Update ErrorNotice and add route level errorBoundary
This commit is contained in:
7 files changed
+242
-145
No files matched your search
+155
-138
@@ -101,6 +101,8 @@ import { CircularProgress } from "@mui/material";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
import { useCentralStore } from "./utils/store/central.js";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { ErrorNotice } from "./components/notices/errorNotice/errorNotice.jsx";
|
||||
|
||||
const anim = {
|
||||
initial: {
|
||||
@@ -457,148 +459,163 @@ function App() {
|
||||
<SideMenu />
|
||||
<AppBar />
|
||||
<AudioPlayer key={audioPlayerVisible} />
|
||||
<Routes location={location}>
|
||||
{/* <Route
|
||||
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
||||
<Routes location={location}>
|
||||
{/* <Route
|
||||
// key={location.key}
|
||||
element={<AnimationWrapper />}
|
||||
> */}
|
||||
<Route
|
||||
path="/"
|
||||
exact
|
||||
element={<Navigate to={initialRoute} />}
|
||||
// element={<></>}
|
||||
/>
|
||||
<Route
|
||||
path="/error"
|
||||
element={
|
||||
<Dialog
|
||||
open
|
||||
onClose={handleRelaunch}
|
||||
aria-labelledby="alert-dialog-text"
|
||||
aria-describedby="alert-dialog-desc"
|
||||
maxWidth="md"
|
||||
>
|
||||
<DialogTitle id="alert-dialog-text">
|
||||
Unable to reach server
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText id="alert-dialog-desc">
|
||||
Unable to connect to
|
||||
the jellyfin server.
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() =>
|
||||
navigate(
|
||||
"/servers/list",
|
||||
)
|
||||
}
|
||||
>
|
||||
Change Server
|
||||
</Button>
|
||||
<Button
|
||||
variant="outlined"
|
||||
onClick={
|
||||
handleRelaunch
|
||||
}
|
||||
>
|
||||
Restart JellyPlayer
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/login/index"
|
||||
exact
|
||||
element={<LoginRoute />}
|
||||
/>
|
||||
<Route
|
||||
path="/"
|
||||
exact
|
||||
element={
|
||||
<Navigate to={initialRoute} />
|
||||
}
|
||||
// element={<></>}
|
||||
/>
|
||||
<Route
|
||||
path="/error"
|
||||
element={
|
||||
<Dialog
|
||||
open
|
||||
onClose={handleRelaunch}
|
||||
aria-labelledby="alert-dialog-text"
|
||||
aria-describedby="alert-dialog-desc"
|
||||
maxWidth="md"
|
||||
>
|
||||
<DialogTitle id="alert-dialog-text">
|
||||
Unable to reach
|
||||
server
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText id="alert-dialog-desc">
|
||||
Unable to
|
||||
connect to the
|
||||
jellyfin
|
||||
server.
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() =>
|
||||
navigate(
|
||||
"/servers/list",
|
||||
)
|
||||
}
|
||||
>
|
||||
Change Server
|
||||
</Button>
|
||||
<Button
|
||||
variant="outlined"
|
||||
onClick={
|
||||
handleRelaunch
|
||||
}
|
||||
>
|
||||
Restart
|
||||
JellyPlayer
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/login/index"
|
||||
exact
|
||||
element={<LoginRoute />}
|
||||
/>
|
||||
|
||||
<Route path="/home" element={<Home />} />
|
||||
<Route
|
||||
path="/setup/server"
|
||||
element={<ServerSetup />}
|
||||
/>
|
||||
<Route
|
||||
path="/servers/list"
|
||||
element={<ServerList />}
|
||||
/>
|
||||
<Route
|
||||
path="/login/withImg/:userName/:userId/"
|
||||
element={<LoginWithImage />}
|
||||
/>
|
||||
<Route
|
||||
path="/login/users"
|
||||
element={<UserLogin />}
|
||||
/>
|
||||
<Route
|
||||
path="/login/manual"
|
||||
element={<UserLoginManual />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/library/:id"
|
||||
element={<LibraryView />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/item/:id"
|
||||
element={<ItemDetail />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/musicalbum/:id"
|
||||
element={<MusicAlbumTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/artist/:id"
|
||||
element={<ArtistTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/boxset/:id"
|
||||
element={<BoxSetTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/episode/:id"
|
||||
element={<EpisodeTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/person/:id"
|
||||
element={<PersonTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/playlist/:id"
|
||||
element={<PlaylistTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
path="/series/:id"
|
||||
element={<SeriesTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
path="/search"
|
||||
element={<SearchPage />}
|
||||
/>
|
||||
<Route
|
||||
path="/favorite"
|
||||
element={<FavoritePage />}
|
||||
/>
|
||||
<Route
|
||||
path="/settings"
|
||||
element={<Settings />}
|
||||
/>
|
||||
<Route path="/about" element={<About />} />
|
||||
<Route
|
||||
path="/player"
|
||||
element={<VideoPlayer />}
|
||||
/>
|
||||
{/* </Route> */}
|
||||
</Routes>
|
||||
<Route
|
||||
path="/home"
|
||||
element={<Home />}
|
||||
/>
|
||||
<Route
|
||||
path="/setup/server"
|
||||
element={<ServerSetup />}
|
||||
/>
|
||||
<Route
|
||||
path="/servers/list"
|
||||
element={<ServerList />}
|
||||
/>
|
||||
<Route
|
||||
path="/login/withImg/:userName/:userId/"
|
||||
element={<LoginWithImage />}
|
||||
/>
|
||||
<Route
|
||||
path="/login/users"
|
||||
element={<UserLogin />}
|
||||
/>
|
||||
<Route
|
||||
path="/login/manual"
|
||||
element={<UserLoginManual />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/library/:id"
|
||||
element={<LibraryView />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/item/:id"
|
||||
element={<ItemDetail />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/musicalbum/:id"
|
||||
element={<MusicAlbumTitlePage />}
|
||||
errorElement={<div>Error</div>}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/artist/:id"
|
||||
element={<ArtistTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/boxset/:id"
|
||||
element={<BoxSetTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/episode/:id"
|
||||
element={<EpisodeTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/person/:id"
|
||||
element={<PersonTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path="/playlist/:id"
|
||||
element={<PlaylistTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
path="/series/:id"
|
||||
element={<SeriesTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
path="/search"
|
||||
element={<SearchPage />}
|
||||
/>
|
||||
<Route
|
||||
path="/favorite"
|
||||
element={<FavoritePage />}
|
||||
/>
|
||||
<Route
|
||||
path="/settings"
|
||||
element={<Settings />}
|
||||
/>
|
||||
<Route
|
||||
path="/about"
|
||||
element={<About />}
|
||||
/>
|
||||
<Route
|
||||
path="/player"
|
||||
element={<VideoPlayer />}
|
||||
/>
|
||||
{/* </Route> */}
|
||||
</Routes>
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
<ReactQueryDevtools buttonPosition="bottom-left" />
|
||||
</ThemeProvider>
|
||||
|
||||
@@ -75,6 +75,7 @@ const LikeButton = ({
|
||||
opacity: mutation.isPending ? 1 : 0,
|
||||
transition: "opacity 200ms",
|
||||
}}
|
||||
thickness={2}
|
||||
/>
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
|
||||
@@ -67,6 +67,7 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
||||
opacity: mutation.isPending ? 1 : 0,
|
||||
transition: "opacity 200ms",
|
||||
}}
|
||||
thickness={2}
|
||||
/>
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
|
||||
@@ -17,6 +17,7 @@ class ErrorBoundary extends React.Component {
|
||||
// in ErrorBoundary (created by App)
|
||||
// in div (created by App)
|
||||
// in App
|
||||
this.setState;
|
||||
console.error(`Err in ${info} - ${error}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ const Hero = ({
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!!videoTracks[0].VideoRangeType && (
|
||||
{!!videoTracks[0]?.VideoRangeType && (
|
||||
<Chip
|
||||
variant="filled"
|
||||
label={
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/** @format */
|
||||
|
||||
import React from "react";
|
||||
import Box from "@mui/material/Box";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { MdiEmoticonDead } from "../../icons/mdiEmoticonDead";
|
||||
import Button from "@mui/material/Button";
|
||||
import { red } from "@mui/material/colors";
|
||||
|
||||
export const ErrorNotice = () => {
|
||||
export const ErrorNotice = ({ error, resetErrorBoundary }) => {
|
||||
console.error(error);
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -14,11 +16,51 @@ export const ErrorNotice = () => {
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
flexFlow: "column",
|
||||
opacity: 0.2,
|
||||
// opacity: 0.2,
|
||||
}}
|
||||
>
|
||||
<MdiEmoticonDead sx={{ fontSize: 200 }} />
|
||||
<Typography variant="h3">Something went wrong</Typography>
|
||||
<div
|
||||
className="material-symbols-rounded animate-icon"
|
||||
style={{
|
||||
fontSize: "10em",
|
||||
color: red[800],
|
||||
}}
|
||||
>
|
||||
error
|
||||
</div>
|
||||
<Typography
|
||||
variant="h3"
|
||||
fontFamily="JetBrains Mono Variable"
|
||||
fontWeight={100}
|
||||
>
|
||||
Something went wrong
|
||||
</Typography>
|
||||
<Typography
|
||||
fontFamily="JetBrains Mono Variable"
|
||||
fontWeight={100}
|
||||
variant="h5"
|
||||
style={{
|
||||
padding: "0.5em",
|
||||
background: "rgb(0 0 0 / 1)",
|
||||
borderRadius: "8px",
|
||||
border: "2px dashed rgb(255 255 255 / 0.5)",
|
||||
maxWidth: "40em",
|
||||
marginTop: "1em",
|
||||
// opacity: 0.6,
|
||||
}}
|
||||
>
|
||||
{error.message}
|
||||
</Typography>
|
||||
<Button
|
||||
size="large"
|
||||
variant="contained"
|
||||
onClick={resetErrorBoundary ? resetErrorBoundary : () => {}}
|
||||
style={{
|
||||
marginTop: "1em",
|
||||
}}
|
||||
>
|
||||
Retry
|
||||
</Button>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -168,3 +168,38 @@ h1 {
|
||||
.MuiListItemIcon-root {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.animate-icon {
|
||||
position: relative;
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 100%;
|
||||
opacity: 0;
|
||||
|
||||
filter: blur(10px);
|
||||
animation: iconAnimation cubic-bezier(0.175, 0.885, 0.32, 1.275) 3s
|
||||
infinite;
|
||||
background: rgb(255 0 0 / 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes iconAnimation {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
}
|
||||
60% {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, -50%) scale(4);
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translate(-50%, -50%) scale(4);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user