Skip to content

Commit

Permalink
Refetch and apply theme without reloading
Browse files Browse the repository at this point in the history
(untested)
  • Loading branch information
pylixonly committed Mar 11, 2024
1 parent dd5cfc7 commit cc65b9e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
25 changes: 12 additions & 13 deletions src/core/ui/components/ThemeCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { formatString, Strings } from "@core/i18n";
import Card, { CardWrapper } from "@core/ui/components/Card";
import { getAssetIDByName } from "@lib/api/assets";
import { BundleUpdaterManager } from "@lib/api/native/modules";
import { useProxy } from "@lib/api/storage";
import { applyTheme, fetchTheme, removeTheme, selectTheme, Theme, themes } from "@lib/managers/themes";
import { settings } from "@lib/settings";
Expand Down Expand Up @@ -50,18 +49,18 @@ export default function ThemeCard({ item: theme, index }: CardWrapper<Theme>) {
label: Strings.REFETCH,
onPress: () => {
fetchTheme(theme.id, theme.selected).then(() => {
if (theme.selected) {
showConfirmationAlert({
title: Strings.MODAL_THEME_REFETCHED,
content: Strings.MODAL_THEME_REFETCHED_DESC,
confirmText: Strings.RELOAD,
cancelText: Strings.CANCEL,
confirmColor: ButtonColors.RED,
onConfirm: () => BundleUpdaterManager.reload(),
});
} else {
showToast(Strings.THEME_REFETCH_SUCCESSFUL, getAssetIDByName("toast_image_saved"));
}
// if (theme.selected) {
// showConfirmationAlert({
// title: Strings.MODAL_THEME_REFETCHED,
// content: Strings.MODAL_THEME_REFETCHED_DESC,
// confirmText: Strings.RELOAD,
// cancelText: Strings.CANCEL,
// confirmColor: ButtonColors.RED,
// onConfirm: () => BundleUpdaterManager.reload(),
// });
// } else {
showToast(Strings.THEME_REFETCH_SUCCESSFUL, getAssetIDByName("toast_image_saved"));
// }
}).catch(() => {
showToast(Strings.THEME_REFETCH_FAILED, getAssetIDByName("Small"));
});
Expand Down
5 changes: 4 additions & 1 deletion src/lib/managers/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ export async function fetchTheme(id: string, selected = false) {
};

// TODO: Should we prompt when the selected theme is updated?
if (selected) writeTheme(themes[id]);
if (selected) {
writeTheme(themes[id]);
applyTheme(themes[id], vdThemeFallback, true);
}
}

export async function installTheme(id: string) {
Expand Down

0 comments on commit cc65b9e

Please sign in to comment.