mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(not found): force yotsuba theme with ref, not with params in app because they can't be detected in app
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
.content {
|
||||
margin: auto;
|
||||
text-align: left;
|
||||
width: 57.69em;
|
||||
min-width: 750px;
|
||||
text-align: left;
|
||||
width: 57.69em;
|
||||
min-width: 750px;
|
||||
}
|
||||
|
||||
.boxOuter {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState, useRef } 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;
|
||||
|
||||
@@ -19,24 +20,42 @@ const NotFoundImage = () => {
|
||||
const NotFound = () => {
|
||||
const { subplebbitAddress } = useParams();
|
||||
|
||||
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.content}>
|
||||
<HomeLogo />
|
||||
<div className={styles.boxOuter}>
|
||||
<div className={styles.boxInner}>
|
||||
<div className={styles.boxBar}>
|
||||
<h2>404 Not Found</h2>
|
||||
</div>
|
||||
<div className={styles.boxContent}>
|
||||
<NotFoundImage />
|
||||
{subplebbitAddress && (
|
||||
<>
|
||||
<br />
|
||||
<div className={styles.backToBoard}>
|
||||
[<Link to={`/p/${subplebbitAddress}`}>Back to p/{Plebbit.getShortAddress(subplebbitAddress)}</Link>]
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.content}>
|
||||
<HomeLogo />
|
||||
<div className={styles.boxOuter}>
|
||||
<div className={styles.boxInner}>
|
||||
<div className={styles.boxBar}>
|
||||
<h2>404 Not Found</h2>
|
||||
</div>
|
||||
<div className={styles.boxContent}>
|
||||
<NotFoundImage />
|
||||
{subplebbitAddress && (
|
||||
<>
|
||||
<br />
|
||||
<div className={styles.backToBoard}>
|
||||
[<Link to={`/p/${subplebbitAddress}`}>Back to p/{Plebbit.getShortAddress(subplebbitAddress)}</Link>]
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user