mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix navigating to home or 404 resets style
This commit is contained in:
@@ -231,8 +231,7 @@ const All = () => {
|
|||||||
<Link to={`/p/all/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
<Link to={`/p/all/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
<Link to="/">Home</Link>
|
||||||
)}>Home</Link>
|
|
||||||
]
|
]
|
||||||
</span>
|
</span>
|
||||||
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
||||||
|
|||||||
@@ -132,8 +132,7 @@ const AllCatalog = () => {
|
|||||||
<Link to={`/p/all/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
<Link to={`/p/all/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
<Link to="/">Home</Link>
|
||||||
)}>Home</Link>
|
|
||||||
]
|
]
|
||||||
</span>
|
</span>
|
||||||
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
||||||
|
|||||||
@@ -574,8 +574,7 @@ const Board = () => {
|
|||||||
<Link to={`/p/${selectedAddress}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
<Link to={`/p/${selectedAddress}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
<Link to="/">Home</Link>
|
||||||
)}>Home</Link>
|
|
||||||
]
|
]
|
||||||
</span>
|
</span>
|
||||||
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
||||||
|
|||||||
@@ -497,8 +497,7 @@ const Catalog = () => {
|
|||||||
<Link to={`/p/${selectedAddress}/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
<Link to={`/p/${selectedAddress}/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
<Link to="/">Home</Link>
|
||||||
)}>Home</Link>
|
|
||||||
]
|
]
|
||||||
</span>
|
</span>
|
||||||
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
||||||
|
|||||||
@@ -15,25 +15,36 @@ const commitRef = process?.env?.REACT_APP_COMMIT_REF ? ` ${process.env.REACT_APP
|
|||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
const {
|
const {
|
||||||
setBodyStyle,
|
bodyStyle, setBodyStyle,
|
||||||
defaultSubplebbits,
|
defaultSubplebbits,
|
||||||
setSelectedAddress,
|
setSelectedAddress,
|
||||||
setSelectedStyle,
|
selectedStyle, setSelectedStyle,
|
||||||
setSelectedTitle
|
setSelectedTitle
|
||||||
} = useGeneralStore(state => state);
|
} = useGeneralStore(state => state);
|
||||||
|
|
||||||
const account = useAccount();
|
const account = useAccount();
|
||||||
const inputRef = useRef(null);
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const inputRef = useRef(null);
|
||||||
|
const prevStyle = useRef(selectedStyle);
|
||||||
|
const prevBodyStyle = useRef(bodyStyle);
|
||||||
|
|
||||||
// prevent dark mode
|
// prevent dark mode
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const currentPrevStyle = prevStyle.current;
|
||||||
|
const currentPrevBodyStyle = prevBodyStyle.current;
|
||||||
|
|
||||||
setBodyStyle({
|
setBodyStyle({
|
||||||
background: "#ffe url(assets/fade.png) top repeat-x",
|
background: "#ffe url(assets/fade.png) top repeat-x",
|
||||||
color: "maroon",
|
color: "maroon",
|
||||||
fontFamily: "Helvetica, Arial, sans-serif"
|
fontFamily: "Helvetica, Arial, sans-serif"
|
||||||
});
|
});
|
||||||
setSelectedStyle("Yotsuba");
|
setSelectedStyle("Yotsuba");
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
setSelectedStyle(currentPrevStyle);
|
||||||
|
setBodyStyle(currentPrevBodyStyle);
|
||||||
|
};
|
||||||
}, [setBodyStyle, setSelectedStyle]);
|
}, [setBodyStyle, setSelectedStyle]);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { Helmet } from 'react-helmet-async';
|
import { Helmet } from 'react-helmet-async';
|
||||||
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
import useGeneralStore from '../../hooks/stores/useGeneralStore';
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
@@ -7,16 +7,31 @@ import packageJson from '../../../package.json'
|
|||||||
const {version} = packageJson
|
const {version} = packageJson
|
||||||
|
|
||||||
|
|
||||||
const NotFound = ({ setBodyStyle }) => {
|
const NotFound = () => {
|
||||||
const { setSelectedStyle } = useGeneralStore(state => state);
|
const {
|
||||||
|
bodyStyle, setBodyStyle,
|
||||||
|
selectedStyle, setSelectedStyle,
|
||||||
|
} = useGeneralStore(state => state);
|
||||||
|
|
||||||
|
const prevStyle = useRef(selectedStyle);
|
||||||
|
const prevBodyStyle = useRef(bodyStyle);
|
||||||
|
|
||||||
|
// prevent dark mode
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const currentPrevStyle = prevStyle.current;
|
||||||
|
const currentPrevBodyStyle = prevBodyStyle.current;
|
||||||
|
|
||||||
setBodyStyle({
|
setBodyStyle({
|
||||||
background: "#ffe url(assets/fade.png) top repeat-x",
|
background: "#ffe url(assets/fade.png) top repeat-x",
|
||||||
color: "maroon",
|
color: "maroon",
|
||||||
fontFamily: "Helvetica, Arial, sans-serif"
|
fontFamily: "Helvetica, Arial, sans-serif"
|
||||||
});
|
});
|
||||||
setSelectedStyle("Yotsuba");
|
setSelectedStyle("Yotsuba");
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
setSelectedStyle(currentPrevStyle);
|
||||||
|
setBodyStyle(currentPrevBodyStyle);
|
||||||
|
};
|
||||||
}, [setBodyStyle, setSelectedStyle]);
|
}, [setBodyStyle, setSelectedStyle]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -136,8 +136,7 @@ const Pending = () => {
|
|||||||
<Link to={`/profile/c/${index}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
<Link to={`/profile/c/${index}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
<Link to="/">Home</Link>
|
||||||
)}>Home</Link>
|
|
||||||
]
|
]
|
||||||
</span>
|
</span>
|
||||||
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
||||||
|
|||||||
@@ -230,8 +230,7 @@ const Subscriptions = () => {
|
|||||||
<Link to={`/p/subscriptions/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
<Link to={`/p/subscriptions/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
<Link to="/">Home</Link>
|
||||||
)}>Home</Link>
|
|
||||||
]
|
]
|
||||||
</span>
|
</span>
|
||||||
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
||||||
|
|||||||
@@ -133,8 +133,7 @@ const SubscriptionsCatalog = () => {
|
|||||||
<Link to={`/p/subscriptions/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
<Link to={`/p/subscriptions/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
<Link to="/">Home</Link>
|
||||||
)}>Home</Link>
|
|
||||||
]
|
]
|
||||||
</span>
|
</span>
|
||||||
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
||||||
|
|||||||
@@ -532,8 +532,7 @@ const Thread = () => {
|
|||||||
<Link to={`/p/${selectedAddress}/c/${selectedThread}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
<Link to={`/p/${selectedAddress}/c/${selectedThread}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
|
<Link to="/">Home</Link>
|
||||||
)}>Home</Link>
|
|
||||||
]
|
]
|
||||||
</span>
|
</span>
|
||||||
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user