fix(theme): changing theme in sfw sub wouldn't change it for p/all and p/subscriptions. it should because sfw is the default

This commit is contained in:
Tom (plebeius.eth)
2024-08-05 11:58:33 +02:00
parent a992912e10
commit f06c50ef33
3 changed files with 6 additions and 18 deletions
+2 -4
View File
@@ -19,10 +19,8 @@ const useInitialTheme = () => {
if (isInPendingPostView) {
return currentTheme || 'yotsuba';
} else if (isInAllView) {
return getTheme('all') || 'yotsuba-b';
} else if (isInSubscriptionsView) {
return getTheme('subscriptions') || 'yotsuba-b';
} else if (isInAllView || isInSubscriptionsView) {
return getTheme('sfw') || 'yotsuba-b';
} else if (isInHomeView || isInNotFoundView) {
return 'yotsuba';
} else if (subplebbitAddress) {
+4 -8
View File
@@ -44,10 +44,8 @@ const useTheme = (): [string, (theme: string) => void] => {
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
let storedTheme = null;
if (isInAllView) {
storedTheme = getTheme('all');
} else if (isInSubscriptionsView) {
storedTheme = getTheme('subscriptions');
if (isInAllView || isInSubscriptionsView) {
storedTheme = getTheme('sfw');
} else if (subplebbitAddress) {
const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress);
if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) {
@@ -67,10 +65,8 @@ const useTheme = (): [string, (theme: string) => void] => {
const isInAllView = isAllView(location.pathname, params);
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
if (isInAllView) {
await setThemeStore('all', newTheme);
} else if (isInSubscriptionsView) {
await setThemeStore('subscriptions', newTheme);
if (isInAllView || isInSubscriptionsView) {
await setThemeStore('sfw', newTheme);
} else if (subplebbitAddress) {
const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress);
if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) {
-6
View File
@@ -5,8 +5,6 @@ interface ThemeState {
themes: {
nsfw: string;
sfw: string;
all: string;
subscriptions: string;
};
currentTheme: string | null;
setTheme: (category: keyof ThemeState['themes'], theme: string) => void;
@@ -23,8 +21,6 @@ const useThemeStore = create<ThemeState>((set: StoreApi<ThemeState>['setState'],
themes: {
nsfw: 'yotsuba',
sfw: 'yotsuba-b',
all: 'yotsuba-b',
subscriptions: 'yotsuba-b',
},
currentTheme: null,
setTheme: async (category, theme) => {
@@ -44,8 +40,6 @@ const useThemeStore = create<ThemeState>((set: StoreApi<ThemeState>['setState'],
const themes: Record<keyof ThemeState['themes'], string> = {
nsfw: 'yotsuba',
sfw: 'yotsuba-b',
all: 'yotsuba-b',
subscriptions: 'yotsuba-b',
};
entries.forEach(([key, value]) => {
themes[key] = value;