Update ErrorNotice and add route level errorBoundary
This commit is contained in:
7 files changed
+111
-14
No files matched your search
+24
-7
@@ -101,6 +101,8 @@ import { CircularProgress } from "@mui/material";
|
|||||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||||
import { useCentralStore } from "./utils/store/central.js";
|
import { useCentralStore } from "./utils/store/central.js";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
|
import { ErrorNotice } from "./components/notices/errorNotice/errorNotice.jsx";
|
||||||
|
|
||||||
const anim = {
|
const anim = {
|
||||||
initial: {
|
initial: {
|
||||||
@@ -457,6 +459,7 @@ function App() {
|
|||||||
<SideMenu />
|
<SideMenu />
|
||||||
<AppBar />
|
<AppBar />
|
||||||
<AudioPlayer key={audioPlayerVisible} />
|
<AudioPlayer key={audioPlayerVisible} />
|
||||||
|
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
||||||
<Routes location={location}>
|
<Routes location={location}>
|
||||||
{/* <Route
|
{/* <Route
|
||||||
// key={location.key}
|
// key={location.key}
|
||||||
@@ -465,7 +468,9 @@ function App() {
|
|||||||
<Route
|
<Route
|
||||||
path="/"
|
path="/"
|
||||||
exact
|
exact
|
||||||
element={<Navigate to={initialRoute} />}
|
element={
|
||||||
|
<Navigate to={initialRoute} />
|
||||||
|
}
|
||||||
// element={<></>}
|
// element={<></>}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
@@ -479,12 +484,15 @@ function App() {
|
|||||||
maxWidth="md"
|
maxWidth="md"
|
||||||
>
|
>
|
||||||
<DialogTitle id="alert-dialog-text">
|
<DialogTitle id="alert-dialog-text">
|
||||||
Unable to reach server
|
Unable to reach
|
||||||
|
server
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogContentText id="alert-dialog-desc">
|
<DialogContentText id="alert-dialog-desc">
|
||||||
Unable to connect to
|
Unable to
|
||||||
the jellyfin server.
|
connect to the
|
||||||
|
jellyfin
|
||||||
|
server.
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
@@ -503,7 +511,8 @@ function App() {
|
|||||||
handleRelaunch
|
handleRelaunch
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Restart JellyPlayer
|
Restart
|
||||||
|
JellyPlayer
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
@@ -515,7 +524,10 @@ function App() {
|
|||||||
element={<LoginRoute />}
|
element={<LoginRoute />}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Route path="/home" element={<Home />} />
|
<Route
|
||||||
|
path="/home"
|
||||||
|
element={<Home />}
|
||||||
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/setup/server"
|
path="/setup/server"
|
||||||
element={<ServerSetup />}
|
element={<ServerSetup />}
|
||||||
@@ -550,6 +562,7 @@ function App() {
|
|||||||
exact
|
exact
|
||||||
path="/musicalbum/:id"
|
path="/musicalbum/:id"
|
||||||
element={<MusicAlbumTitlePage />}
|
element={<MusicAlbumTitlePage />}
|
||||||
|
errorElement={<div>Error</div>}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
@@ -592,13 +605,17 @@ function App() {
|
|||||||
path="/settings"
|
path="/settings"
|
||||||
element={<Settings />}
|
element={<Settings />}
|
||||||
/>
|
/>
|
||||||
<Route path="/about" element={<About />} />
|
<Route
|
||||||
|
path="/about"
|
||||||
|
element={<About />}
|
||||||
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/player"
|
path="/player"
|
||||||
element={<VideoPlayer />}
|
element={<VideoPlayer />}
|
||||||
/>
|
/>
|
||||||
{/* </Route> */}
|
{/* </Route> */}
|
||||||
</Routes>
|
</Routes>
|
||||||
|
</ErrorBoundary>
|
||||||
</div>
|
</div>
|
||||||
<ReactQueryDevtools buttonPosition="bottom-left" />
|
<ReactQueryDevtools buttonPosition="bottom-left" />
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ const LikeButton = ({
|
|||||||
opacity: mutation.isPending ? 1 : 0,
|
opacity: mutation.isPending ? 1 : 0,
|
||||||
transition: "opacity 200ms",
|
transition: "opacity 200ms",
|
||||||
}}
|
}}
|
||||||
|
thickness={2}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => {
|
|||||||
opacity: mutation.isPending ? 1 : 0,
|
opacity: mutation.isPending ? 1 : 0,
|
||||||
transition: "opacity 200ms",
|
transition: "opacity 200ms",
|
||||||
}}
|
}}
|
||||||
|
thickness={2}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class ErrorBoundary extends React.Component {
|
|||||||
// in ErrorBoundary (created by App)
|
// in ErrorBoundary (created by App)
|
||||||
// in div (created by App)
|
// in div (created by App)
|
||||||
// in App
|
// in App
|
||||||
|
this.setState;
|
||||||
console.error(`Err in ${info} - ${error}`);
|
console.error(`Err in ${info} - ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ const Hero = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!!videoTracks[0].VideoRangeType && (
|
{!!videoTracks[0]?.VideoRangeType && (
|
||||||
<Chip
|
<Chip
|
||||||
variant="filled"
|
variant="filled"
|
||||||
label={
|
label={
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
|
import React from "react";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Typography from "@mui/material/Typography";
|
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 (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -14,11 +16,51 @@ export const ErrorNotice = () => {
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
flexFlow: "column",
|
flexFlow: "column",
|
||||||
opacity: 0.2,
|
// opacity: 0.2,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MdiEmoticonDead sx={{ fontSize: 200 }} />
|
<div
|
||||||
<Typography variant="h3">Something went wrong</Typography>
|
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>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -168,3 +168,38 @@ h1 {
|
|||||||
.MuiListItemIcon-root {
|
.MuiListItemIcon-root {
|
||||||
font-size: 24px;
|
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