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:
@@ -25,12 +25,12 @@ const Board = () => {
|
||||
const location = useLocation();
|
||||
const { subplebbitAddress } = useParams<{ subplebbitAddress: string }>();
|
||||
|
||||
const isInAllView = isAllView(location.pathname);
|
||||
const isInAllView = isAllView(location.pathname, useParams());
|
||||
const defaultSubplebbitAddresses = useDefaultSubplebbitAddresses();
|
||||
|
||||
const account = useAccount();
|
||||
const subscriptions = account?.subscriptions;
|
||||
const isInSubscriptionsView = isSubscriptionsView(location.pathname);
|
||||
const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
|
||||
|
||||
const subplebbitAddresses = useMemo(() => {
|
||||
if (isInAllView) {
|
||||
|
||||
@@ -9,8 +9,9 @@ const FiltersModal = ({ closeModal }: { closeModal: () => void }) => {
|
||||
const { t } = useTranslation();
|
||||
const { showAdultBoards, setShowAdultBoards, showGoreBoards, setShowGoreBoards, showTextOnlyThreads, setShowTextOnlyThreads } = useCatalogFiltersStore();
|
||||
const location = useLocation();
|
||||
const isInCatalogView = isCatalogView(location.pathname, useParams());
|
||||
const isInAllView = isAllView(location.pathname);
|
||||
const params = useParams();
|
||||
const isInCatalogView = isCatalogView(location.pathname, params);
|
||||
const isInAllView = isAllView(location.pathname, params);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -27,7 +27,7 @@ const useFeedRows = (columnCount: number, feed: any, isFeedLoaded: boolean, subp
|
||||
const { avatarUrl } = suggested || {};
|
||||
|
||||
const location = useLocation();
|
||||
const isInAllView = isAllView(location.pathname);
|
||||
const isInAllView = isAllView(location.pathname, useParams());
|
||||
const multisub = useMultisubMetadata();
|
||||
|
||||
const feedWithDescriptionAndRules = useMemo(() => {
|
||||
@@ -90,13 +90,13 @@ const Catalog = () => {
|
||||
const location = useLocation();
|
||||
const { subplebbitAddress } = useParams<{ subplebbitAddress: string }>();
|
||||
|
||||
const isInAllView = isAllView(location.pathname);
|
||||
const isInAllView = isAllView(location.pathname, useParams());
|
||||
const defaultSubplebbits = useDefaultSubplebbits();
|
||||
const { showAdultBoards, showGoreBoards } = useCatalogFiltersStore();
|
||||
|
||||
const account = useAccount();
|
||||
const subscriptions = account?.subscriptions;
|
||||
const isInSubscriptionsView = isSubscriptionsView(location.pathname);
|
||||
const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
|
||||
|
||||
const subplebbitAddresses = useMemo(() => {
|
||||
const filteredDefaultSubplebbits = defaultSubplebbits
|
||||
@@ -121,10 +121,6 @@ const Catalog = () => {
|
||||
return [subplebbitAddress];
|
||||
}, [isInAllView, isInSubscriptionsView, subplebbitAddress, defaultSubplebbits, subscriptions, showAdultBoards, showGoreBoards]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(showAdultBoards, showGoreBoards);
|
||||
}, [showAdultBoards, showGoreBoards]);
|
||||
|
||||
const columnCount = Math.floor(useWindowWidth() / columnWidth);
|
||||
// postPerPage based on columnCount for optimized feed, dont change value after first render
|
||||
// eslint-disable-next-line
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { useEffect, useState, useRef } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { Link, useParams } from 'react-router-dom';
|
||||
import { HomeLogo } from '../home';
|
||||
import styles from './not-found.module.css';
|
||||
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
|
||||
import useTheme from '../../hooks/use-theme';
|
||||
|
||||
const totalNotFoundImages = 2;
|
||||
|
||||
@@ -20,22 +19,6 @@ const NotFound = () => {
|
||||
const { subplebbitAddress } = useParams();
|
||||
const isValidSubplebbitAddress = !subplebbitAddress || subplebbitAddress.includes('.') || /^12D3K[a-zA-Z0-9]{44}$/.test(subplebbitAddress);
|
||||
|
||||
const [theme, setTheme] = useTheme();
|
||||
const previousThemeRef = useRef(theme);
|
||||
|
||||
useEffect(() => {
|
||||
if (theme !== 'yotsuba') {
|
||||
previousThemeRef.current = theme;
|
||||
setTheme('yotsuba');
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (theme === 'yotsuba') {
|
||||
setTheme(previousThemeRef.current);
|
||||
}
|
||||
};
|
||||
}, [theme, setTheme]);
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.content}>
|
||||
|
||||
Reference in New Issue
Block a user