feat(styles): remember style selection per sfw or nsfw category, instead of single board

This commit is contained in:
Tom (plebeius.eth)
2024-06-30 21:50:50 +02:00
parent ed393d0c72
commit 06e18289a4
4 changed files with 73 additions and 54 deletions
+6 -9
View File
@@ -15,21 +15,18 @@ const useInitialTheme = () => {
const isInAllView = isAllView(location.pathname, params);
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
if (isInAllView || isInSubscriptionsView) {
const userTheme = getTheme(isInAllView ? 'all' : 'subscriptions');
return userTheme || 'yotsuba-b';
if (isInAllView) {
return getTheme('all') || 'yotsuba-b';
} else if (isInSubscriptionsView) {
return getTheme('subscriptions') || 'yotsuba-b';
} else if (isInHomeView || isInNotFoundView) {
return 'yotsuba';
} else if (subplebbitAddress) {
const userTheme = getTheme(subplebbitAddress);
if (userTheme) {
return userTheme;
}
const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress);
if (subplebbit && subplebbit.tags && subplebbit.tags.some((tag) => nsfwTags.includes(tag))) {
return 'yotsuba';
return getTheme('nsfw') || 'yotsuba';
}
return 'yotsuba-b';
return getTheme('sfw') || 'yotsuba-b';
}
return 'yotsuba';
};