mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-12-06 19:56:45 +10:30
fix: fix not being able to switch tabs for community themes
This commit is contained in:
1 parent
9d8f0613cb
commit
6f4728aa18
5 files changed
+71
-69
No files matched your search
@@ -4,10 +4,11 @@
|
||||
import SkeletonLoader from "@/interface/components/SkeletonLoader.svelte";
|
||||
import type { CommunityThemesState } from "@/interface/hooks/communityThemesState.svelte";
|
||||
|
||||
let { state, searchTerm }: { state: CommunityThemesState; searchTerm: string } = $props();
|
||||
let { communityState, searchTerm }: { communityState: CommunityThemesState; searchTerm: string } =
|
||||
$props();
|
||||
|
||||
const themes = $derived(
|
||||
state.browseThemes.filter((theme) => {
|
||||
communityState.browseThemes.filter((theme) => {
|
||||
const q = searchTerm.toLowerCase();
|
||||
if (!q) return true;
|
||||
return (
|
||||
@@ -18,20 +19,20 @@
|
||||
);
|
||||
</script>
|
||||
|
||||
{#if state.browseLoading}
|
||||
{#if communityState.browseLoading}
|
||||
<div class="grid grid-cols-1 gap-4 py-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{#each Array(6) as _, i (i)}
|
||||
<SkeletonLoader width="100%" height="200px" />
|
||||
{/each}
|
||||
</div>
|
||||
{:else if state.browseError}
|
||||
{:else if communityState.browseError}
|
||||
<div class="flex flex-col items-center justify-center py-24 text-center">
|
||||
<h2 class="text-2xl font-bold">Couldn't load community themes</h2>
|
||||
<p class="mt-3 text-zinc-600 dark:text-zinc-300">{state.browseError}</p>
|
||||
<p class="mt-3 text-zinc-600 dark:text-zinc-300">{communityState.browseError}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-6 rounded-lg bg-zinc-900 px-4 py-2 font-medium text-white dark:bg-zinc-100 dark:text-zinc-900"
|
||||
onclick={() => void state.loadBrowseThemes()}
|
||||
onclick={() => void communityState.loadBrowseThemes()}
|
||||
>
|
||||
Try again
|
||||
</button>
|
||||
@@ -40,27 +41,27 @@
|
||||
<ThemeGrid
|
||||
{themes}
|
||||
{searchTerm}
|
||||
setDisplayTheme={(theme) => (state.displayTheme = theme)}
|
||||
setDisplayTheme={(theme) => (communityState.displayTheme = theme)}
|
||||
toggleFavorite={() => {}}
|
||||
isLoggedIn={false}
|
||||
installedThemeIds={state.currentThemes}
|
||||
installedThemeIds={communityState.currentThemes}
|
||||
variant="community"
|
||||
/>
|
||||
{#if state.displayTheme}
|
||||
{#if communityState.displayTheme}
|
||||
<ThemeModal
|
||||
currentThemes={state.currentThemes}
|
||||
currentThemes={communityState.currentThemes}
|
||||
allThemes={themes}
|
||||
theme={state.displayTheme}
|
||||
displayTheme={state.displayTheme}
|
||||
setDisplayTheme={(t) => (state.displayTheme = t)}
|
||||
selectedThemeId={state.selectedThemeId}
|
||||
installedThemeColors={state.installedThemeColors}
|
||||
theme={communityState.displayTheme}
|
||||
displayTheme={communityState.displayTheme}
|
||||
setDisplayTheme={(t) => (communityState.displayTheme = t)}
|
||||
selectedThemeId={communityState.selectedThemeId}
|
||||
installedThemeColors={communityState.installedThemeColors}
|
||||
variant="community"
|
||||
onInstall={async (themeId) => {
|
||||
if (state.displayTheme) await state.installCommunityTheme(themeId, state.displayTheme);
|
||||
if (communityState.displayTheme) await communityState.installCommunityTheme(themeId, communityState.displayTheme);
|
||||
}}
|
||||
onRemove={(id) => void state.removeInstalledTheme(id)}
|
||||
onApply={(id) => void state.applyInstalledTheme(id)}
|
||||
onRemove={(id) => void communityState.removeInstalledTheme(id)}
|
||||
onApply={(id) => void communityState.applyInstalledTheme(id)}
|
||||
/>
|
||||
{/if}
|
||||
{/if}
|
||||
@@ -16,7 +16,7 @@
|
||||
import { filterThemesByMode } from "@/interface/utils/themeListFilters";
|
||||
import { formatCustomThemeApiError } from "@/seqta/utils/customThemes/apiErrors";
|
||||
|
||||
let { state }: { state: CommunityThemesState } = $props();
|
||||
let { communityState }: { communityState: CommunityThemesState } = $props();
|
||||
|
||||
const statusFilters = ["", "pending", "approved", "rejected"] as const;
|
||||
const themeManager = ThemeManager.getInstance();
|
||||
@@ -38,15 +38,15 @@
|
||||
|
||||
async function submitLocalTheme(theme: CustomTheme) {
|
||||
localSubmitError = null;
|
||||
if (!state.cloudLoggedIn) {
|
||||
state.showSignInOverlay = true;
|
||||
if (!communityState.cloudLoggedIn) {
|
||||
communityState.showSignInOverlay = true;
|
||||
return;
|
||||
}
|
||||
submittingLocalId = theme.id;
|
||||
try {
|
||||
const { submitThemeById } = await import("@/seqta/utils/customThemes/submitLocalTheme");
|
||||
await submitThemeById(theme.id, theme.description?.trim() || undefined);
|
||||
await state.loadMyThemes();
|
||||
await communityState.loadMyThemes();
|
||||
} catch (err) {
|
||||
localSubmitError = formatCustomThemeApiError(err);
|
||||
} finally {
|
||||
@@ -70,7 +70,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if !state.cloudLoggedIn}
|
||||
{#if !communityState.cloudLoggedIn}
|
||||
<div class="mx-auto flex max-w-md flex-col items-center py-20 text-center">
|
||||
<h2 class="text-2xl font-bold">Sign in to manage your themes</h2>
|
||||
<p class="mt-3 text-zinc-600 dark:text-zinc-300">
|
||||
@@ -79,7 +79,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="mt-6 rounded-lg bg-zinc-900 px-5 py-2.5 font-medium text-white dark:bg-zinc-100 dark:text-zinc-900"
|
||||
onclick={() => (state.showSignInOverlay = true)}
|
||||
onclick={() => (communityState.showSignInOverlay = true)}
|
||||
>
|
||||
Sign in with BetterSEQTA Cloud
|
||||
</button>
|
||||
@@ -155,25 +155,25 @@
|
||||
{#each statusFilters as status (status)}
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1 text-sm font-medium transition {state.statusFilter === status
|
||||
class="rounded-full px-3 py-1 text-sm font-medium transition {communityState.statusFilter === status
|
||||
? 'bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900'
|
||||
: 'bg-zinc-200 text-zinc-700 hover:bg-zinc-300 dark:bg-zinc-800 dark:text-zinc-300'}"
|
||||
onclick={() => (state.statusFilter = status)}
|
||||
onclick={() => (communityState.statusFilter = status)}
|
||||
>
|
||||
{status === "" ? "All" : formatCustomThemeStatus(status)}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
{#if state.myLoading}
|
||||
{#if communityState.myLoading}
|
||||
<div class="grid grid-cols-1 gap-3">
|
||||
{#each Array(4) as _, i (i)}
|
||||
<SkeletonLoader width="100%" height="72px" />
|
||||
{/each}
|
||||
</div>
|
||||
{:else if state.myError}
|
||||
<p class="text-red-600 dark:text-red-400">{state.myError}</p>
|
||||
{:else if state.myThemes.length === 0}
|
||||
{:else if communityState.myError}
|
||||
<p class="text-red-600 dark:text-red-400">{communityState.myError}</p>
|
||||
{:else if communityState.myThemes.length === 0}
|
||||
<div class="py-10 text-center">
|
||||
<p class="text-lg text-zinc-600 dark:text-zinc-300">No community submissions yet.</p>
|
||||
<button
|
||||
@@ -189,12 +189,12 @@
|
||||
</div>
|
||||
{:else}
|
||||
<ul class="space-y-3">
|
||||
{#each state.myThemes as theme (theme.id)}
|
||||
{#each communityState.myThemes as theme (theme.id)}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full items-center gap-4 rounded-xl border border-zinc-200 bg-white p-4 text-left transition hover:border-zinc-300 hover:shadow-sm dark:border-zinc-700 dark:bg-zinc-800 dark:hover:border-zinc-600"
|
||||
onclick={() => void state.openDetail(theme)}
|
||||
onclick={() => void communityState.openDetail(theme)}
|
||||
>
|
||||
{#if theme.coverImage}
|
||||
<img src={theme.coverImage} alt="" class="h-14 w-20 shrink-0 rounded-lg object-cover" />
|
||||
@@ -221,6 +221,6 @@
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if state.showSignInOverlay}
|
||||
<SignInToFavoriteModal onClose={() => (state.showSignInOverlay = false)} />
|
||||
{#if communityState.showSignInOverlay}
|
||||
<SignInToFavoriteModal onClose={() => (communityState.showSignInOverlay = false)} />
|
||||
{/if}
|
||||
@@ -9,16 +9,16 @@
|
||||
statusBadgeClass,
|
||||
} from "@/seqta/utils/customThemes/client";
|
||||
|
||||
let { state }: { state: CommunityThemesState } = $props();
|
||||
let { communityState }: { communityState: CommunityThemesState } = $props();
|
||||
|
||||
const theme = $derived(state.detailTheme);
|
||||
const theme = $derived(communityState.detailTheme);
|
||||
</script>
|
||||
|
||||
<ModalFrame
|
||||
open={theme != null}
|
||||
busy={state.detailBusy}
|
||||
busy={communityState.detailBusy}
|
||||
maxWidthClass="max-w-2xl"
|
||||
onClose={() => state.closeDetail()}
|
||||
onClose={() => communityState.closeDetail()}
|
||||
>
|
||||
{#if theme}
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
@@ -34,7 +34,7 @@
|
||||
type="button"
|
||||
class="rounded-lg p-2 hover:bg-zinc-100 dark:hover:bg-zinc-700"
|
||||
aria-label="Close"
|
||||
onclick={() => state.closeDetail()}
|
||||
onclick={() => communityState.closeDetail()}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
@@ -49,7 +49,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if state.detailLoading}
|
||||
{#if communityState.detailLoading}
|
||||
<div class="py-8"><SkeletonLoader width="100%" height="120px" /></div>
|
||||
{:else}
|
||||
<dl class="mt-4 grid grid-cols-2 gap-3 text-sm">
|
||||
@@ -75,11 +75,11 @@
|
||||
{/if}
|
||||
</dl>
|
||||
|
||||
{#if state.detailFiles.length > 0}
|
||||
{#if communityState.detailFiles.length > 0}
|
||||
<div class="mt-4">
|
||||
<h3 class="text-sm font-semibold">Files</h3>
|
||||
<ul class="mt-2 space-y-1 text-sm text-zinc-600 dark:text-zinc-400">
|
||||
{#each state.detailFiles as file (file.id)}
|
||||
{#each communityState.detailFiles as file (file.id)}
|
||||
<li>{file.file_path} ({file.file_size.toLocaleString()} bytes)</li>
|
||||
{/each}
|
||||
</ul>
|
||||
@@ -91,26 +91,26 @@
|
||||
<h3 class="font-semibold">Edit metadata</h3>
|
||||
<input
|
||||
class="w-full rounded-lg border border-zinc-300 px-3 py-2 text-sm dark:border-zinc-600 dark:bg-zinc-900"
|
||||
bind:value={state.editName}
|
||||
bind:value={communityState.editName}
|
||||
placeholder="Name"
|
||||
/>
|
||||
<textarea
|
||||
class="w-full rounded-lg border border-zinc-300 px-3 py-2 text-sm dark:border-zinc-600 dark:bg-zinc-900"
|
||||
rows="2"
|
||||
bind:value={state.editDescription}
|
||||
bind:value={communityState.editDescription}
|
||||
placeholder="Description"
|
||||
></textarea>
|
||||
<textarea
|
||||
class="w-full rounded-lg border border-zinc-300 px-3 py-2 text-sm dark:border-zinc-600 dark:bg-zinc-900"
|
||||
rows="2"
|
||||
bind:value={state.editNotes}
|
||||
bind:value={communityState.editNotes}
|
||||
placeholder="Submission notes"
|
||||
></textarea>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-zinc-200 px-4 py-2 text-sm font-medium dark:bg-zinc-700"
|
||||
disabled={state.detailBusy}
|
||||
onclick={() => void state.saveMetadata()}
|
||||
disabled={communityState.detailBusy}
|
||||
onclick={() => void communityState.saveMetadata()}
|
||||
>
|
||||
Save metadata
|
||||
</button>
|
||||
@@ -122,14 +122,14 @@
|
||||
accept=".zip,application/zip"
|
||||
class="block w-full text-sm"
|
||||
onchange={(e) => {
|
||||
state.replaceZipFile = (e.currentTarget as HTMLInputElement).files?.[0] ?? null;
|
||||
communityState.replaceZipFile = (e.currentTarget as HTMLInputElement).files?.[0] ?? null;
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-zinc-900 px-4 py-2 text-sm font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900"
|
||||
disabled={state.detailBusy || !state.replaceZipFile}
|
||||
onclick={() => void state.runReplaceFiles()}
|
||||
disabled={communityState.detailBusy || !communityState.replaceZipFile}
|
||||
onclick={() => void communityState.runReplaceFiles()}
|
||||
>
|
||||
Upload revised files
|
||||
</button>
|
||||
@@ -140,30 +140,30 @@
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
{#if state.detailError}
|
||||
{#if communityState.detailError}
|
||||
<p class="mt-4 whitespace-pre-line text-sm text-red-600 dark:text-red-400">
|
||||
{state.detailError}
|
||||
{communityState.detailError}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<div
|
||||
class="mt-6 flex flex-wrap justify-between gap-2 border-t border-zinc-200 pt-4 dark:border-zinc-700"
|
||||
>
|
||||
{#if state.showDeleteConfirm}
|
||||
{#if communityState.showDeleteConfirm}
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-sm text-red-600 dark:text-red-400">Delete permanently?</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-red-600 px-3 py-1.5 text-sm font-medium text-white"
|
||||
disabled={state.detailBusy}
|
||||
onclick={() => void state.runDelete()}
|
||||
disabled={communityState.detailBusy}
|
||||
onclick={() => void communityState.runDelete()}
|
||||
>
|
||||
Confirm delete
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-3 py-1.5 text-sm"
|
||||
onclick={() => (state.showDeleteConfirm = false)}
|
||||
onclick={() => (communityState.showDeleteConfirm = false)}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
@@ -172,7 +172,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-4 py-2 text-sm font-medium text-red-600 hover:bg-red-50 dark:hover:bg-red-950"
|
||||
onclick={() => (state.showDeleteConfirm = true)}
|
||||
onclick={() => (communityState.showDeleteConfirm = true)}
|
||||
>
|
||||
Delete theme
|
||||
</button>
|
||||
@@ -180,7 +180,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-zinc-200 px-4 py-2 text-sm font-medium dark:bg-zinc-700"
|
||||
onclick={() => state.closeDetail()}
|
||||
onclick={() => communityState.closeDetail()}
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
let { searchTerm }: { searchTerm: string; setSearchTerm?: (term: string) => void } = $props();
|
||||
|
||||
const state = createCommunityThemesState(() => searchTerm);
|
||||
state.bindReactiveLoads();
|
||||
const communityState = createCommunityThemesState(() => searchTerm);
|
||||
communityState.bindReactiveLoads();
|
||||
|
||||
onMount(() => state.mount());
|
||||
onMount(() => communityState.mount());
|
||||
</script>
|
||||
|
||||
<div class="relative flex h-full min-h-0 flex-col overflow-hidden text-zinc-900 dark:text-white">
|
||||
@@ -19,19 +19,19 @@
|
||||
<div class="inline-flex rounded-xl bg-zinc-200/80 p-1 dark:bg-zinc-800/80">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-4 py-2 text-sm font-medium transition-colors {state.innerTab === 'browse'
|
||||
class="rounded-lg px-4 py-2 text-sm font-medium transition-colors {communityState.innerTab === 'browse'
|
||||
? 'bg-white text-zinc-900 shadow dark:bg-zinc-700 dark:text-white'
|
||||
: 'text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white'}"
|
||||
onclick={() => (state.innerTab = "browse")}
|
||||
onclick={() => (communityState.innerTab = "browse")}
|
||||
>
|
||||
Browse
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-4 py-2 text-sm font-medium transition-colors {state.innerTab === 'mine'
|
||||
class="rounded-lg px-4 py-2 text-sm font-medium transition-colors {communityState.innerTab === 'mine'
|
||||
? 'bg-white text-zinc-900 shadow dark:bg-zinc-700 dark:text-white'
|
||||
: 'text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white'}"
|
||||
onclick={() => (state.innerTab = "mine")}
|
||||
onclick={() => (communityState.innerTab = "mine")}
|
||||
>
|
||||
My themes
|
||||
</button>
|
||||
@@ -53,12 +53,12 @@
|
||||
</div>
|
||||
|
||||
<main class="min-h-0 flex-1 overflow-y-auto bg-zinc-50/80 px-6 py-6 dark:bg-zinc-900/40 md:px-8 lg:px-10">
|
||||
{#if state.innerTab === "browse"}
|
||||
<BrowsePanel {state} {searchTerm} />
|
||||
{#if communityState.innerTab === "browse"}
|
||||
<BrowsePanel {communityState} {searchTerm} />
|
||||
{:else}
|
||||
<MyThemesPanel {state} />
|
||||
<MyThemesPanel {communityState} />
|
||||
{/if}
|
||||
</main>
|
||||
|
||||
<OwnerThemeDetailModal {state} />
|
||||
<OwnerThemeDetailModal {communityState} />
|
||||
</div>
|
||||
@@ -17,6 +17,7 @@
|
||||
import { cloudAuth } from '@/seqta/utils/CloudAuth'
|
||||
import SignInToFavoriteModal from '../components/SignInToFavoriteModal.svelte'
|
||||
import { getStoreInstalledThemeIds } from '@/interface/utils/themeListFilters'
|
||||
import { consumePendingHighlightThemeId } from '@/seqta/utils/openThemeStoreWithHighlight'
|
||||
|
||||
const themeManager = ThemeManager.getInstance();
|
||||
type StoreTab = 'themes' | 'backgrounds';
|
||||
|
||||
Reference in new issue
Block a user