Fix performance issues for libView page #26
This commit is contained in:
4 files changed
+156
-161
No files matched your search
+1
-9
@@ -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 />
|
||||||
|
|||||||
@@ -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)}
|
||||||
|
|||||||
+152
-151
@@ -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,163 +808,163 @@ const LibraryView = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
{items.isSuccess &&
|
{items.isLoading || items.isFetching ? (
|
||||||
(items.data.TotalRecordCount == 0 ? (
|
<Box
|
||||||
<EmptyNotice />
|
sx={{
|
||||||
) : currentViewType != BaseItemKind.Audio ? (
|
position: "absolute",
|
||||||
<Grid2
|
top: 0,
|
||||||
container
|
left: 0,
|
||||||
columns={{ xs: 2, sm: 4, md: 8 }}
|
height: "100%",
|
||||||
>
|
width: "100%",
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CircularProgress />
|
||||||
|
</Box>
|
||||||
|
) : items.data.TotalRecordCount == 0 ? (
|
||||||
|
<EmptyNotice />
|
||||||
|
) : currentViewType != BaseItemKind.Audio ? (
|
||||||
|
<Grid2 container columns={{ xs: 2, sm: 4, md: 8 }}>
|
||||||
|
{items.data.Items.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Grid2 key={index} xs={1} sm={1} md={1}>
|
||||||
|
<Card
|
||||||
|
itemName={item.Name}
|
||||||
|
itemId={item.Id}
|
||||||
|
imageTags={
|
||||||
|
!!item.ImageTags.Primary
|
||||||
|
}
|
||||||
|
subText={item.ProductionYear}
|
||||||
|
iconType={item.Type}
|
||||||
|
playedPercent={
|
||||||
|
!!item.UserData
|
||||||
|
? item.UserData
|
||||||
|
.PlayedPercentage
|
||||||
|
: 0
|
||||||
|
}
|
||||||
|
cardOrientation={
|
||||||
|
item.Type ==
|
||||||
|
"MusicArtist" ||
|
||||||
|
item.Type ==
|
||||||
|
"MusicAlbum" ||
|
||||||
|
item.Type ==
|
||||||
|
"MusicGenre" ||
|
||||||
|
item.Type == "Playlist"
|
||||||
|
? "square"
|
||||||
|
: "portait"
|
||||||
|
}
|
||||||
|
watchedStatus={
|
||||||
|
!!item.UserData
|
||||||
|
? item.UserData
|
||||||
|
.Played
|
||||||
|
: false
|
||||||
|
}
|
||||||
|
watchedCount={
|
||||||
|
!!item.UserData &&
|
||||||
|
item.UserData
|
||||||
|
.UnplayedItemCount
|
||||||
|
}
|
||||||
|
blurhash={
|
||||||
|
item.ImageBlurHashes ==
|
||||||
|
{}
|
||||||
|
? ""
|
||||||
|
: !!item.ImageTags
|
||||||
|
.Primary
|
||||||
|
? !!item
|
||||||
|
.ImageBlurHashes
|
||||||
|
.Primary
|
||||||
|
? item
|
||||||
|
.ImageBlurHashes
|
||||||
|
.Primary[
|
||||||
|
item
|
||||||
|
.ImageTags
|
||||||
|
.Primary
|
||||||
|
]
|
||||||
|
: ""
|
||||||
|
: ""
|
||||||
|
}
|
||||||
|
currentUser={user.data}
|
||||||
|
></Card>
|
||||||
|
</Grid2>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Grid2>
|
||||||
|
) : (
|
||||||
|
<TableContainer>
|
||||||
|
<Table>
|
||||||
{items.data.Items.map((item, index) => {
|
{items.data.Items.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<Grid2
|
<TableRow
|
||||||
key={index}
|
key={index}
|
||||||
xs={1}
|
sx={{
|
||||||
sm={1}
|
"& td,& th": {
|
||||||
md={1}
|
borderBottom:
|
||||||
|
"1px solid rgb(255 255 255 / 0.1)",
|
||||||
|
},
|
||||||
|
"&:hover": {
|
||||||
|
background:
|
||||||
|
"rgb(255 255 255 / 0.05)",
|
||||||
|
},
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Card
|
<TableCell width="4.5em">
|
||||||
itemName={item.Name}
|
<Box className="library-list-image-container">
|
||||||
itemId={item.Id}
|
{!!item.ImageTags
|
||||||
imageTags={
|
.Primary && (
|
||||||
!!item.ImageTags
|
<img
|
||||||
.Primary
|
className="library-list-image"
|
||||||
}
|
src={`${window.api.basePath}/Items/${item.Id}/Images/Primary?quality=80&tag=${item.ImageTags.Primary}`}
|
||||||
subText={
|
/>
|
||||||
item.ProductionYear
|
)}
|
||||||
}
|
<Box className="library-list-icon-container">
|
||||||
iconType={item.Type}
|
<MdiMusic className="library-list-icon" />
|
||||||
playedPercent={
|
</Box>
|
||||||
!!item.UserData
|
</Box>
|
||||||
? item.UserData
|
</TableCell>
|
||||||
.PlayedPercentage
|
<TableCell>
|
||||||
: 0
|
<Typography variant="h6">
|
||||||
}
|
{item.Name}
|
||||||
cardOrientation={
|
</Typography>
|
||||||
item.Type ==
|
<Typography
|
||||||
"MusicArtist" ||
|
variant="subtitle1"
|
||||||
item.Type ==
|
sx={{
|
||||||
"MusicAlbum" ||
|
opacity: 0.7,
|
||||||
item.Type ==
|
}}
|
||||||
"MusicGenre" ||
|
>
|
||||||
item.Type ==
|
{item.Album}
|
||||||
"Playlist"
|
</Typography>
|
||||||
? "square"
|
</TableCell>
|
||||||
: "portait"
|
<TableCell>
|
||||||
}
|
<Typography variant="subtitle1">
|
||||||
watchedStatus={
|
{getRuntimeMusic(
|
||||||
!!item.UserData
|
item.RunTimeTicks,
|
||||||
? item.UserData
|
)}
|
||||||
.Played
|
</Typography>
|
||||||
: false
|
</TableCell>
|
||||||
}
|
<TableCell width="1em">
|
||||||
watchedCount={
|
<IconButton
|
||||||
!!item.UserData &&
|
onClick={() => {
|
||||||
item.UserData
|
handleLiking(
|
||||||
.UnplayedItemCount
|
item,
|
||||||
}
|
);
|
||||||
blurhash={
|
}}
|
||||||
item.ImageBlurHashes ==
|
>
|
||||||
{}
|
{item.UserData
|
||||||
? ""
|
.IsFavorite ? (
|
||||||
: !!item
|
<MdiHeart />
|
||||||
.ImageTags
|
) : (
|
||||||
.Primary
|
<MdiHeartOutline />
|
||||||
? !!item
|
)}
|
||||||
.ImageBlurHashes
|
</IconButton>
|
||||||
.Primary
|
</TableCell>
|
||||||
? item
|
</TableRow>
|
||||||
.ImageBlurHashes
|
|
||||||
.Primary[
|
|
||||||
item
|
|
||||||
.ImageTags
|
|
||||||
.Primary
|
|
||||||
]
|
|
||||||
: ""
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
currentUser={user.data}
|
|
||||||
></Card>
|
|
||||||
</Grid2>
|
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Grid2>
|
</Table>
|
||||||
) : (
|
</TableContainer>
|
||||||
<TableContainer>
|
)}
|
||||||
<Table>
|
|
||||||
{items.data.Items.map((item, index) => {
|
|
||||||
return (
|
|
||||||
<TableRow
|
|
||||||
key={index}
|
|
||||||
sx={{
|
|
||||||
"& td,& th": {
|
|
||||||
borderBottom:
|
|
||||||
"1px solid rgb(255 255 255 / 0.1)",
|
|
||||||
},
|
|
||||||
"&:hover": {
|
|
||||||
background:
|
|
||||||
"rgb(255 255 255 / 0.05)",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TableCell width="4.5em">
|
|
||||||
<Box className="library-list-image-container">
|
|
||||||
{!!item
|
|
||||||
.ImageTags
|
|
||||||
.Primary && (
|
|
||||||
<img
|
|
||||||
className="library-list-image"
|
|
||||||
src={`${window.api.basePath}/Items/${item.Id}/Images/Primary?quality=80&tag=${item.ImageTags.Primary}`}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Box className="library-list-icon-container">
|
|
||||||
<MdiMusic className="library-list-icon" />
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<Typography variant="h6">
|
|
||||||
{item.Name}
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="subtitle1"
|
|
||||||
sx={{
|
|
||||||
opacity: 0.7,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{item.Album}
|
|
||||||
</Typography>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<Typography variant="subtitle1">
|
|
||||||
{getRuntimeMusic(
|
|
||||||
item.RunTimeTicks,
|
|
||||||
)}
|
|
||||||
</Typography>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell width="1em">
|
|
||||||
<IconButton
|
|
||||||
onClick={() => {
|
|
||||||
handleLiking(
|
|
||||||
item,
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{item.UserData
|
|
||||||
.IsFavorite ? (
|
|
||||||
<MdiHeart />
|
|
||||||
) : (
|
|
||||||
<MdiHeartOutline />
|
|
||||||
)}
|
|
||||||
</IconButton>
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Table>
|
|
||||||
</TableContainer>
|
|
||||||
))}
|
|
||||||
{items.isError && <ErrorNotice />}
|
{items.isError && <ErrorNotice />}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user