diff --git a/src/interface/components/themes/ThemeSelector.svelte b/src/interface/components/themes/ThemeSelector.svelte index 0e278354..dd8718f4 100644 --- a/src/interface/components/themes/ThemeSelector.svelte +++ b/src/interface/components/themes/ThemeSelector.svelte @@ -232,18 +232,6 @@ const useTwoColumnLayout = $derived(listMode === 'downloaded' || listMode === 'custom'); -{#snippet customThemeUploadZone()} - -{/snippet} -
+ {#if allowsFileImport} + + {/if} {#if themes} {#each visibleThemes as theme (theme.id)}
{/if} - {#if allowsFileImport && themes && visibleThemes.length > 0 && !tempTheme} - {@render customThemeUploadZone()} - {/if} - {#if themes && (listMode === 'custom' || (showNavigation && visibleThemes.length > 0) || (listMode === 'downloaded' && visibleThemes.length > 0))}
diff --git a/src/interface/pages/communityThemes.svelte b/src/interface/pages/communityThemes.svelte index 84d82826..1494df41 100644 --- a/src/interface/pages/communityThemes.svelte +++ b/src/interface/pages/communityThemes.svelte @@ -34,7 +34,7 @@ } from "@/seqta/utils/customThemes/buildThemeUploadFormData"; import type { CustomThemeOwner, CustomThemeFile } from "@/seqta/utils/customThemes/types"; import type { LoadedCustomTheme } from "@/types/CustomThemes"; - import { isLocalCustomTheme } from "@/interface/utils/themeListFilters"; + import { getCommunityInstalledThemeIds, isLocalCustomTheme } from "@/interface/utils/themeListFilters"; let { searchTerm, @@ -94,10 +94,12 @@ async function refreshInstalledThemes() { const themes = await themeManager.getAvailableThemes(); - currentThemes = themes.filter((t) => t !== null).map((t) => t.id); + currentThemes = getCommunityInstalledThemeIds(themes); selectedThemeId = themeManager.getSelectedThemeId() || ""; installedThemeColors = Object.fromEntries( - themes.filter((t) => t != null).map((t) => [t.id, t.defaultColour]), + themes + .filter((t) => t != null && t.installedFromCommunity === true) + .map((t) => [t.id, t.defaultColour]), ); } diff --git a/src/interface/pages/store.svelte b/src/interface/pages/store.svelte index 5df465ca..1ee39425 100644 --- a/src/interface/pages/store.svelte +++ b/src/interface/pages/store.svelte @@ -16,7 +16,7 @@ import Backgrounds from '../components/store/Backgrounds.svelte' import { cloudAuth } from '@/seqta/utils/CloudAuth' import SignInToFavoriteModal from '../components/SignInToFavoriteModal.svelte' - import { consumePendingHighlightThemeId } from '@/seqta/utils/openThemeStoreWithHighlight' + import { getStoreInstalledThemeIds } from '@/interface/utils/themeListFilters' const themeManager = ThemeManager.getInstance(); type StoreTab = 'themes' | 'backgrounds'; @@ -75,10 +75,12 @@ const fetchCurrentThemes = async () => { const themes = await themeManager.getAvailableThemes(); - currentThemes = themes.filter(theme => theme !== null).map(theme => theme.id); + currentThemes = getStoreInstalledThemeIds(themes); selectedThemeId = themeManager.getSelectedThemeId() || ''; installedThemeColors = Object.fromEntries( - themes.filter((theme) => theme != null).map((theme) => [theme.id, theme.defaultColour]), + themes + .filter((theme) => theme != null && theme.installedFromStore === true) + .map((theme) => [theme.id, theme.defaultColour]), ); }; diff --git a/src/interface/utils/themeListFilters.test.ts b/src/interface/utils/themeListFilters.test.ts index e53cfc56..d1389027 100644 --- a/src/interface/utils/themeListFilters.test.ts +++ b/src/interface/utils/themeListFilters.test.ts @@ -3,6 +3,8 @@ import type { Theme } from '@/interface/types/Theme'; import { filterThemesByMode, getThemeApplyButtonStyles, + getCommunityInstalledThemeIds, + getStoreInstalledThemeIds, isDownloadedTheme, isLocalCustomTheme, isStoreThemeInstalled, @@ -127,6 +129,31 @@ describe('filterThemesByMode', () => { }); }); +describe('getStoreInstalledThemeIds', () => { + it('returns only store-installed theme ids', () => { + const themes = [ + makeCustomTheme({ id: 'store-1', name: 'Store', installedFromStore: true }), + makeCustomTheme({ id: 'local-1', name: 'Local' }), + makeCustomTheme({ + id: 'same-as-store', + name: 'Imported copy', + installedFromStore: false, + }), + ]; + expect(getStoreInstalledThemeIds(themes)).toEqual(['store-1']); + }); +}); + +describe('getCommunityInstalledThemeIds', () => { + it('returns only community-installed theme ids', () => { + const themes = [ + makeCustomTheme({ id: 'community-1', name: 'Community', installedFromCommunity: true }), + makeCustomTheme({ id: 'local-1', name: 'Local' }), + ]; + expect(getCommunityInstalledThemeIds(themes)).toEqual(['community-1']); + }); +}); + describe('isStoreThemeInstalled', () => { it('returns true when master id is installed', () => { const theme = makeStoreTheme({ id: 'master-1', name: 'Master' }); diff --git a/src/interface/utils/themeListFilters.ts b/src/interface/utils/themeListFilters.ts index 66666730..d7b4d4ea 100644 --- a/src/interface/utils/themeListFilters.ts +++ b/src/interface/utils/themeListFilters.ts @@ -42,6 +42,18 @@ export function filterThemesByMode(themes: CustomTheme[], mode: ThemeListMode): return themes.filter(isDownloadedTheme); } +/** Installed theme ids from the official store only (excludes file imports / custom copies). */ +export function getStoreInstalledThemeIds(themes: CustomTheme[]): string[] { + return themes.filter((theme) => theme.installedFromStore === true).map((theme) => theme.id); +} + +/** Installed theme ids from the community API only (excludes file imports / custom copies). */ +export function getCommunityInstalledThemeIds(themes: CustomTheme[]): string[] { + return themes + .filter((theme) => theme.installedFromCommunity === true) + .map((theme) => theme.id); +} + export function isStoreThemeInstalled(theme: Theme, installedIds: string[]): boolean { const installed = new Set(installedIds); if (installed.has(theme.id)) return true;