fix navigating to home or 404 resets style

This commit is contained in:
Tom
2023-05-27 12:55:16 +02:00
parent 51b3466b49
commit d04dd32d5a
10 changed files with 40 additions and 22 deletions
+1 -2
View File
@@ -231,8 +231,7 @@ const All = () => {
<Link to={`/p/all/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
]
[
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
)}>Home</Link>
<Link to="/">Home</Link>
]
</span>
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
+1 -2
View File
@@ -132,8 +132,7 @@ const AllCatalog = () => {
<Link to={`/p/all/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
]
[
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
)}>Home</Link>
<Link to="/">Home</Link>
]
</span>
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
+1 -2
View File
@@ -574,8 +574,7 @@ const Board = () => {
<Link to={`/p/${selectedAddress}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
]
[
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
)}>Home</Link>
<Link to="/">Home</Link>
]
</span>
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
+1 -2
View File
@@ -497,8 +497,7 @@ const Catalog = () => {
<Link to={`/p/${selectedAddress}/catalog/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
]
[
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
)}>Home</Link>
<Link to="/">Home</Link>
]
</span>
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
+14 -3
View File
@@ -15,25 +15,36 @@ const commitRef = process?.env?.REACT_APP_COMMIT_REF ? ` ${process.env.REACT_APP
const Home = () => {
const {
setBodyStyle,
bodyStyle, setBodyStyle,
defaultSubplebbits,
setSelectedAddress,
setSelectedStyle,
selectedStyle, setSelectedStyle,
setSelectedTitle
} = useGeneralStore(state => state);
const account = useAccount();
const inputRef = useRef(null);
const navigate = useNavigate();
const inputRef = useRef(null);
const prevStyle = useRef(selectedStyle);
const prevBodyStyle = useRef(bodyStyle);
// prevent dark mode
useEffect(() => {
const currentPrevStyle = prevStyle.current;
const currentPrevBodyStyle = prevBodyStyle.current;
setBodyStyle({
background: "#ffe url(assets/fade.png) top repeat-x",
color: "maroon",
fontFamily: "Helvetica, Arial, sans-serif"
});
setSelectedStyle("Yotsuba");
return () => {
setSelectedStyle(currentPrevStyle);
setBodyStyle(currentPrevBodyStyle);
};
}, [setBodyStyle, setSelectedStyle]);
+18 -3
View File
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useRef } from 'react';
import { Helmet } from 'react-helmet-async';
import useGeneralStore from '../../hooks/stores/useGeneralStore';
import { Link } from "react-router-dom";
@@ -7,16 +7,31 @@ import packageJson from '../../../package.json'
const {version} = packageJson
const NotFound = ({ setBodyStyle }) => {
const { setSelectedStyle } = useGeneralStore(state => state);
const NotFound = () => {
const {
bodyStyle, setBodyStyle,
selectedStyle, setSelectedStyle,
} = useGeneralStore(state => state);
const prevStyle = useRef(selectedStyle);
const prevBodyStyle = useRef(bodyStyle);
// prevent dark mode
useEffect(() => {
const currentPrevStyle = prevStyle.current;
const currentPrevBodyStyle = prevBodyStyle.current;
setBodyStyle({
background: "#ffe url(assets/fade.png) top repeat-x",
color: "maroon",
fontFamily: "Helvetica, Arial, sans-serif"
});
setSelectedStyle("Yotsuba");
return () => {
setSelectedStyle(currentPrevStyle);
setBodyStyle(currentPrevBodyStyle);
};
}, [setBodyStyle, setSelectedStyle]);
return (
+1 -2
View File
@@ -136,8 +136,7 @@ const Pending = () => {
<Link to={`/profile/c/${index}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
]
[
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
)}>Home</Link>
<Link to="/">Home</Link>
]
</span>
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
+1 -2
View File
@@ -230,8 +230,7 @@ const Subscriptions = () => {
<Link to={`/p/subscriptions/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
]
[
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
)}>Home</Link>
<Link to="/">Home</Link>
]
</span>
<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="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
)}>Home</Link>
<Link to="/">Home</Link>
]
</span>
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>
+1 -2
View File
@@ -532,8 +532,7 @@ const Thread = () => {
<Link to={`/p/${selectedAddress}/c/${selectedThread}/settings`} onClick={() => setIsSettingsOpen(true)}>Settings</Link>
]
[
<Link to="/" onClick={() => handleStyleChange({target: {value: "Yotsuba"}}
)}>Home</Link>
<Link to="/">Home</Link>
]
</span>
<div id="board-nav-mobile" style={{ top: visible ? 0 : '-23px' }}>