mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor: remove hide gore boards and hide adult boards functionality
This commit is contained in:
@@ -127,7 +127,7 @@ const InterfaceLanguage = () => {
|
|||||||
const InterfaceSettings = () => {
|
const InterfaceSettings = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { hideAvatars, setHideAvatars } = useAvatarVisibilityStore();
|
const { hideAvatars, setHideAvatars } = useAvatarVisibilityStore();
|
||||||
const { hideGoreBoards, setHideGoreBoards, hideAdultBoards, setHideAdultBoards, hideThreadsWithoutImages, setHideThreadsWithoutImages } = useInterfaceSettingsStore();
|
const { hideThreadsWithoutImages, setHideThreadsWithoutImages } = useInterfaceSettingsStore();
|
||||||
const { setShowTextOnlyThreads } = useCatalogFiltersStore();
|
const { setShowTextOnlyThreads } = useCatalogFiltersStore();
|
||||||
const { fitExpandedImagesToScreen, setFitExpandedImagesToScreen } = useExpandedMediaStore();
|
const { fitExpandedImagesToScreen, setFitExpandedImagesToScreen } = useExpandedMediaStore();
|
||||||
|
|
||||||
@@ -163,18 +163,6 @@ const InterfaceSettings = () => {
|
|||||||
</label>
|
</label>
|
||||||
<div className={styles.settingTip}>{_.capitalize(t('threads_without_images_tip'))}</div>
|
<div className={styles.settingTip}>{_.capitalize(t('threads_without_images_tip'))}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.setting}>
|
|
||||||
<label>
|
|
||||||
<input type='checkbox' checked={hideGoreBoards} onChange={(e) => setHideGoreBoards(e.target.checked)} /> {_.capitalize(t('hide_gore_boards'))}
|
|
||||||
</label>
|
|
||||||
<div className={styles.settingTip}>{_.capitalize(t('hide_gore_boards_tip'))}</div>
|
|
||||||
</div>
|
|
||||||
<div className={styles.setting}>
|
|
||||||
<label>
|
|
||||||
<input type='checkbox' checked={hideAdultBoards} onChange={(e) => setHideAdultBoards(e.target.checked)} /> {_.capitalize(t('hide_adult_boards'))}
|
|
||||||
</label>
|
|
||||||
<div className={styles.settingTip}>{_.capitalize(t('hide_adult_boards_tip'))}</div>
|
|
||||||
</div>
|
|
||||||
<div className={styles.setting}>
|
<div className={styles.setting}>
|
||||||
<label>
|
<label>
|
||||||
<input type='checkbox' checked={fitExpandedImagesToScreen} onChange={(e) => setFitExpandedImagesToScreen(e.target.checked)} />
|
<input type='checkbox' checked={fitExpandedImagesToScreen} onChange={(e) => setFitExpandedImagesToScreen(e.target.checked)} />
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ import { create } from 'zustand';
|
|||||||
import { persist } from 'zustand/middleware';
|
import { persist } from 'zustand/middleware';
|
||||||
|
|
||||||
interface InterfaceSettingsStore {
|
interface InterfaceSettingsStore {
|
||||||
hideGoreBoards: boolean;
|
|
||||||
setHideGoreBoards: (value: boolean) => void;
|
|
||||||
hideAdultBoards: boolean;
|
|
||||||
setHideAdultBoards: (value: boolean) => void;
|
|
||||||
hideThreadsWithoutImages: boolean;
|
hideThreadsWithoutImages: boolean;
|
||||||
setHideThreadsWithoutImages: (value: boolean) => void;
|
setHideThreadsWithoutImages: (value: boolean) => void;
|
||||||
}
|
}
|
||||||
@@ -13,10 +9,6 @@ interface InterfaceSettingsStore {
|
|||||||
const useInterfaceSettingsStore = create(
|
const useInterfaceSettingsStore = create(
|
||||||
persist<InterfaceSettingsStore>(
|
persist<InterfaceSettingsStore>(
|
||||||
(set) => ({
|
(set) => ({
|
||||||
hideGoreBoards: true,
|
|
||||||
setHideGoreBoards: (value: boolean) => set({ hideGoreBoards: value }),
|
|
||||||
hideAdultBoards: true,
|
|
||||||
setHideAdultBoards: (value: boolean) => set({ hideAdultBoards: value }),
|
|
||||||
hideThreadsWithoutImages: true,
|
hideThreadsWithoutImages: true,
|
||||||
setHideThreadsWithoutImages: (value: boolean) => set({ hideThreadsWithoutImages: value }),
|
setHideThreadsWithoutImages: (value: boolean) => set({ hideThreadsWithoutImages: value }),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import useTimeFilter, { timeFilterNameToSeconds } from '../../hooks/use-time-fil
|
|||||||
import useWindowWidth from '../../hooks/use-window-width';
|
import useWindowWidth from '../../hooks/use-window-width';
|
||||||
import useCatalogStyleStore from '../../stores/use-catalog-style-store';
|
import useCatalogStyleStore from '../../stores/use-catalog-style-store';
|
||||||
import useFeedResetStore from '../../stores/use-feed-reset-store';
|
import useFeedResetStore from '../../stores/use-feed-reset-store';
|
||||||
import useInterfaceSettingsStore from '../../stores/use-interface-settings-store';
|
|
||||||
import useSortingStore from '../../stores/use-sorting-store';
|
import useSortingStore from '../../stores/use-sorting-store';
|
||||||
import useCatalogFiltersStore from '../../stores/use-catalog-filters-store';
|
import useCatalogFiltersStore from '../../stores/use-catalog-filters-store';
|
||||||
import { getSubplebbitAddress } from '../../lib/utils/route-utils';
|
import { getSubplebbitAddress } from '../../lib/utils/route-utils';
|
||||||
@@ -149,23 +148,13 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
|
|||||||
}, [boardIdentifierProp, defaultSubplebbits, resolvedAddressFromUrl]);
|
}, [boardIdentifierProp, defaultSubplebbits, resolvedAddressFromUrl]);
|
||||||
|
|
||||||
const boardPath = useBoardPath(subplebbitAddress);
|
const boardPath = useBoardPath(subplebbitAddress);
|
||||||
const { hideAdultBoards } = useInterfaceSettingsStore();
|
|
||||||
const { showTextOnlyThreads, filterItems, searchText, clearMatchedFilters } = useCatalogFiltersStore();
|
const { showTextOnlyThreads, filterItems, searchText, clearMatchedFilters } = useCatalogFiltersStore();
|
||||||
|
|
||||||
const account = useAccount();
|
const account = useAccount();
|
||||||
const subscriptions = account?.subscriptions;
|
const subscriptions = account?.subscriptions;
|
||||||
|
|
||||||
const subplebbitAddresses = useMemo(() => {
|
const subplebbitAddresses = useMemo(() => {
|
||||||
const filteredDefaultSubplebbits = defaultSubplebbits
|
const filteredDefaultSubplebbits = defaultSubplebbits.map((subplebbit) => subplebbit.address).filter(Boolean); // Filter out any undefined/null values
|
||||||
.filter((subplebbit) => {
|
|
||||||
// Hide NSFW boards if hideAdultBoards is enabled (treating NSFW as adult content)
|
|
||||||
if (subplebbit.nsfw && hideAdultBoards) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
})
|
|
||||||
.map((subplebbit) => subplebbit.address)
|
|
||||||
.filter(Boolean); // Filter out any undefined/null values
|
|
||||||
|
|
||||||
if (isInAllView) {
|
if (isInAllView) {
|
||||||
return filteredDefaultSubplebbits;
|
return filteredDefaultSubplebbits;
|
||||||
@@ -175,7 +164,7 @@ const Catalog = ({ feedCacheKey, viewType, boardIdentifier: boardIdentifierProp,
|
|||||||
}
|
}
|
||||||
// Only include subplebbitAddress if it's defined
|
// Only include subplebbitAddress if it's defined
|
||||||
return subplebbitAddress ? [subplebbitAddress] : [];
|
return subplebbitAddress ? [subplebbitAddress] : [];
|
||||||
}, [isInAllView, isInSubscriptionsView, subplebbitAddress, defaultSubplebbits, subscriptions, hideAdultBoards]);
|
}, [isInAllView, isInSubscriptionsView, subplebbitAddress, defaultSubplebbits, subscriptions]);
|
||||||
|
|
||||||
const { imageSize } = useCatalogStyleStore();
|
const { imageSize } = useCatalogStyleStore();
|
||||||
const columnWidth = imageSize === 'Large' ? 270 : 180;
|
const columnWidth = imageSize === 'Large' ? 270 : 180;
|
||||||
|
|||||||
Reference in New Issue
Block a user