From ac8dbe2ca4b0ad007c5695fc599095cd0dce1498 Mon Sep 17 00:00:00 2001 From: jliddev Date: Sun, 23 Jan 2022 23:21:21 -0600 Subject: [PATCH] Hook the tabs to the enable controls global Fix the get-addons breaking bug --- wowup-electron/package.json | 2 +- .../business-objects/get-addon-list-item.ts | 2 +- .../vertical-tabs/vertical-tabs.component.ts | 20 ++++++++++--------- .../pages/get-addons/get-addons.component.ts | 6 +++--- .../src/app/pipes/relative-duration-pipe.ts | 3 +++ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/wowup-electron/package.json b/wowup-electron/package.json index f002bd46..a8aaa4a4 100644 --- a/wowup-electron/package.json +++ b/wowup-electron/package.json @@ -1,7 +1,7 @@ { "name": "wowup", "productName": "WowUp", - "version": "2.6.1-beta.1", + "version": "2.6.1-beta.2", "description": "World of Warcraft addon updater", "homepage": "https://wowup.io", "author": { 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 f9671810..21635599 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 @@ -30,7 +30,7 @@ export class GetAddonListItem { this.downloadCount = this.searchResult.downloadCount || 0; this.canonicalName = this.name.toLowerCase(); - if (defaultAddonChannel) { + if (defaultAddonChannel !== undefined) { const latestFile = SearchResults.getLatestFile(searchResult, defaultAddonChannel); this.latestAddonChannel = latestFile?.channelType ?? AddonChannelType.Stable; diff --git a/wowup-electron/src/app/components/common/vertical-tabs/vertical-tabs.component.ts b/wowup-electron/src/app/components/common/vertical-tabs/vertical-tabs.component.ts index e8b1355e..69ed9f08 100644 --- a/wowup-electron/src/app/components/common/vertical-tabs/vertical-tabs.component.ts +++ b/wowup-electron/src/app/components/common/vertical-tabs/vertical-tabs.component.ts @@ -64,9 +64,10 @@ export class VerticalTabsComponent implements OnInit, OnDestroy { tooltipKey: "PAGES.HOME.MY_ADDONS_TAB_TITLE", icon: "fas:dice-d6", isSelected$: this.sessionService.selectedHomeTab$.pipe(map((result) => result === TAB_INDEX_MY_ADDONS)), - isDisabled$: this._warcraftInstallationService.wowInstallations$.pipe( - map((installations) => installations.length === 0) - ), + isDisabled$: combineLatest([ + this._warcraftInstallationService.wowInstallations$, + this.sessionService.enableControls$, + ]).pipe(map(([installations, enableControls]) => !enableControls || installations.length === 0)), onClick: (): void => { this.sessionService.selectedHomeTab = TAB_INDEX_MY_ADDONS; }, @@ -77,9 +78,10 @@ export class VerticalTabsComponent implements OnInit, OnDestroy { tooltipKey: "PAGES.HOME.GET_ADDONS_TAB_TITLE", icon: "fas:search", isSelected$: this.sessionService.selectedHomeTab$.pipe(map((result) => result === TAB_INDEX_GET_ADDONS)), - isDisabled$: this._warcraftInstallationService.wowInstallations$.pipe( - map((installations) => installations.length === 0) - ), + isDisabled$: combineLatest([ + this._warcraftInstallationService.wowInstallations$, + this.sessionService.enableControls$, + ]).pipe(map(([installations, enableControls]) => !enableControls || installations.length === 0)), onClick: (): void => { this.sessionService.selectedHomeTab = TAB_INDEX_GET_ADDONS; }, @@ -90,7 +92,7 @@ export class VerticalTabsComponent implements OnInit, OnDestroy { tooltipKey: "PAGES.HOME.ACCOUNT_TAB_TITLE", icon: "fas:user-circle", isSelected$: this.sessionService.selectedHomeTab$.pipe(map((result) => result === TAB_INDEX_ABOUT)), - isDisabled$: of(false), + isDisabled$: this.sessionService.enableControls$.pipe(map((enabled) => !enabled)), onClick: (): void => { this.sessionService.selectedHomeTab = TAB_INDEX_ABOUT; }, @@ -102,7 +104,7 @@ export class VerticalTabsComponent implements OnInit, OnDestroy { icon: "fas:newspaper", badge: true, isSelected$: this.sessionService.selectedHomeTab$.pipe(map((result) => result === TAB_INDEX_NEWS)), - isDisabled$: of(false), + isDisabled$: this.sessionService.enableControls$.pipe(map((enabled) => !enabled)), onClick: (): void => { this.sessionService.selectedHomeTab = TAB_INDEX_NEWS; }, @@ -113,7 +115,7 @@ export class VerticalTabsComponent implements OnInit, OnDestroy { tooltipKey: "PAGES.HOME.OPTIONS_TAB_TITLE", icon: "fas:cog", isSelected$: this.sessionService.selectedHomeTab$.pipe(map((result) => result === TAB_INDEX_SETTINGS)), - isDisabled$: of(false), + isDisabled$: this.sessionService.enableControls$.pipe(map((enabled) => !enabled)), onClick: (): void => { this.sessionService.selectedHomeTab = TAB_INDEX_SETTINGS; }, 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 b263b730..c8a3141a 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 @@ -109,7 +109,8 @@ export class GetAddonsComponent implements OnInit, OnDestroy { ]; public get defaultAddonChannel(): AddonChannelType | undefined { - return this._sessionService.getSelectedWowInstallation()?.defaultAddonChannelType; + const installation = this._sessionService.getSelectedWowInstallation(); + return installation?.defaultAddonChannelType ?? undefined; } public query = ""; @@ -290,7 +291,7 @@ export class GetAddonsComponent implements OnInit, OnDestroy { public onRowDoubleClicked(evt: RowDoubleClickedEvent): void { const defaultChannel = this.defaultAddonChannel; - if (!defaultChannel) { + if (defaultChannel === undefined) { return; } @@ -580,7 +581,6 @@ export class GetAddonsComponent implements OnInit, OnDestroy { }) ) .subscribe((addons) => { - console.debug(`Loaded ${addons?.length ?? 0} addons`); const listItems = this.formatAddons(addons); this._rowDataSrc.next(listItems); this._showTableSrc.next(true); diff --git a/wowup-electron/src/app/pipes/relative-duration-pipe.ts b/wowup-electron/src/app/pipes/relative-duration-pipe.ts index 9c90d055..b3bd52cf 100644 --- a/wowup-electron/src/app/pipes/relative-duration-pipe.ts +++ b/wowup-electron/src/app/pipes/relative-duration-pipe.ts @@ -9,6 +9,9 @@ export class RelativeDurationPipe implements PipeTransform { public constructor(private _translate: TranslateService) {} public transform(value: string): string { + if (!value) { + return "EMPTY"; + } const [fmt, val] = getRelativeDateFormat(value); return this._translate.instant(fmt, val); }