refactor: remove virtualization from library page #465
This commit is contained in:
3 files changed
+25
-55
No files matched your search
@@ -122,7 +122,6 @@ const CardComponent = ({
|
|||||||
? getTypeIcon(overrideIcon)
|
? getTypeIcon(overrideIcon)
|
||||||
: getTypeIcon(item.Type ?? "universal")}
|
: getTypeIcon(item.Type ?? "universal")}
|
||||||
</div>
|
</div>
|
||||||
{inView && (
|
|
||||||
<img
|
<img
|
||||||
alt={item.Name ?? "blink"}
|
alt={item.Name ?? "blink"}
|
||||||
src={
|
src={
|
||||||
@@ -144,6 +143,7 @@ const CardComponent = ({
|
|||||||
height: "100%",
|
height: "100%",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
|
display: inView ? "block" : "none",
|
||||||
}}
|
}}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
onLoad={(e) => {
|
onLoad={(e) => {
|
||||||
@@ -152,8 +152,6 @@ const CardComponent = ({
|
|||||||
onLoadStart={(e) => console.log(e)}
|
onLoadStart={(e) => console.log(e)}
|
||||||
className="card-image"
|
className="card-image"
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
|
|
||||||
{inView && !disableOverlay && (
|
{inView && !disableOverlay && (
|
||||||
<div className="card-overlay">
|
<div className="card-overlay">
|
||||||
<PlayButton
|
<PlayButton
|
||||||
|
|||||||
@@ -218,6 +218,9 @@ function Library() {
|
|||||||
case CollectionType.Playlists:
|
case CollectionType.Playlists:
|
||||||
result = [{ title: "Playlist", value: BaseItemKind.Playlist }];
|
result = [{ title: "Playlist", value: BaseItemKind.Playlist }];
|
||||||
break;
|
break;
|
||||||
|
case CollectionType.Books:
|
||||||
|
result = [{ title: "Books", value: BaseItemKind.Book }];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
result = [];
|
result = [];
|
||||||
}
|
}
|
||||||
@@ -517,6 +520,14 @@ function Library() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
case CollectionType.Books:
|
||||||
|
result = [
|
||||||
|
{
|
||||||
|
title: "Name",
|
||||||
|
value: ItemSortBy.SortName,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// And they say typescript makes your code better :|
|
// And they say typescript makes your code better :|
|
||||||
const cachedVal = JSON.parse(
|
const cachedVal = JSON.parse(
|
||||||
@@ -661,8 +672,7 @@ function Library() {
|
|||||||
result = await getItemsApi(api).getItems({
|
result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
parentId: currentLib.data?.Id,
|
parentId: currentLib.data?.Id,
|
||||||
recursive:
|
recursive: true,
|
||||||
currentLib.data?.CollectionType === "boxsets" ? undefined : true,
|
|
||||||
includeItemTypes: [currentViewType],
|
includeItemTypes: [currentViewType],
|
||||||
sortOrder: [
|
sortOrder: [
|
||||||
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||||
@@ -1333,33 +1343,11 @@ function Library() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : currentViewType !== BaseItemKind.Audio ? (
|
) : currentViewType !== BaseItemKind.Audio ? (
|
||||||
<div
|
<div className="library-items-container">
|
||||||
style={{
|
{items.data?.Items?.map((item) => (
|
||||||
height: virtualizer.getTotalSize(),
|
|
||||||
width: "100%",
|
|
||||||
position: "relative",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{virtualizer.getVirtualItems().map((virtualRow) => {
|
|
||||||
const index = virtualRow.index;
|
|
||||||
const displayItems = [];
|
|
||||||
const fromIndex = index * itemsPerRow;
|
|
||||||
const toIndex = Math.min(
|
|
||||||
fromIndex + itemsPerRow,
|
|
||||||
items.data?.TotalRecordCount ?? 0,
|
|
||||||
);
|
|
||||||
for (let i = fromIndex; i < toIndex; i++) {
|
|
||||||
const item = items.data?.Items?.[i];
|
|
||||||
if (!item) return null;
|
|
||||||
displayItems.push(
|
|
||||||
<div
|
|
||||||
className="library-virtual-item"
|
|
||||||
key={i}
|
|
||||||
data-index={virtualRow.index}
|
|
||||||
ref={virtualizer.measureElement}
|
|
||||||
>
|
|
||||||
<Card
|
<Card
|
||||||
item={item}
|
item={item}
|
||||||
|
key={item?.Id}
|
||||||
seriesId={item?.SeriesId}
|
seriesId={item?.SeriesId}
|
||||||
cardTitle={
|
cardTitle={
|
||||||
item?.Type === BaseItemKind.Episode
|
item?.Type === BaseItemKind.Episode
|
||||||
@@ -1373,12 +1361,9 @@ function Library() {
|
|||||||
: item?.Type === BaseItemKind.Series
|
: item?.Type === BaseItemKind.Series
|
||||||
? `${item.ProductionYear} - ${
|
? `${item.ProductionYear} - ${
|
||||||
item.EndDate
|
item.EndDate
|
||||||
? new Date(item.EndDate).toLocaleString(
|
? new Date(item.EndDate).toLocaleString([], {
|
||||||
[],
|
|
||||||
{
|
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
},
|
})
|
||||||
)
|
|
||||||
: "Present"
|
: "Present"
|
||||||
}`
|
}`
|
||||||
: item?.ProductionYear
|
: item?.ProductionYear
|
||||||
@@ -1402,26 +1387,7 @@ function Library() {
|
|||||||
// queryKey={items}
|
// queryKey={items}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
</div>,
|
))}
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="library-virtual-item-row"
|
|
||||||
key={virtualRow.key}
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
width: "100%",
|
|
||||||
height: virtualRow.size,
|
|
||||||
transform: `translateY(${virtualRow.start}px)`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{displayItems}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -80,6 +80,12 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
&-container{
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(10em, 1fr)) ;
|
||||||
|
gap: 1.6em;
|
||||||
|
padding: 1em 4.4em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&-filter {
|
&-filter {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
Reference in new issue
Block a user