can hide nsfw in MangaSources

This commit is contained in:
Aria Moradi
2021-09-03 04:47:02 +04:30
parent f98ad6e9c9
commit ba26d852dc
2 changed files with 10 additions and 6 deletions

View File

@@ -38,6 +38,7 @@ export default function MangaSources() {
const { setTitle, setAction } = useContext(NavbarContext); const { setTitle, setAction } = useContext(NavbarContext);
const [shownLangs, setShownLangs] = useLocalStorage<string[]>('shownSourceLangs', defualtLangs()); const [shownLangs, setShownLangs] = useLocalStorage<string[]>('shownSourceLangs', defualtLangs());
const [showNsfw] = useLocalStorage<boolean>('showNsfw', false);
const [sources, setSources] = useState<ISource[]>([]); const [sources, setSources] = useState<ISource[]>([]);
const [fetched, setFetched] = useState<boolean>(false); const [fetched, setFetched] = useState<boolean>(false);
@@ -70,12 +71,14 @@ export default function MangaSources() {
shownLangs.indexOf(lang) !== -1 && ( shownLangs.indexOf(lang) !== -1 && (
<React.Fragment key={lang}> <React.Fragment key={lang}>
<h1 key={lang} style={{ marginLeft: 25 }}>{langCodeToName(lang)}</h1> <h1 key={lang} style={{ marginLeft: 25 }}>{langCodeToName(lang)}</h1>
{(list as ISource[]).map((source) => ( {(list as ISource[])
<SourceCard .filter((source) => showNsfw || !source.isNsfw)
key={source.id} .map((source) => (
source={source} <SourceCard
/> key={source.id}
))} source={source}
/>
))}
</React.Fragment> </React.Fragment>
) )
))} ))}

1
src/typings.d.ts vendored
View File

@@ -27,6 +27,7 @@ interface ISource {
supportsLatest: boolean supportsLatest: boolean
history: any history: any
isConfigurable: boolean isConfigurable: boolean
isNsfw: boolean
} }
interface IMangaCard { interface IMangaCard {