mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
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:
@@ -19,10 +19,8 @@ const useInitialTheme = () => {
|
|||||||
|
|
||||||
if (isInPendingPostView) {
|
if (isInPendingPostView) {
|
||||||
return currentTheme || 'yotsuba';
|
return currentTheme || 'yotsuba';
|
||||||
} else if (isInAllView) {
|
} else if (isInAllView || isInSubscriptionsView) {
|
||||||
return getTheme('all') || 'yotsuba-b';
|
return getTheme('sfw') || 'yotsuba-b';
|
||||||
} else if (isInSubscriptionsView) {
|
|
||||||
return getTheme('subscriptions') || 'yotsuba-b';
|
|
||||||
} else if (isInHomeView || isInNotFoundView) {
|
} else if (isInHomeView || isInNotFoundView) {
|
||||||
return 'yotsuba';
|
return 'yotsuba';
|
||||||
} else if (subplebbitAddress) {
|
} else if (subplebbitAddress) {
|
||||||
|
|||||||
@@ -44,10 +44,8 @@ const useTheme = (): [string, (theme: string) => void] => {
|
|||||||
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
|
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
|
||||||
|
|
||||||
let storedTheme = null;
|
let storedTheme = null;
|
||||||
if (isInAllView) {
|
if (isInAllView || isInSubscriptionsView) {
|
||||||
storedTheme = getTheme('all');
|
storedTheme = getTheme('sfw');
|
||||||
} else if (isInSubscriptionsView) {
|
|
||||||
storedTheme = getTheme('subscriptions');
|
|
||||||
} else if (subplebbitAddress) {
|
} else if (subplebbitAddress) {
|
||||||
const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress);
|
const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress);
|
||||||
if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) {
|
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 isInAllView = isAllView(location.pathname, params);
|
||||||
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
|
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
|
||||||
|
|
||||||
if (isInAllView) {
|
if (isInAllView || isInSubscriptionsView) {
|
||||||
await setThemeStore('all', newTheme);
|
await setThemeStore('sfw', newTheme);
|
||||||
} else if (isInSubscriptionsView) {
|
|
||||||
await setThemeStore('subscriptions', newTheme);
|
|
||||||
} else if (subplebbitAddress) {
|
} else if (subplebbitAddress) {
|
||||||
const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress);
|
const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress);
|
||||||
if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) {
|
if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) {
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ interface ThemeState {
|
|||||||
themes: {
|
themes: {
|
||||||
nsfw: string;
|
nsfw: string;
|
||||||
sfw: string;
|
sfw: string;
|
||||||
all: string;
|
|
||||||
subscriptions: string;
|
|
||||||
};
|
};
|
||||||
currentTheme: string | null;
|
currentTheme: string | null;
|
||||||
setTheme: (category: keyof ThemeState['themes'], theme: string) => void;
|
setTheme: (category: keyof ThemeState['themes'], theme: string) => void;
|
||||||
@@ -23,8 +21,6 @@ const useThemeStore = create<ThemeState>((set: StoreApi<ThemeState>['setState'],
|
|||||||
themes: {
|
themes: {
|
||||||
nsfw: 'yotsuba',
|
nsfw: 'yotsuba',
|
||||||
sfw: 'yotsuba-b',
|
sfw: 'yotsuba-b',
|
||||||
all: 'yotsuba-b',
|
|
||||||
subscriptions: 'yotsuba-b',
|
|
||||||
},
|
},
|
||||||
currentTheme: null,
|
currentTheme: null,
|
||||||
setTheme: async (category, theme) => {
|
setTheme: async (category, theme) => {
|
||||||
@@ -44,8 +40,6 @@ const useThemeStore = create<ThemeState>((set: StoreApi<ThemeState>['setState'],
|
|||||||
const themes: Record<keyof ThemeState['themes'], string> = {
|
const themes: Record<keyof ThemeState['themes'], string> = {
|
||||||
nsfw: 'yotsuba',
|
nsfw: 'yotsuba',
|
||||||
sfw: 'yotsuba-b',
|
sfw: 'yotsuba-b',
|
||||||
all: 'yotsuba-b',
|
|
||||||
subscriptions: 'yotsuba-b',
|
|
||||||
};
|
};
|
||||||
entries.forEach(([key, value]) => {
|
entries.forEach(([key, value]) => {
|
||||||
themes[key] = value;
|
themes[key] = value;
|
||||||
|
|||||||
Reference in New Issue
Block a user