From 08f6993132f015b0d29aeab4bb10cfefbfc7c7ef Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Wed, 12 Jul 2023 17:15:54 +0530 Subject: [PATCH] Fix 0 is not a fn in titlePage --- package-lock.json | 12 + package.json | 1 + src/App.jsx | 1 + src/routes/home/index.jsx | 494 ++++++++++++++++++++------------------ src/routes/item/index.jsx | 60 +++-- 5 files changed, 307 insertions(+), 261 deletions(-) diff --git a/package-lock.json b/package-lock.json index d772d75..6593760 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "react": "^18.2.0", "react-blurhash": "^0.3.0", "react-dom": "^18.2.0", + "react-error-boundary": "^4.0.10", "react-konami-code": "^2.3.0", "react-material-ui-carousel": "^3.4.2", "react-multi-carousel": "^2.8.3", @@ -2789,6 +2790,17 @@ "react": "^18.2.0" } }, + "node_modules/react-error-boundary": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-4.0.10.tgz", + "integrity": "sha512-pvVKdi77j2OoPHo+p3rorgE43OjDWiqFkaqkJz8sJKK6uf/u8xtzuaVfj5qJ2JnDLIgF1De3zY5AJDijp+LVPA==", + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "peerDependencies": { + "react": ">=16.13.1" + } + }, "node_modules/react-fast-compare": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.2.tgz", diff --git a/package.json b/package.json index afc1ef9..ee2541e 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "react": "^18.2.0", "react-blurhash": "^0.3.0", "react-dom": "^18.2.0", + "react-error-boundary": "^4.0.10", "react-konami-code": "^2.3.0", "react-material-ui-carousel": "^3.4.2", "react-multi-carousel": "^2.8.3", diff --git a/src/App.jsx b/src/App.jsx index 2ce2a94..ce10953 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -397,6 +397,7 @@ function App() { + ); diff --git a/src/routes/home/index.jsx b/src/routes/home/index.jsx index 6898a75..4894379 100644 --- a/src/routes/home/index.jsx +++ b/src/routes/home/index.jsx @@ -49,6 +49,8 @@ import { useNavigate } from "react-router-dom"; import { endsAt, getRuntime } from "../../utils/date/time"; import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client"; +import { ErrorBoundary } from "react-error-boundary"; + const Home = () => { const authUser = useQuery({ queryKey: ["home", "authenticateUser"], @@ -249,267 +251,289 @@ const Home = () => { latestMedia.data.length != 0 && latestMedia.data.map((item, index) => { return ( - + Something went wrong in + carousel slide for + {" --- "} + {item.Name} + + } > -
- {item.Type == - BaseItemKind.MusicAlbum ? ( - !!item.ParentBackdropItemId && ( - <> - +
+ {item.Type == + BaseItemKind.MusicAlbum ? ( + !!item.ParentBackdropItemId && ( + <> + + .ImageBlurHashes + .Backdrop[ + item + .ParentBackdropImageTags[0] + ] + } + // hash="LEHV6nWB2yk8pyo0adR*.7kCMdnj" + width="1080" + height="720" + resolutionX={ + 64 + } + resolutionY={ + 96 + } + className="hero-carousel-background-blurhash" + punch={ + 1 + } + /> +
+ + ) + ) : item.ImageBlurHashes + .Backdrop ? ( + <> + {item + .BackdropImageTags + .length != + 0 && ( + + )}
- ) - ) : item.ImageBlurHashes - .Backdrop ? ( - <> - {item - .BackdropImageTags - .length != - 0 && ( - - )} -
+ )} +
+ { + MediaTypeIconCollection[ + item.Type + ] + } +
+
+ + + {!item.ImageTags + .Logo ? ( + item.Name + ) : ( +
- - ) : ( -
- )} -
- { - MediaTypeIconCollection[ - item.Type - ] - } -
- - - - {!item.ImageTags.Logo ? ( - item.Name - ) : ( - + )} + + + } + className="hero-carousel-info" + > + + {!!item.ProductionYear + ? item.ProductionYear + : "Unknown"} + + - )} - - - } - className="hero-carousel-info" - > + + {!!item.CommunityRating ? ( + <> + + + {Math.round( + item.CommunityRating * + 10, + ) / + 10} + + + ) : ( + + No + Community + Rating + + )} + + {!!item.RunTimeTicks && ( + + {getRuntime( + item.RunTimeTicks, + )} + + )} + {!!item.RunTimeTicks && ( + + {endsAt( + item.RunTimeTicks, + )} + + )} + - {!!item.ProductionYear - ? item.ProductionYear - : "Unknown"} + {item.Overview} - + {/* TODO Link PLay and More info buttons in carousel */} - {!!item.CommunityRating ? ( - <> - - - {Math.round( - item.CommunityRating * - 10, - ) / - 10} - - - ) : ( - - No - Community - Rating - - )} + + - {!!item.RunTimeTicks && ( - - {getRuntime( - item.RunTimeTicks, - )} - - )} - {!!item.RunTimeTicks && ( - - {endsAt( - item.RunTimeTicks, - )} - - )} - - - {item.Overview} - - {/* TODO Link PLay and More info buttons in carousel */} - - - - -
+ + ); }) )} diff --git a/src/routes/item/index.jsx b/src/routes/item/index.jsx index eb53cd9..6edc505 100644 --- a/src/routes/item/index.jsx +++ b/src/routes/item/index.jsx @@ -767,32 +767,40 @@ const ItemDetail = () => { } /> )} - {!!item.data.ImageBlurHashes - .Primary && ( - - )} + {!!item.data.ImageTags.Primary && + Object.keys( + item.data.ImageBlurHashes + .Primary, + ).length != 0 && ( + + )}
{ TypeIconCollectionCard[