From 6842eb05debb77e4f7e84d12565e20bdbba15c18 Mon Sep 17 00:00:00 2001 From: oto-ciulis-tt <62436273+oto-ciulis-tt@users.noreply.github.com> Date: Sat, 16 Nov 2024 08:46:55 -0800 Subject: [PATCH] feat: Adding download count badge to sidebar (#1552) * feat: Adding download count badge to sidebar * Fixing lint * Updating electronDownloadStore to handle missing DownloadManager * PR comments --------- Co-authored-by: Oto Ciulis --- src/hooks/sidebarTabs/modelLibrarySidebarTab.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/hooks/sidebarTabs/modelLibrarySidebarTab.ts b/src/hooks/sidebarTabs/modelLibrarySidebarTab.ts index 5ed0dad78..7b0e20834 100644 --- a/src/hooks/sidebarTabs/modelLibrarySidebarTab.ts +++ b/src/hooks/sidebarTabs/modelLibrarySidebarTab.ts @@ -2,15 +2,28 @@ import { markRaw } from 'vue' import { useI18n } from 'vue-i18n' import ModelLibrarySidebarTab from '@/components/sidebar/tabs/ModelLibrarySidebarTab.vue' import type { SidebarTabExtension } from '@/types/extensionTypes' +import { useElectronDownloadStore } from '@/stores/electronDownloadStore' +import { isElectron } from '@/utils/envUtil' export const useModelLibrarySidebarTab = (): SidebarTabExtension => { const { t } = useI18n() + return { id: 'model-library', icon: 'pi pi-box', title: t('sideToolbar.modelLibrary'), tooltip: t('sideToolbar.modelLibrary'), component: markRaw(ModelLibrarySidebarTab), - type: 'vue' + type: 'vue', + iconBadge: () => { + if (isElectron()) { + const electronDownloadStore = useElectronDownloadStore() + if (electronDownloadStore.downloads.length > 0) { + return electronDownloadStore.downloads.length.toString() + } + } + + return null + } } }