Fix performance issues for libView page #26

This commit is contained in:
prayag17 committed 2023-04-25 13:37:10 +05:30
1 parent 9c4c1191d8
commit 1d31496854
4 files changed
+29 -34

No files matched your search

+1 -9
View File
@@ -89,15 +89,9 @@ event.on("set-api-accessToken", (serverAddress) => {
const anim = { const anim = {
initial: { initial: {
opacity: 0, opacity: 0,
x: -50,
}, },
animate: { animate: {
opacity: 1, opacity: 1,
x: 0,
},
exit: {
opacity: 0,
x: 50,
}, },
}; };
@@ -108,10 +102,8 @@ const AnimationWrapper = () => {
variants={anim} variants={anim}
initial="initial" initial="initial"
animate="animate" animate="animate"
exit="exit"
transition={{ transition={{
duration: 0.3, duration: 0.4,
ease: "easeInOut",
}} }}
> >
<Outlet /> <Outlet />
+2
View File
@@ -96,6 +96,7 @@ export const EpisodeCard = ({
background: "transparent", background: "transparent",
borderRadius: borderRadiusDefault, borderRadius: borderRadiusDefault,
mr: 1, mr: 1,
mb: 0.5,
}} }}
elevation={0} elevation={0}
{...cardProps} {...cardProps}
@@ -300,6 +301,7 @@ export const EpisodeCard = ({
maxWidth="100%" maxWidth="100%"
sx={{ sx={{
opacity: 0.65, opacity: 0.65,
flexShrink: 0,
}} }}
> >
{getRuntime(itemTicks)} {getRuntime(itemTicks)}
+25 -24
View File
@@ -331,6 +331,7 @@ const LibraryView = () => {
queryFn: () => fetchLibItems(id), queryFn: () => fetchLibItems(id),
enabled: currentLib.isSuccess, enabled: currentLib.isSuccess,
networkMode: "always", networkMode: "always",
refetchOnWindowFocus: false,
}); });
const handleCurrentViewType = (e) => { const handleCurrentViewType = (e) => {
@@ -807,32 +808,35 @@ const LibraryView = () => {
</Stack> </Stack>
</Toolbar> </Toolbar>
</AppBar> </AppBar>
{items.isSuccess && {items.isLoading || items.isFetching ? (
(items.data.TotalRecordCount == 0 ? ( <Box
sx={{
position: "absolute",
top: 0,
left: 0,
height: "100%",
width: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
>
<CircularProgress />
</Box>
) : items.data.TotalRecordCount == 0 ? (
<EmptyNotice /> <EmptyNotice />
) : currentViewType != BaseItemKind.Audio ? ( ) : currentViewType != BaseItemKind.Audio ? (
<Grid2 <Grid2 container columns={{ xs: 2, sm: 4, md: 8 }}>
container
columns={{ xs: 2, sm: 4, md: 8 }}
>
{items.data.Items.map((item, index) => { {items.data.Items.map((item, index) => {
return ( return (
<Grid2 <Grid2 key={index} xs={1} sm={1} md={1}>
key={index}
xs={1}
sm={1}
md={1}
>
<Card <Card
itemName={item.Name} itemName={item.Name}
itemId={item.Id} itemId={item.Id}
imageTags={ imageTags={
!!item.ImageTags !!item.ImageTags.Primary
.Primary
}
subText={
item.ProductionYear
} }
subText={item.ProductionYear}
iconType={item.Type} iconType={item.Type}
playedPercent={ playedPercent={
!!item.UserData !!item.UserData
@@ -847,8 +851,7 @@ const LibraryView = () => {
"MusicAlbum" || "MusicAlbum" ||
item.Type == item.Type ==
"MusicGenre" || "MusicGenre" ||
item.Type == item.Type == "Playlist"
"Playlist"
? "square" ? "square"
: "portait" : "portait"
} }
@@ -867,8 +870,7 @@ const LibraryView = () => {
item.ImageBlurHashes == item.ImageBlurHashes ==
{} {}
? "" ? ""
: !!item : !!item.ImageTags
.ImageTags
.Primary .Primary
? !!item ? !!item
.ImageBlurHashes .ImageBlurHashes
@@ -909,8 +911,7 @@ const LibraryView = () => {
> >
<TableCell width="4.5em"> <TableCell width="4.5em">
<Box className="library-list-image-container"> <Box className="library-list-image-container">
{!!item {!!item.ImageTags
.ImageTags
.Primary && ( .Primary && (
<img <img
className="library-list-image" className="library-list-image"
@@ -963,7 +964,7 @@ const LibraryView = () => {
})} })}
</Table> </Table>
</TableContainer> </TableContainer>
))} )}
{items.isError && <ErrorNotice />} {items.isError && <ErrorNotice />}
</Box> </Box>
</Box> </Box>
+1 -1
View File
@@ -24,7 +24,7 @@ export const getRuntime = (ticks) => {
timeMin -= timeHr * 60; timeMin -= timeHr * 60;
formatedTime = `${timeHr}hr ${timeMin}min`; formatedTime = `${timeHr}hr ${timeMin}min`;
} else { } else {
formatedTime = `${timeMin}min ${timeSec}sec`; formatedTime = `${timeMin}min`;
} }
return formatedTime; return formatedTime;
}; };