Fix navbar back button behavior (#195)
* Enable passing backLink through location state. Explicitly handle cases for BACK * Allow pages to override default backLink. Fix manga page back link * Cleanup
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
CircularProgress, IconButton, Stack, Tooltip,
|
||||
} from '@mui/material';
|
||||
import { Box } from '@mui/system';
|
||||
import NavbarContext from 'components/context/NavbarContext';
|
||||
import NavbarContext, { useSetDefaultBackTo } from 'components/context/NavbarContext';
|
||||
import ChapterList from 'components/manga/ChapterList';
|
||||
import { useRefreshManga } from 'components/manga/hooks';
|
||||
import MangaDetails from 'components/manga/MangaDetails';
|
||||
@@ -37,6 +37,8 @@ const Manga: React.FC = () => {
|
||||
|
||||
const [refresh, { loading: refreshing }] = useRefreshManga(id);
|
||||
|
||||
useSetDefaultBackTo(manga?.inLibrary === false && manga.sourceId != null ? `/sources/${manga.sourceId}/popular` : '/library');
|
||||
|
||||
useEffect(() => {
|
||||
// Automatically fetch manga from source if data is older then 24 hours
|
||||
// Automatic fetch is done only once, to prevent issues when server does
|
||||
|
||||
@@ -157,13 +157,13 @@ export default function Reader() {
|
||||
formData.append('read', 'true');
|
||||
client.patch(`/api/v1/manga/${manga.id}/chapter/${chapter.index}`, formData);
|
||||
|
||||
history.replace(`/manga/${manga.id}/chapter/${chapter.index + 1}`);
|
||||
history.replace({ pathname: `/manga/${manga.id}/chapter/${chapter.index + 1}`, state: history.location.state });
|
||||
}
|
||||
};
|
||||
|
||||
const prevChapter = () => {
|
||||
if (chapter.index > 1) {
|
||||
history.replace(`/manga/${manga.id}/chapter/${chapter.index - 1}`);
|
||||
history.replace({ pathname: `/manga/${manga.id}/chapter/${chapter.index - 1}`, state: history.location.state });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ export default function Updates() {
|
||||
transition: 'background-color 100ms cubic-bezier(0.4, 0, 0.2, 1) 0ms',
|
||||
},
|
||||
}}
|
||||
onClick={() => history.push(`/manga/${chapter.mangaId}/chapter/${chapter.index}`)}
|
||||
onClick={() => history.push({ pathname: `/manga/${chapter.mangaId}/chapter/${chapter.index}`, state: history.location.state })}
|
||||
>
|
||||
<CardContent sx={{
|
||||
display: 'flex',
|
||||
|
||||
Reference in New Issue
Block a user