Fix an issue with the app breaking if no battlenet is installed

This commit is contained in:
jliddev
2022-01-23 18:47:52 +00:00
parent 5024baa626
commit a33d93ebbb
2 changed files with 15 additions and 9 deletions

View File

@@ -21,7 +21,7 @@ export class GetAddonListItem {
return this.searchResult.externalId;
}
public constructor(searchResult: AddonSearchResult, defaultAddonChannel: AddonChannelType) {
public constructor(searchResult: AddonSearchResult, defaultAddonChannel?: AddonChannelType) {
this.searchResult = searchResult;
this.author = this.searchResult.author;
this.name = this.searchResult.name;
@@ -30,9 +30,11 @@ export class GetAddonListItem {
this.downloadCount = this.searchResult.downloadCount || 0;
this.canonicalName = this.name.toLowerCase();
const latestFile = SearchResults.getLatestFile(searchResult, defaultAddonChannel);
this.latestAddonChannel = latestFile?.channelType ?? AddonChannelType.Stable;
if (defaultAddonChannel) {
const latestFile = SearchResults.getLatestFile(searchResult, defaultAddonChannel);
this.latestAddonChannel = latestFile?.channelType ?? AddonChannelType.Stable;
this.releasedAt = new Date(latestFile?.releaseDate ?? new Date()).getTime();
this.releasedAt = new Date(latestFile?.releaseDate ?? new Date()).getTime();
}
}
}

View File

@@ -108,8 +108,8 @@ export class GetAddonsComponent implements OnInit, OnDestroy {
{ name: "status", display: "PAGES.GET_ADDONS.TABLE.STATUS_COLUMN_HEADER", visible: true },
];
public get defaultAddonChannel(): AddonChannelType {
return this._sessionService.getSelectedWowInstallation().defaultAddonChannelType;
public get defaultAddonChannel(): AddonChannelType | undefined {
return this._sessionService.getSelectedWowInstallation()?.defaultAddonChannelType;
}
public query = "";
@@ -196,9 +196,8 @@ export class GetAddonsComponent implements OnInit, OnDestroy {
public relativeDurationPipe: RelativeDurationPipe,
public downloadCountPipe: DownloadCountPipe
) {
this.overlayNoRowsTemplate = `<span class="text-1 mat-h1">${
_translateService.instant("COMMON.SEARCH.NO_ADDONS") as string
}</span>`;
this.overlayNoRowsTemplate = `<span class="text-1 mat-h1">${_translateService.instant("COMMON.SEARCH.NO_ADDONS") as string
}</span>`;
this.wowInstallations$ = warcraftInstallationService.wowInstallations$;
@@ -289,6 +288,11 @@ export class GetAddonsComponent implements OnInit, OnDestroy {
}
public onRowDoubleClicked(evt: RowDoubleClickedEvent): void {
const defaultChannel = this.defaultAddonChannel;
if (!defaultChannel) {
return;
}
this.openDetailDialog(evt.data.searchResult as AddonSearchResult, this.defaultAddonChannel);
evt.node.setSelected(true);
}