From a33d93ebbb00e5b44140bf387aa4a04b233b957f Mon Sep 17 00:00:00 2001 From: jliddev Date: Sun, 23 Jan 2022 18:47:52 +0000 Subject: [PATCH] Fix an issue with the app breaking if no battlenet is installed --- .../app/business-objects/get-addon-list-item.ts | 10 ++++++---- .../app/pages/get-addons/get-addons.component.ts | 14 +++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/wowup-electron/src/app/business-objects/get-addon-list-item.ts b/wowup-electron/src/app/business-objects/get-addon-list-item.ts index ce01a8aa..f9671810 100644 --- a/wowup-electron/src/app/business-objects/get-addon-list-item.ts +++ b/wowup-electron/src/app/business-objects/get-addon-list-item.ts @@ -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(); + } } } diff --git a/wowup-electron/src/app/pages/get-addons/get-addons.component.ts b/wowup-electron/src/app/pages/get-addons/get-addons.component.ts index 89298325..5fe40993 100644 --- a/wowup-electron/src/app/pages/get-addons/get-addons.component.ts +++ b/wowup-electron/src/app/pages/get-addons/get-addons.component.ts @@ -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 = `${ - _translateService.instant("COMMON.SEARCH.NO_ADDONS") as string - }`; + this.overlayNoRowsTemplate = `${_translateService.instant("COMMON.SEARCH.NO_ADDONS") as string + }`; 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); }