Reduce toasts when switching themes

This commit is contained in:
schroda
2024-09-07 01:47:06 +02:00
parent 74944407f7
commit 4a742bb0ff
2 changed files with 15 additions and 6 deletions

View File

@@ -196,8 +196,14 @@ const getFontsFromTheme = (obj: Record<string, any>, fonts: string[] = []): stri
};
const loadedFonts: string[] = [];
export const hasMissingFonts = (theme: ThemeOptions): boolean => {
const themeFonts = getFontsFromTheme(theme.typography ?? {});
return !!themeFonts.length && themeFonts.some((font) => !loadedFonts.includes(font));
};
export const loadThemeFonts = async (theme: ThemeOptions): Promise<void> => {
const themeFonts = getFontsFromTheme(theme);
const themeFonts = getFontsFromTheme(theme.typography ?? {});
const missingThemeFonts = themeFonts.filter((font) => !loadedFonts.includes(font));
if (!missingThemeFonts.length) {