mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(subplebbit): add automatic theme based on nsfw or sfw tags
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { timeFilterNames } from '../../hooks/use-time-filter';
|
||||
|
||||
export type ParamsType = {
|
||||
accountCommentIndex?: string;
|
||||
commentCid?: string;
|
||||
@@ -5,8 +7,25 @@ export type ParamsType = {
|
||||
timeFilterName?: string;
|
||||
};
|
||||
|
||||
export const isAllView = (pathname: string): boolean => {
|
||||
return pathname.startsWith('/p/all');
|
||||
export const isAllView = (pathname: string, params: ParamsType): boolean => {
|
||||
const { timeFilterName } = params;
|
||||
|
||||
if (timeFilterName && !timeFilterNames.includes(timeFilterName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
pathname === '/p/all' ||
|
||||
pathname === '/p/all/settings' ||
|
||||
pathname === `/p/all/${timeFilterName}` ||
|
||||
pathname === `/p/all/${timeFilterName}/settings` ||
|
||||
pathname === '/p/all/catalog' ||
|
||||
pathname === '/p/all/catalog/settings' ||
|
||||
pathname === `/p/all/catalog/${timeFilterName}` ||
|
||||
pathname === `/p/all/catalog/${timeFilterName}/settings` ||
|
||||
pathname === '/p/all/description' ||
|
||||
pathname === '/p/all/description/settings'
|
||||
);
|
||||
};
|
||||
|
||||
export const isBoardView = (pathname: string, params: ParamsType): boolean => {
|
||||
@@ -68,19 +87,31 @@ export const isSettingsView = (pathname: string, params: ParamsType): boolean =>
|
||||
);
|
||||
};
|
||||
|
||||
export const isSubscriptionsView = (pathname: string): boolean => {
|
||||
return pathname.startsWith('/p/subscriptions');
|
||||
export const isSubscriptionsView = (pathname: string, params: ParamsType): boolean => {
|
||||
const { timeFilterName } = params;
|
||||
return (
|
||||
pathname === '/p/subscriptions' ||
|
||||
pathname === '/p/subscriptions/settings' ||
|
||||
pathname === `/p/subscriptions/${timeFilterName}` ||
|
||||
pathname === `/p/subscriptions/${timeFilterName}/settings` ||
|
||||
pathname === '/p/subscriptions/catalog' ||
|
||||
pathname === '/p/subscriptions/catalog/settings' ||
|
||||
pathname === `/p/subscriptions/catalog/${timeFilterName}` ||
|
||||
pathname === `/p/subscriptions/catalog/${timeFilterName}/settings`
|
||||
);
|
||||
};
|
||||
|
||||
export const isNotFoundView = (pathname: string, params: ParamsType): boolean => {
|
||||
return (
|
||||
!isAllView(pathname) &&
|
||||
!isAllView(pathname, params) &&
|
||||
!isBoardView(pathname, params) &&
|
||||
!isCatalogView(pathname, params) &&
|
||||
!isDescriptionView(pathname, params) &&
|
||||
!isHomeView(pathname) &&
|
||||
!isPendingPostView(pathname, params) &&
|
||||
!isPostPageView(pathname, params) &&
|
||||
!isRulesView(pathname, params)
|
||||
!isRulesView(pathname, params) &&
|
||||
!isSettingsView(pathname, params) &&
|
||||
!isSubscriptionsView(pathname, params)
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user