mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
I have literally lost track. Please save me, I am going crazy
This commit is contained in:
@@ -66,7 +66,7 @@ export const ThemeCover: React.FC<ThemeCoverProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{ !isEditMode || !downloaded &&
|
{ isEditMode || !downloaded &&
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
className="absolute z-20 flex w-8 h-8 p-2 text-white transition-all rounded-full delay-[20ms] opacity-0 top-1 right-2 dark:bg-black/50 place-items-center group-hover:opacity-100 group-hover:top-[1.25rem]"
|
className="absolute z-20 flex w-8 h-8 p-2 text-white transition-all rounded-full delay-[20ms] opacity-0 top-1 right-2 dark:bg-black/50 place-items-center group-hover:opacity-100 group-hover:top-[1.25rem]"
|
||||||
|
|||||||
@@ -59,6 +59,17 @@ const ThemeSelector: ForwardRefExoticComponent<Omit<ThemeSelectorProps, "ref"> &
|
|||||||
setThemes(themes);
|
setThemes(themes);
|
||||||
setDownloadedThemes(await getDownloadedThemes());
|
setDownloadedThemes(await getDownloadedThemes());
|
||||||
setSelectedTheme(selectedTheme ? selectedTheme : '');
|
setSelectedTheme(selectedTheme ? selectedTheme : '');
|
||||||
|
|
||||||
|
const matchingThemes = themes.filter(theme => downloadedThemes.some((downloadedTheme: DownloadedTheme) => downloadedTheme.id === theme.id));
|
||||||
|
if (matchingThemes.length > 0) {
|
||||||
|
matchingThemes.forEach((theme) => {
|
||||||
|
browser.runtime.sendMessage({
|
||||||
|
type: 'DeleteDownloadedTheme',
|
||||||
|
body: theme.id
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching themes:', error);
|
console.error('Error fetching themes:', error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { LinkIcon } from "@heroicons/react/24/outline";
|
|||||||
import { ToastContainer, toast } from 'react-toastify';
|
import { ToastContainer, toast } from 'react-toastify';
|
||||||
import browser from 'webextension-polyfill';
|
import browser from 'webextension-polyfill';
|
||||||
import 'react-toastify/dist/ReactToastify.css';
|
import 'react-toastify/dist/ReactToastify.css';
|
||||||
|
import localforage from "localforage";
|
||||||
|
|
||||||
const pb = new PocketBase('https://betterseqta.pockethost.io');
|
const pb = new PocketBase('https://betterseqta.pockethost.io');
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ const Theme = () => {
|
|||||||
const [themeID, setThemeID] = useState<string>('');
|
const [themeID, setThemeID] = useState<string>('');
|
||||||
const [justCreated, setJustCreated] = useState(false);
|
const [justCreated, setJustCreated] = useState(false);
|
||||||
const [displayConfetti, setDisplayConfetti] = useState(true);
|
const [displayConfetti, setDisplayConfetti] = useState(true);
|
||||||
|
const [currentThemes, setCurrentThemes] = useState<string[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
@@ -37,6 +39,9 @@ const Theme = () => {
|
|||||||
console.log(theme);
|
console.log(theme);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setTheme(theme);
|
setTheme(theme);
|
||||||
|
|
||||||
|
const availableThemes = await localforage.getItem('availableThemes') as string[];
|
||||||
|
setCurrentThemes(availableThemes)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (themeID && themeID !== 'null') {
|
if (themeID && themeID !== 'null') {
|
||||||
@@ -94,12 +99,24 @@ const Theme = () => {
|
|||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<h2 className="mb-2 text-2xl font-bold">{theme.name}</h2>
|
<h2 className="mb-2 text-2xl font-bold">{theme.name}</h2>
|
||||||
<p className="mb-8">{theme.description}</p>
|
<p className="mb-8">{theme.description}</p>
|
||||||
|
{
|
||||||
|
/* currentThemes.includes((theme.theme as { id: string }).id) */ false ?
|
||||||
|
<button
|
||||||
|
className="flex justify-center w-full gap-1 px-3 py-2 text-white transition cursor-not-allowed rounded-2xl ring-white/20 ring-1 bg-zinc-950/20"
|
||||||
|
>
|
||||||
|
Theme Installed
|
||||||
|
</button>
|
||||||
|
:
|
||||||
<button
|
<button
|
||||||
className="flex justify-center w-full gap-1 px-3 py-2 text-white transition cursor-pointer rounded-2xl ring-white/20 hover:ring-white/10 ring-1 bg-zinc-950/20 hover:bg-zinc-950/40"
|
className="flex justify-center w-full gap-1 px-3 py-2 text-white transition cursor-pointer rounded-2xl ring-white/20 hover:ring-white/10 ring-1 bg-zinc-950/20 hover:bg-zinc-950/40"
|
||||||
onClick={() => browser.runtime.sendMessage({ type: 'DownloadTheme', body: { theme } }) }
|
onClick={() => {
|
||||||
|
browser.runtime.sendMessage({ type: 'DownloadTheme', body: { theme } });
|
||||||
|
setCurrentThemes([...currentThemes, (theme.theme as { id: string }).id]);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Install Theme
|
Install Theme
|
||||||
</button>
|
</button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<ToastContainer theme="dark" />
|
<ToastContainer theme="dark" />
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import localforage from 'localforage';
|
import localforage from 'localforage';
|
||||||
import { ThemesResponse } from '../../../interface/types/pocketbase-types';
|
import { ThemesResponse } from '../../../interface/types/pocketbase-types';
|
||||||
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
import { CustomTheme } from '../../../interface/types/CustomThemes';
|
||||||
import browser from 'webextension-polyfill';
|
|
||||||
|
|
||||||
const DownloadTheme = async (theme: ThemesResponse & { theme: CustomTheme & { images: { id: string, variableName: string }[] } }) => {
|
const DownloadTheme = async (theme: ThemesResponse & { theme: CustomTheme & { images: { id: string, variableName: string }[] } }) => {
|
||||||
const images: { imageData: Blob, imageID: string }[] = []
|
const images: { imageData: Blob, imageID: string }[] = []
|
||||||
@@ -36,12 +35,12 @@ const DownloadTheme = async (theme: ThemesResponse & { theme: CustomTheme & { im
|
|||||||
CustomImages: theme.theme.images.map((image) => {
|
CustomImages: theme.theme.images.map((image) => {
|
||||||
return {
|
return {
|
||||||
...image,
|
...image,
|
||||||
blob: images.find((i) => i.imageID.split('_')[0] === image.id)?.imageData
|
blob: images.find((img) => {
|
||||||
|
return image.id.includes(img.imageID.split('_')[0]);
|
||||||
|
})?.imageData
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
browser.runtime.sendMessage({ type: 'extensionPages', info: 'themeChanged' });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DownloadTheme;
|
export default DownloadTheme;
|
||||||
|
|||||||
Reference in New Issue
Block a user