feat: implement cloud store

This commit is contained in:
2026-02-20 10:27:17 +10:30
parent 170b1cf5c3
commit d64962147a
5 changed files with 80 additions and 17 deletions
+12 -6
View File
@@ -48,20 +48,26 @@
activeTab = tab;
};
// Fetch themes and initialize app
// Fetch themes via background script (avoids CORS when store runs inside SEQTA page)
const fetchThemes = async () => {
try {
const response = await fetch(`https://raw.githubusercontent.com/BetterSEQTA/BetterSEQTA-Themes/main/store/themes.json?nocache=${(new Date()).getTime()}`, { cache: 'no-store' });
const data = await response.json();
themes = data.themes;
const data = (await browser.runtime.sendMessage({ type: 'fetchThemes' })) as {
success?: boolean;
data?: { themes: Theme[] };
error?: string;
};
if (!data?.success || !data?.data?.themes) {
throw new Error(data?.error || 'Failed to fetch themes');
}
themes = data.data.themes;
// Shuffle for cover themes
const shuffled = [...themes].sort(() => 0.5 - Math.random());
coverThemes = shuffled.slice(0, 3);
loading = false;
} catch (error) {
console.error('Failed to fetch themes', error);
} catch (err) {
console.error('Failed to fetch themes', err);
setTimeout(fetchThemes, 5000); // Retry after 5 seconds if failure occurs
}
};