feat: add new library page with performance improvements
This commit is contained in:
29 files changed
+2020
-645
No files matched your search
@@ -1 +1 @@
|
||||
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-set-dock-visibility":{"identifier":"allow-set-dock-visibility","description":"Enables the set_dock_visibility command without any pre-configured scope.","commands":{"allow":["set_dock_visibility"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":[Line truncated
|
||||
{"clipboard-manager":{"default_permission":{"identifier":"default","description":"No features are enabled by default, as we believe\nthe clipboard can be inherently dangerous and it is \napplication specific if read and/or write access is needed.\n\nClipboard interaction needs to be explicitly enabled.\n","permissions":[]},"permissions":{"allow-clear":{"identifier":"allow-clear","description":"Enables the clear command without any pre-configured scope.","commands":{"allow":["clear"],"deny":[]}},"allow-read-image":{"identifier":"allow-read-image","description":"Enables the read_image command without any pre-configured scope.","commands":{"allow":["read_image"],"deny":[]}},"allow-read-text":{"identifier":"allow-read-text","description":"Enables the read_text command without any pre-configured scope.","commands":{"allow":["read_text"],"deny":[]}},"allow-write-html":{"identifier":"allow-write-html","description":"Enables the write_html command without any pre-configured scope.","commands":{"allow":["write_html"],"deny":[]}},"allow-write-image":{"identifier":"allow-write-image","description":"Enables the write_image command without any pre-configured scope.","commands":{"allow":["write_image"],"deny":[]}},"allow-write-text":{"identifier":"allow-write-text","description":"Enables the write_text command without any pre-configured scope.","commands":{"allow":["write_text"],"deny":[]}},"deny-clear":{"identifier":"deny-clear","description":"Denies the clear command without any pre-configured scope.","commands":{"allow":[],"deny":["clear"]}},"deny-read-image":{"identifier":"deny-read-image","description":"Denies the read_image command without any pre-configured scope.","commands":{"allow":[],"deny":["read_image"]}},"deny-read-text":{"identifier":"deny-read-text","description":"Denies the read_text command without any pre-configured scope.","commands":{"allow":[],"deny":["read_text"]}},"deny-write-html":{"identifier":"deny-write-html","description":"Denies the write_html command without any pre-configured scope.","commands":{"allow":[],"deny":["write_html"]}},"deny-write-image":{"identifier":"deny-write-image","description":"Denies the write_image command without any pre-configured scope.","commands":{"allow":[],"deny":["write_image"]}},"deny-write-text":{"identifier":"deny-write-text","description":"Denies the write_text command without any pre-configured scope.","commands":{"allow":[],"deny":["write_text"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-register-listener":{"identifier":"allow-register-listener","description":"Enables the register_listener command without any pre-configured scope.","commands":{"allow":["register_listener"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-remove-listener":{"identifier":"allow-remove-listener","description":"Enables the remove_listener commLine truncated
|
||||
@@ -261,10 +261,10 @@
|
||||
"markdownDescription": "Default core plugins set.\n#### This default permission set includes:\n\n- `core:path:default`\n- `core:event:default`\n- `core:window:default`\n- `core:webview:default`\n- `core:app:default`\n- `core:image:default`\n- `core:resources:default`\n- `core:menu:default`\n- `core:tray:default`"
|
||||
},
|
||||
{
|
||||
"description": "Default permissions for the plugin.\n#### This default permission set includes:\n\n- `allow-version`\n- `allow-name`\n- `allow-tauri-version`\n- `allow-identifier`",
|
||||
"description": "Default permissions for the plugin.\n#### This default permission set includes:\n\n- `allow-version`\n- `allow-name`\n- `allow-tauri-version`\n- `allow-identifier`\n- `allow-bundle-type`\n- `allow-register-listener`\n- `allow-remove-listener`",
|
||||
"type": "string",
|
||||
"const": "core:app:default",
|
||||
"markdownDescription": "Default permissions for the plugin.\n#### This default permission set includes:\n\n- `allow-version`\n- `allow-name`\n- `allow-tauri-version`\n- `allow-identifier`"
|
||||
"markdownDescription": "Default permissions for the plugin.\n#### This default permission set includes:\n\n- `allow-version`\n- `allow-name`\n- `allow-tauri-version`\n- `allow-identifier`\n- `allow-bundle-type`\n- `allow-register-listener`\n- `allow-remove-listener`"
|
||||
},
|
||||
{
|
||||
"description": "Enables the app_hide command without any pre-configured scope.",
|
||||
@@ -278,6 +278,12 @@
|
||||
"const": "core:app:allow-app-show",
|
||||
"markdownDescription": "Enables the app_show command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the bundle_type command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-bundle-type",
|
||||
"markdownDescription": "Enables the bundle_type command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the default_window_icon command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -302,12 +308,24 @@
|
||||
"const": "core:app:allow-name",
|
||||
"markdownDescription": "Enables the name command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the register_listener command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-register-listener",
|
||||
"markdownDescription": "Enables the register_listener command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the remove_data_store command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-remove-data-store",
|
||||
"markdownDescription": "Enables the remove_data_store command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the remove_listener command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-remove-listener",
|
||||
"markdownDescription": "Enables the remove_listener command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_app_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -344,6 +362,12 @@
|
||||
"const": "core:app:deny-app-show",
|
||||
"markdownDescription": "Denies the app_show command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the bundle_type command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-bundle-type",
|
||||
"markdownDescription": "Denies the bundle_type command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the default_window_icon command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -368,12 +392,24 @@
|
||||
"const": "core:app:deny-name",
|
||||
"markdownDescription": "Denies the name command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the register_listener command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-register-listener",
|
||||
"markdownDescription": "Denies the register_listener command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the remove_data_store command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-remove-data-store",
|
||||
"markdownDescription": "Denies the remove_data_store command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the remove_listener command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-remove-listener",
|
||||
"markdownDescription": "Denies the remove_listener command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_app_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -1556,6 +1592,12 @@
|
||||
"const": "core:window:allow-set-focus",
|
||||
"markdownDescription": "Enables the set_focus command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_focusable command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:allow-set-focusable",
|
||||
"markdownDescription": "Enables the set_focusable command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_fullscreen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -1628,6 +1670,12 @@
|
||||
"const": "core:window:allow-set-shadow",
|
||||
"markdownDescription": "Enables the set_shadow command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_simple_fullscreen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:allow-set-simple-fullscreen",
|
||||
"markdownDescription": "Enables the set_simple_fullscreen command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_size command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2000,6 +2048,12 @@
|
||||
"const": "core:window:deny-set-focus",
|
||||
"markdownDescription": "Denies the set_focus command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_focusable command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:deny-set-focusable",
|
||||
"markdownDescription": "Denies the set_focusable command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_fullscreen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2072,6 +2126,12 @@
|
||||
"const": "core:window:deny-set-shadow",
|
||||
"markdownDescription": "Denies the set_shadow command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_simple_fullscreen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:deny-set-simple-fullscreen",
|
||||
"markdownDescription": "Denies the set_simple_fullscreen command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_size command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -261,10 +261,10 @@
|
||||
"markdownDescription": "Default core plugins set.\n#### This default permission set includes:\n\n- `core:path:default`\n- `core:event:default`\n- `core:window:default`\n- `core:webview:default`\n- `core:app:default`\n- `core:image:default`\n- `core:resources:default`\n- `core:menu:default`\n- `core:tray:default`"
|
||||
},
|
||||
{
|
||||
"description": "Default permissions for the plugin.\n#### This default permission set includes:\n\n- `allow-version`\n- `allow-name`\n- `allow-tauri-version`\n- `allow-identifier`",
|
||||
"description": "Default permissions for the plugin.\n#### This default permission set includes:\n\n- `allow-version`\n- `allow-name`\n- `allow-tauri-version`\n- `allow-identifier`\n- `allow-bundle-type`\n- `allow-register-listener`\n- `allow-remove-listener`",
|
||||
"type": "string",
|
||||
"const": "core:app:default",
|
||||
"markdownDescription": "Default permissions for the plugin.\n#### This default permission set includes:\n\n- `allow-version`\n- `allow-name`\n- `allow-tauri-version`\n- `allow-identifier`"
|
||||
"markdownDescription": "Default permissions for the plugin.\n#### This default permission set includes:\n\n- `allow-version`\n- `allow-name`\n- `allow-tauri-version`\n- `allow-identifier`\n- `allow-bundle-type`\n- `allow-register-listener`\n- `allow-remove-listener`"
|
||||
},
|
||||
{
|
||||
"description": "Enables the app_hide command without any pre-configured scope.",
|
||||
@@ -278,6 +278,12 @@
|
||||
"const": "core:app:allow-app-show",
|
||||
"markdownDescription": "Enables the app_show command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the bundle_type command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-bundle-type",
|
||||
"markdownDescription": "Enables the bundle_type command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the default_window_icon command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -302,12 +308,24 @@
|
||||
"const": "core:app:allow-name",
|
||||
"markdownDescription": "Enables the name command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the register_listener command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-register-listener",
|
||||
"markdownDescription": "Enables the register_listener command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the remove_data_store command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-remove-data-store",
|
||||
"markdownDescription": "Enables the remove_data_store command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the remove_listener command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:allow-remove-listener",
|
||||
"markdownDescription": "Enables the remove_listener command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_app_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -344,6 +362,12 @@
|
||||
"const": "core:app:deny-app-show",
|
||||
"markdownDescription": "Denies the app_show command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the bundle_type command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-bundle-type",
|
||||
"markdownDescription": "Denies the bundle_type command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the default_window_icon command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -368,12 +392,24 @@
|
||||
"const": "core:app:deny-name",
|
||||
"markdownDescription": "Denies the name command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the register_listener command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-register-listener",
|
||||
"markdownDescription": "Denies the register_listener command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the remove_data_store command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-remove-data-store",
|
||||
"markdownDescription": "Denies the remove_data_store command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the remove_listener command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:app:deny-remove-listener",
|
||||
"markdownDescription": "Denies the remove_listener command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_app_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -1556,6 +1592,12 @@
|
||||
"const": "core:window:allow-set-focus",
|
||||
"markdownDescription": "Enables the set_focus command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_focusable command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:allow-set-focusable",
|
||||
"markdownDescription": "Enables the set_focusable command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_fullscreen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -1628,6 +1670,12 @@
|
||||
"const": "core:window:allow-set-shadow",
|
||||
"markdownDescription": "Enables the set_shadow command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_simple_fullscreen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:allow-set-simple-fullscreen",
|
||||
"markdownDescription": "Enables the set_simple_fullscreen command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Enables the set_size command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2000,6 +2048,12 @@
|
||||
"const": "core:window:deny-set-focus",
|
||||
"markdownDescription": "Denies the set_focus command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_focusable command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:deny-set-focusable",
|
||||
"markdownDescription": "Denies the set_focusable command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_fullscreen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2072,6 +2126,12 @@
|
||||
"const": "core:window:deny-set-shadow",
|
||||
"markdownDescription": "Denies the set_shadow command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_simple_fullscreen command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"const": "core:window:deny-set-simple-fullscreen",
|
||||
"markdownDescription": "Denies the set_simple_fullscreen command without any pre-configured scope."
|
||||
},
|
||||
{
|
||||
"description": "Denies the set_size command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
.alpha-selector {
|
||||
position: sticky;
|
||||
top: 80px;
|
||||
right: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px;
|
||||
margin-left: auto;
|
||||
user-select: none;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.alpha-letter {
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
padding: 6px 8px;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: rgba(255,255,255,0.7);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.alpha-letter.active {
|
||||
background: rgba(255,255,255,0.12);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.alpha-letter:hover {
|
||||
background: rgba(255,255,255,0.08);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { getRouteApi } from "@tanstack/react-router";
|
||||
import React, { useMemo } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
import "./alphaSelector.scss";
|
||||
|
||||
const libraryRoute = getRouteApi("/_api/library/$id");
|
||||
|
||||
export const AlphaSelector = React.memo(function AlphaSelector() {
|
||||
const { id: currentLibraryId } = libraryRoute.useParams();
|
||||
const { nameStartsWith } = useLibraryStateStore(
|
||||
useShallow((s) => ({
|
||||
nameStartsWith: s.libraries[currentLibraryId || ""]?.nameStartsWith,
|
||||
})),
|
||||
);
|
||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||
|
||||
const letters = useMemo(() => {
|
||||
const arr = Array.from({ length: 26 }, (_, i) =>
|
||||
String.fromCharCode(65 + i),
|
||||
);
|
||||
return ["All", ...arr];
|
||||
}, []);
|
||||
|
||||
const handleSelect = (letter: string) => {
|
||||
const value = letter === "All" ? undefined : letter;
|
||||
if (currentLibraryId)
|
||||
updateLibrary(currentLibraryId, { nameStartsWith: value });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="alpha-selector">
|
||||
{letters.map((l) => {
|
||||
const active = (nameStartsWith || "All") === l;
|
||||
return (
|
||||
<button
|
||||
key={l}
|
||||
className={active ? "alpha-letter active" : "alpha-letter"}
|
||||
onClick={() => handleSelect(l)}
|
||||
aria-label={`Filter by ${l}`}
|
||||
type="button"
|
||||
>
|
||||
{l}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
export default AlphaSelector;
|
||||
@@ -1,20 +1,48 @@
|
||||
|
||||
.appBar {
|
||||
transition: background-color $transition-time-fast,
|
||||
backdrop-filter $transition-time-fast,
|
||||
box-shadow $transition-time-default !important;
|
||||
// Limit transitions to cheaper properties; avoid animating box-shadow directly
|
||||
transition: background-color $transition-time-fast;
|
||||
padding: 0.8em ($page-margin - 1.7em);
|
||||
z-index: 999 !important;
|
||||
.flex {
|
||||
transition: $transition-time-fast;
|
||||
// Avoid animating padding; it causes layout reflow on each frame.
|
||||
transition: background-color $transition-time-fast;
|
||||
// Avoid using will-change: scroll-position; it can degrade performance when misused
|
||||
// will-change: opacity, transform;
|
||||
border-radius: 1000px;
|
||||
position: relative;
|
||||
|
||||
// Pseudo-element handles elevation shadow; we animate its opacity
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
backdrop-filter: blur(40px);
|
||||
inset: -0.35em;
|
||||
pointer-events: none;
|
||||
border-radius: inherit;
|
||||
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
||||
background: rgb(0 0 0 / 0.4);
|
||||
opacity: 0;
|
||||
z-index: -1;
|
||||
transition: opacity $transition-time-fast;
|
||||
}
|
||||
}
|
||||
|
||||
// Inner content wrapper that we can scale without causing layout reflow
|
||||
.flex-inner {
|
||||
transform-origin: top center;
|
||||
transition: transform $transition-time-fast;
|
||||
}
|
||||
&.elevated{
|
||||
.flex {
|
||||
padding: 0.5em;
|
||||
background: rgb(0 0 0 / 0.4);
|
||||
backdrop-filter: blur(40px);
|
||||
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
||||
&::after {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply a subtle scale to simulate shrink without layout changes
|
||||
.flex-inner {
|
||||
transform: scaleY(0.95);
|
||||
}
|
||||
}
|
||||
&-avatar {
|
||||
|
||||
@@ -1,37 +1,29 @@
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
import MuiAppBar from "@mui/material/AppBar";
|
||||
import Avatar from "@mui/material/Avatar";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import ListItemIcon from "@mui/material/ListItemIcon";
|
||||
import Menu from "@mui/material/Menu";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { useLocation, useNavigate, useRouter } from "@tanstack/react-router";
|
||||
import React, {
|
||||
type MouseEventHandler,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import React, { useCallback, useMemo, useState } from "react";
|
||||
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import "./appBar.scss";
|
||||
|
||||
import { Divider, Drawer, List, ListItem, ListItemButton } from "@mui/material";
|
||||
|
||||
import { useShallow } from "zustand/shallow";
|
||||
// removed search placeholder; library state now managed via zustand
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useHeaderStore from "@/utils/store/header";
|
||||
import {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
import BackButton from "../buttons/backButton";
|
||||
import ListItemLink from "../listItemLink";
|
||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
|
||||
const HIDDEN_PATHS = [
|
||||
@@ -41,25 +33,21 @@ const HIDDEN_PATHS = [
|
||||
"/player",
|
||||
"/error",
|
||||
"/settings",
|
||||
"/library",
|
||||
];
|
||||
|
||||
export const AppBar = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const router = useRouter();
|
||||
|
||||
const display = !HIDDEN_PATHS.some(
|
||||
(path) => location.pathname.startsWith(path) || location.pathname === "/",
|
||||
);
|
||||
|
||||
|
||||
const [user, resetCurrentUser] = useCentralStore((s) => [
|
||||
s.currentUser,
|
||||
s.resetCurrentUser,
|
||||
]);
|
||||
const [user] = useCentralStore((s) => [s.currentUser]);
|
||||
const libraries = useQuery({
|
||||
queryKey: ["libraries"],
|
||||
queryFn: async () => {
|
||||
@@ -80,34 +68,6 @@ export const AppBar = () => {
|
||||
threshold: 20,
|
||||
});
|
||||
|
||||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
||||
const openMenu = Boolean(anchorEl);
|
||||
const handleMenuOpen: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||
(event) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
},
|
||||
[],
|
||||
);
|
||||
const handleMenuClose = useCallback(() => {
|
||||
setAnchorEl(null);
|
||||
}, []);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const handleLogout = useCallback(async () => {
|
||||
console.log("Logging out user...");
|
||||
await api?.logout();
|
||||
createApi(api?.basePath ?? "", undefined);
|
||||
console.log(api);
|
||||
resetCurrentUser();
|
||||
delUser();
|
||||
sessionStorage.removeItem("accessToken");
|
||||
queryClient.clear();
|
||||
await router.invalidate();
|
||||
setAnchorEl(null);
|
||||
navigate({ to: "/login", replace: true });
|
||||
}, [api]);
|
||||
|
||||
|
||||
const [showDrawer, setShowDrawer] = useState(false);
|
||||
|
||||
const appBarStyling = useMemo(() => {
|
||||
@@ -116,9 +76,6 @@ export const AppBar = () => {
|
||||
paddingRight: "0 !important",
|
||||
};
|
||||
}, []);
|
||||
const menuStyle = useMemo(() => {
|
||||
return { mt: 2 };
|
||||
}, []);
|
||||
|
||||
const drawerPaperProps = useMemo(() => {
|
||||
return {
|
||||
@@ -145,7 +102,7 @@ export const AppBar = () => {
|
||||
navigate({ to: "/favorite" });
|
||||
}, []);
|
||||
|
||||
const menuButtonSx = useMemo(() => ({ p: 0 }), []);
|
||||
useHeaderStore(useShallow((s) => ({ pageTitle: s.pageTitle })));
|
||||
|
||||
if (!display) {
|
||||
return null;
|
||||
@@ -188,80 +145,7 @@ export const AppBar = () => {
|
||||
<IconButton onClick={handleNavigateToFavorite}>
|
||||
<div className="material-symbols-rounded">favorite</div>
|
||||
</IconButton>
|
||||
<IconButton sx={menuButtonSx} onClick={handleMenuOpen}>
|
||||
{!!user?.Id &&
|
||||
(user?.PrimaryImageTag === undefined ? (
|
||||
<Avatar className="appBar-avatar" alt={user?.Name ?? "image"}>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
) : (
|
||||
<Avatar
|
||||
className="appBar-avatar"
|
||||
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
||||
alt={user?.Name ?? "image"}
|
||||
>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
))}
|
||||
</IconButton>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
open={openMenu}
|
||||
onClose={handleMenuClose}
|
||||
sx={menuStyle}
|
||||
disableScrollLock
|
||||
>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
handleLogout();
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">logout</div>
|
||||
</ListItemIcon>
|
||||
Logout
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(1);
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">settings</div>
|
||||
</ListItemIcon>
|
||||
Settings
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/preferences" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">tune</div>
|
||||
</ListItemIcon>
|
||||
Preferences
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/about" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">info</div>
|
||||
</ListItemIcon>
|
||||
About
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<UserAvatarMenu />
|
||||
</div>
|
||||
</MuiAppBar>
|
||||
<Drawer
|
||||
@@ -298,9 +182,7 @@ export const AppBar = () => {
|
||||
className="library-drawer-item"
|
||||
key={library.Id}
|
||||
to="/library/$id"
|
||||
params={{
|
||||
id: library.Id ?? "",
|
||||
}}
|
||||
params={{ id: library.Id ?? "" }}
|
||||
icon={
|
||||
library.CollectionType &&
|
||||
getTypeIcon(library.CollectionType)
|
||||
|
||||
@@ -24,6 +24,10 @@ export default function Backdrop() {
|
||||
animate={{ opacity: 1 }}
|
||||
key={backdropHash}
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{
|
||||
duration: 2,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
className="app-backdrop-container"
|
||||
>
|
||||
<BlurhashCanvas
|
||||
|
||||
@@ -33,6 +33,7 @@ const CardComponent = ({
|
||||
onClick,
|
||||
disableOverlay = false,
|
||||
overrideIcon,
|
||||
skipInView = false,
|
||||
}: {
|
||||
item: BaseItemDto;
|
||||
cardTitle: string | undefined | null;
|
||||
@@ -46,6 +47,7 @@ const CardComponent = ({
|
||||
onClick?: () => void;
|
||||
disableOverlay?: boolean;
|
||||
overrideIcon?: any;
|
||||
skipInView?: boolean;
|
||||
}) => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const navigate = useNavigate();
|
||||
@@ -82,6 +84,7 @@ const CardComponent = ({
|
||||
|
||||
const { ref, inView } = useInView({
|
||||
threshold: 0.1,
|
||||
skip: skipInView,
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -120,7 +123,7 @@ const CardComponent = ({
|
||||
? getTypeIcon(overrideIcon)
|
||||
: getTypeIcon(item.Type ?? "universal")}
|
||||
</div>
|
||||
{inView && (
|
||||
{(skipInView || inView) && (
|
||||
<img
|
||||
alt={item.Name ?? "blink"}
|
||||
src={
|
||||
@@ -148,11 +151,10 @@ const CardComponent = ({
|
||||
onLoad={(e) => {
|
||||
e.currentTarget.style.setProperty("opacity", "1");
|
||||
}}
|
||||
onLoadStart={(e) => console.log(e)}
|
||||
className="card-image"
|
||||
/>
|
||||
)}
|
||||
{inView && !disableOverlay && (
|
||||
{(skipInView || inView) && !disableOverlay && (
|
||||
<div className="card-overlay">
|
||||
<PlayButton
|
||||
item={item}
|
||||
@@ -201,7 +203,7 @@ const CardComponent = ({
|
||||
</div>
|
||||
<div
|
||||
className="card-text-container"
|
||||
style={{ display: hideText ? "none" : "block" }}
|
||||
style={{ display: hideText ? "none" : "block", marginLeft: "0.2em" }}
|
||||
>
|
||||
<Typography mt={1} variant="subtitle2" noWrap style={{ opacity: 0.9 }}>
|
||||
{cardTitle}
|
||||
|
||||
@@ -0,0 +1,509 @@
|
||||
import { getGenresApi } from "@jellyfin/sdk/lib/utils/api/genres-api";
|
||||
import { getMusicGenresApi } from "@jellyfin/sdk/lib/utils/api/music-genres-api";
|
||||
import {
|
||||
Accordion,
|
||||
AccordionDetails,
|
||||
AccordionSummary,
|
||||
Button,
|
||||
Checkbox,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
FormControlLabel,
|
||||
FormGroup,
|
||||
IconButton,
|
||||
Stack,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { getRouteApi } from "@tanstack/react-router";
|
||||
import React, { useMemo, useRef, useState } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import type { FILTERS } from "@/utils/constants/library";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
|
||||
const route = getRouteApi("/_api/library/$id");
|
||||
|
||||
const FILTER_LABELS: Record<FILTERS, string> = {
|
||||
isPlayed: "Played",
|
||||
isUnPlayed: "Unplayed",
|
||||
isResumable: "Resumable",
|
||||
isFavorite: "Favorite",
|
||||
hasSubtitles: "Has Subtitles",
|
||||
hasTrailer: "Has Trailer",
|
||||
hasSpecialFeature: "Special Feature",
|
||||
hasThemeSong: "Theme Song",
|
||||
hasThemeVideo: "Theme Video",
|
||||
isSD: "SD",
|
||||
isHD: "HD",
|
||||
is4K: "4K",
|
||||
is3D: "3D",
|
||||
};
|
||||
|
||||
interface FiltersDialogProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
||||
({ open, onClose }) => {
|
||||
const { id: currentLibraryId } = route.useParams();
|
||||
const { api, user } = route.useRouteContext();
|
||||
const { routeFilters, routeVideoTypes, routeGenreIds } =
|
||||
useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const slice = s.libraries[currentLibraryId || ""];
|
||||
return {
|
||||
routeFilters: slice?.filters,
|
||||
routeVideoTypes: slice?.videoTypesState,
|
||||
routeGenreIds: slice?.genreIds,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||
const initial = useMemo(
|
||||
() => ({ ...(routeFilters || {}) }),
|
||||
[routeFilters],
|
||||
);
|
||||
const [localFilters, setLocalFilters] =
|
||||
useState<Record<string, boolean | undefined>>(initial);
|
||||
const initialVideo = useMemo(
|
||||
() => ({ ...(routeVideoTypes || {}) }),
|
||||
[routeVideoTypes],
|
||||
);
|
||||
const [localVideoTypes, setLocalVideoTypes] =
|
||||
useState<Record<string, boolean>>(initialVideo);
|
||||
const initialGenres = useMemo(
|
||||
() => [...(routeGenreIds || [])] as string[],
|
||||
[routeGenreIds],
|
||||
);
|
||||
const [localGenreIds, setLocalGenreIds] = useState<string[]>(initialGenres);
|
||||
const dirty = useMemo(
|
||||
() =>
|
||||
JSON.stringify(initial) !== JSON.stringify(localFilters) ||
|
||||
JSON.stringify(initialVideo) !== JSON.stringify(localVideoTypes) ||
|
||||
JSON.stringify(initialGenres) !== JSON.stringify(localGenreIds),
|
||||
[
|
||||
initial,
|
||||
localFilters,
|
||||
initialVideo,
|
||||
localVideoTypes,
|
||||
initialGenres,
|
||||
localGenreIds,
|
||||
],
|
||||
);
|
||||
const debounceRef = useRef<number | null>(null);
|
||||
const currentLibrary = useSuspenseQuery(
|
||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||
);
|
||||
const collectionType = currentLibrary.data.CollectionType;
|
||||
const isVideoCollection = ["movies", "tvshows", "boxsets"].includes(
|
||||
String(collectionType || "").toLowerCase(),
|
||||
);
|
||||
|
||||
// Fetch genres for this library (music uses music-genres API)
|
||||
const { data: genresData } = useQuery({
|
||||
queryKey: ["library", "genres", currentLibraryId, collectionType],
|
||||
queryFn: async () => {
|
||||
if (!api || !user?.Id || !currentLibraryId) return { Items: [] } as any;
|
||||
if (String(collectionType || "").toLowerCase() === "music") {
|
||||
const res = await getMusicGenresApi(api).getMusicGenres({
|
||||
parentId: currentLibraryId,
|
||||
userId: user.Id,
|
||||
});
|
||||
return res.data;
|
||||
}
|
||||
const res = await getGenresApi(api).getGenres({
|
||||
parentId: currentLibraryId,
|
||||
userId: user.Id,
|
||||
});
|
||||
return res.data;
|
||||
},
|
||||
staleTime: 10 * 60 * 1000,
|
||||
enabled: !!open && !!api && !!user?.Id && !!currentLibraryId,
|
||||
});
|
||||
|
||||
const handleToggle = (key: FILTERS) => {
|
||||
setLocalFilters((prev) => {
|
||||
const next = { ...prev };
|
||||
// isHD special: undefined if unchecked instead of false
|
||||
if (key === "isHD") {
|
||||
if (next[key]) delete next[key];
|
||||
else next[key] = true;
|
||||
} else {
|
||||
next[key] = !next[key];
|
||||
}
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const apply = () => {
|
||||
if (!currentLibraryId) return;
|
||||
if (debounceRef.current) window.clearTimeout(debounceRef.current);
|
||||
debounceRef.current = window.setTimeout(() => {
|
||||
updateLibrary(currentLibraryId, {
|
||||
filters: localFilters as any,
|
||||
videoTypesState: localVideoTypes as any,
|
||||
genreIds: localGenreIds as any,
|
||||
});
|
||||
onClose();
|
||||
}, 40);
|
||||
};
|
||||
|
||||
const clearAll = () => {
|
||||
setLocalFilters({});
|
||||
setLocalVideoTypes({});
|
||||
setLocalGenreIds([]);
|
||||
};
|
||||
|
||||
const restore = () => setLocalFilters(initial);
|
||||
const restoreVideo = () => setLocalVideoTypes(initialVideo);
|
||||
const restoreGenres = () => setLocalGenreIds(initialGenres);
|
||||
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose} fullWidth maxWidth="sm" keepMounted>
|
||||
<DialogTitle>Filters</DialogTitle>
|
||||
<DialogContent dividers>
|
||||
<Stack spacing={1.25}>
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
"&:not(:last-of-type)": {
|
||||
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">General</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(
|
||||
[
|
||||
"isPlayed",
|
||||
"isUnPlayed",
|
||||
"isResumable",
|
||||
"isFavorite",
|
||||
] as FILTERS[]
|
||||
).map((k) => (
|
||||
<FormControlLabel
|
||||
key={k}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={!!localFilters[k]}
|
||||
onChange={() => handleToggle(k)}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={FILTER_LABELS[k]}
|
||||
/>
|
||||
))}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
|
||||
{isVideoCollection && (
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
"&:not(:last-of-type)": {
|
||||
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Video features</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(
|
||||
[
|
||||
"hasSubtitles",
|
||||
"hasTrailer",
|
||||
"hasSpecialFeature",
|
||||
"hasThemeSong",
|
||||
"hasThemeVideo",
|
||||
] as FILTERS[]
|
||||
).map((k) => (
|
||||
<FormControlLabel
|
||||
key={k}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={!!localFilters[k]}
|
||||
onChange={() => handleToggle(k)}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={FILTER_LABELS[k]}
|
||||
/>
|
||||
))}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
|
||||
{isVideoCollection && (
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
"&:not(:last-of-type)": {
|
||||
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Resolution</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(["isSD", "isHD", "is4K", "is3D"] as FILTERS[]).map(
|
||||
(k) => (
|
||||
<FormControlLabel
|
||||
key={k}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={!!localFilters[k]}
|
||||
onChange={() => handleToggle(k)}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={FILTER_LABELS[k]}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
|
||||
{isVideoCollection && (
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
"&:not(:last-of-type)": {
|
||||
borderBottom: "1px solid rgba(255,255,255,0.12)",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Media type</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(["BluRay", "Dvd", "Iso", "VideoFile"] as const).map(
|
||||
(k) => (
|
||||
<FormControlLabel
|
||||
key={k}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={!!(localVideoTypes as any)[k]}
|
||||
onChange={() =>
|
||||
setLocalVideoTypes((prev) => ({
|
||||
...(prev || {}),
|
||||
[k]: !(prev as any)?.[k],
|
||||
}))
|
||||
}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={k}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
|
||||
{/* Genres (all collection types) */}
|
||||
{(genresData?.Items?.length || 0) > 0 && (
|
||||
<Accordion
|
||||
disableGutters
|
||||
sx={{
|
||||
backgroundColor: "transparent",
|
||||
boxShadow: "none",
|
||||
m: 0,
|
||||
"&:before": { display: "none" },
|
||||
}}
|
||||
>
|
||||
<AccordionSummary
|
||||
sx={{
|
||||
minHeight: 40,
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Genres</Typography>
|
||||
</AccordionSummary>
|
||||
<AccordionDetails sx={{ px: 1.5, py: 1.25 }}>
|
||||
<FormGroup>
|
||||
{(genresData?.Items || []).map((g: any) => (
|
||||
<FormControlLabel
|
||||
key={g.Id}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={localGenreIds.includes(g.Id)}
|
||||
onChange={() =>
|
||||
setLocalGenreIds((prev) =>
|
||||
prev.includes(g.Id)
|
||||
? prev.filter((id) => id !== g.Id)
|
||||
: [...prev, g.Id],
|
||||
)
|
||||
}
|
||||
size="small"
|
||||
/>
|
||||
}
|
||||
label={g.Name}
|
||||
/>
|
||||
))}
|
||||
</FormGroup>
|
||||
</AccordionDetails>
|
||||
</Accordion>
|
||||
)}
|
||||
</Stack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={clearAll}
|
||||
color="inherit"
|
||||
disabled={Object.keys(localFilters).length === 0}
|
||||
>
|
||||
Clear
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
restore();
|
||||
restoreVideo();
|
||||
restoreGenres();
|
||||
}}
|
||||
color="inherit"
|
||||
disabled={!dirty}
|
||||
>
|
||||
Reset
|
||||
</Button>
|
||||
<Button onClick={onClose}>Cancel</Button>
|
||||
<Button onClick={apply} disabled={!dirty} variant="contained">
|
||||
Apply
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
},
|
||||
);
|
||||
(FiltersDialog as any).displayName = "FiltersDialog";
|
||||
|
||||
export const FiltersDialogTrigger: React.FC = () => {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const { id: currentLibraryId } = route.useParams();
|
||||
const { filters, videoTypesState, genreIds } = useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const slice = s.libraries[currentLibraryId || ""];
|
||||
return {
|
||||
filters: slice?.filters,
|
||||
videoTypesState: slice?.videoTypesState,
|
||||
genreIds: slice?.genreIds,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const activeCount = useMemo(() => {
|
||||
const a = Object.values(filters || {}).filter((v) => v === true).length;
|
||||
const b = Object.values(videoTypesState || {}).filter(
|
||||
(v) => v === true,
|
||||
).length;
|
||||
const c = (genreIds || []).length;
|
||||
return a + b + c;
|
||||
}, [filters, videoTypesState, genreIds]);
|
||||
return (
|
||||
<>
|
||||
<Tooltip
|
||||
title={activeCount ? `${activeCount} active filters` : "Filters"}
|
||||
>
|
||||
<IconButton
|
||||
onClick={() => setOpen(true)}
|
||||
aria-label="Open filters dialog"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded"
|
||||
style={{ position: "relative" }}
|
||||
>
|
||||
filter_list
|
||||
{activeCount > 0 && (
|
||||
<span
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: -2,
|
||||
right: -4,
|
||||
background: "#ff4081",
|
||||
color: "#fff",
|
||||
fontSize: 10,
|
||||
borderRadius: 8,
|
||||
lineHeight: 1,
|
||||
padding: "2px 4px",
|
||||
fontFamily: "Plus Jakarta Sans Variable",
|
||||
}}
|
||||
>
|
||||
{activeCount}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<FiltersDialog open={open} onClose={() => setOpen(false)} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default FiltersDialog;
|
||||
@@ -0,0 +1,362 @@
|
||||
import type { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { ItemSortBy, SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import {
|
||||
AppBar,
|
||||
Chip,
|
||||
IconButton,
|
||||
MenuItem,
|
||||
TextField,
|
||||
Typography,
|
||||
useScrollTrigger,
|
||||
} from "@mui/material";
|
||||
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { getRouteApi, useNavigate } from "@tanstack/react-router";
|
||||
import type { ChangeEvent } from "react";
|
||||
import React, { useCallback, useEffect, useMemo } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { AVAILABLE_VIEWS, SORT_BY_OPTIONS } from "@/utils/constants/library";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
// import removed: header reads name/count from Zustand slice
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
import "./libraryHeader.scss";
|
||||
import BackButton from "../buttons/backButton";
|
||||
import { FiltersDialogTrigger } from "../filtersDialog";
|
||||
import { UserAvatarMenu } from "../userAvatarMenu";
|
||||
|
||||
const route = getRouteApi("/_api/library/$id");
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
|
||||
export const LibraryHeader = () => {
|
||||
const { id: currentLibraryId } = route.useParams();
|
||||
const { api, user } = route.useRouteContext();
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
// Zustand library state (selected via shallow comparator)
|
||||
const {
|
||||
currentViewType,
|
||||
storeSortBy,
|
||||
storeSortAscending,
|
||||
filters,
|
||||
vts,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
libraryNameFromStore,
|
||||
itemsTotalCount,
|
||||
} = useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const slice = s.libraries[currentLibraryId || ""];
|
||||
return {
|
||||
currentViewType: slice?.currentViewType,
|
||||
storeSortBy: slice?.sortBy,
|
||||
storeSortAscending: slice?.sortAscending,
|
||||
filters: slice?.filters,
|
||||
vts: slice?.videoTypesState,
|
||||
nameStartsWith: slice?.nameStartsWith,
|
||||
genreIds: slice?.genreIds,
|
||||
libraryNameFromStore: slice?.libraryName,
|
||||
itemsTotalCount: slice?.itemsTotalCount,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const { initLibrary, updateLibrary } = useLibraryStateStore(
|
||||
useShallow((s) => ({
|
||||
initLibrary: s.initLibrary,
|
||||
updateLibrary: s.updateLibrary,
|
||||
})),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentLibraryId) return;
|
||||
// If the slice isn't initialized, these fields will be undefined
|
||||
if (
|
||||
currentViewType === undefined &&
|
||||
storeSortBy === undefined &&
|
||||
storeSortAscending === undefined
|
||||
) {
|
||||
initLibrary(currentLibraryId, {
|
||||
sortBy: ItemSortBy.Name,
|
||||
sortAscending: true,
|
||||
});
|
||||
}
|
||||
}, [
|
||||
currentLibraryId,
|
||||
currentViewType,
|
||||
storeSortBy,
|
||||
storeSortAscending,
|
||||
initLibrary,
|
||||
]);
|
||||
const currentLibrary = useSuspenseQuery(
|
||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||
);
|
||||
const scrollTrigger = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 20,
|
||||
});
|
||||
|
||||
const compatibleViews = useMemo(
|
||||
() =>
|
||||
AVAILABLE_VIEWS.filter((v) =>
|
||||
v.compatibleCollectionTypes.includes(
|
||||
currentLibrary.data.CollectionType as any,
|
||||
),
|
||||
),
|
||||
[currentLibrary.data.CollectionType],
|
||||
);
|
||||
// Values from store
|
||||
const sortBy = (storeSortBy ?? ItemSortBy.Name) as string;
|
||||
const sortAscending = storeSortAscending ?? true;
|
||||
const effectiveViewType = currentViewType as any;
|
||||
const effectiveSortByRaw = sortBy;
|
||||
const effectiveSortAscending = sortAscending;
|
||||
|
||||
const normalizedViewType = useMemo(() => {
|
||||
const values = compatibleViews.map((v) => v.value);
|
||||
if (effectiveViewType && values.includes(effectiveViewType as any))
|
||||
return effectiveViewType as any;
|
||||
return values[0] as BaseItemKind | "Artist";
|
||||
}, [effectiveViewType, compatibleViews]);
|
||||
|
||||
const normalizedSortBy = useMemo(() => {
|
||||
const compatibleOptions = SORT_BY_OPTIONS.filter(
|
||||
(option) =>
|
||||
option.compatibleViewTypes?.includes(normalizedViewType as any) ||
|
||||
option.compatibleCollectionTypes?.includes(
|
||||
currentLibrary.data.CollectionType as any,
|
||||
),
|
||||
);
|
||||
const compatibleValues = compatibleOptions.map((opt) =>
|
||||
Array.isArray(opt.value) ? opt.value.join(",") : String(opt.value),
|
||||
);
|
||||
const current = String(effectiveSortByRaw ?? "");
|
||||
if (current && compatibleValues.includes(current)) return current;
|
||||
return compatibleValues[0] ?? String(ItemSortBy.Name);
|
||||
}, [
|
||||
effectiveSortByRaw,
|
||||
normalizedViewType,
|
||||
currentLibrary.data.CollectionType,
|
||||
]);
|
||||
|
||||
const handleChangeViewType = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const next = e.target.value as unknown as BaseItemKind | "Artist";
|
||||
if (currentLibraryId)
|
||||
updateLibrary(currentLibraryId, { currentViewType: next });
|
||||
};
|
||||
const handleChangeSortBy = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const next = e.target.value as unknown as string;
|
||||
if (currentLibraryId) updateLibrary(currentLibraryId, { sortBy: next });
|
||||
};
|
||||
const handleSortAscendingToggle = () => {
|
||||
if (currentLibraryId)
|
||||
updateLibrary(currentLibraryId, {
|
||||
sortAscending: !effectiveSortAscending,
|
||||
});
|
||||
};
|
||||
|
||||
// (Video type multi-select temporarily removed; logic cleaned to reduce overhead.)
|
||||
|
||||
// Prefetch helpers to reduce perceived latency on sort changes
|
||||
// filters, vts, nameStartsWith, genreIds are already selected above
|
||||
// Prefetch handler will be attached on menu items below
|
||||
const prefetchItems = useCallback(
|
||||
async (sortByValue: string, asc: boolean) => {
|
||||
if (!api || !user?.Id || !currentLibraryId || !normalizedViewType) return;
|
||||
const key = [
|
||||
"library",
|
||||
"items",
|
||||
currentLibraryId,
|
||||
{
|
||||
currentViewType: normalizedViewType,
|
||||
sortAscending: asc,
|
||||
sortBy: sortByValue,
|
||||
filters,
|
||||
videoTypesState: vts,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
},
|
||||
] as const;
|
||||
await queryClient.prefetchQuery({
|
||||
queryKey: key,
|
||||
queryFn: async () => {
|
||||
const result = await getItemsApi(api).getItems({
|
||||
userId: user.Id!,
|
||||
parentId: currentLibraryId,
|
||||
recursive: true,
|
||||
includeItemTypes: [normalizedViewType as any],
|
||||
sortOrder: [asc ? SortOrder.Ascending : SortOrder.Descending],
|
||||
sortBy: String(sortByValue).split(",") as any,
|
||||
enableUserData: true,
|
||||
nameStartsWith: nameStartsWith || undefined,
|
||||
genreIds: genreIds && genreIds.length > 0 ? genreIds : undefined,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
staleTime: 5_000,
|
||||
});
|
||||
},
|
||||
[
|
||||
api,
|
||||
user?.Id,
|
||||
currentLibraryId,
|
||||
normalizedViewType,
|
||||
filters,
|
||||
vts,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
queryClient,
|
||||
],
|
||||
);
|
||||
|
||||
const disableSortOption = useMemo(
|
||||
() =>
|
||||
!normalizedViewType ||
|
||||
!SORT_BY_OPTIONS.some(
|
||||
(option) =>
|
||||
option.compatibleViewTypes?.includes(normalizedViewType as any) ||
|
||||
option.compatibleCollectionTypes?.includes(
|
||||
currentLibrary.data.CollectionType as any,
|
||||
),
|
||||
),
|
||||
[normalizedViewType, currentLibrary.data.CollectionType],
|
||||
);
|
||||
|
||||
const appBarStyling = useMemo(
|
||||
() => ({ backgroundColor: "transparent", paddingRight: "0 !important" }),
|
||||
[],
|
||||
);
|
||||
|
||||
// Read values from Zustand: name set by route, count set by grid
|
||||
const libraryName = libraryNameFromStore ?? currentLibrary.data.Name;
|
||||
const totalCount = itemsTotalCount;
|
||||
|
||||
const handleNavigateToSearch = useCallback(
|
||||
() => navigate({ to: "/search", search: { query: "" } }),
|
||||
[navigate],
|
||||
);
|
||||
const handleNavigateToHome = useCallback(
|
||||
() => navigate({ to: "/home" }),
|
||||
[navigate],
|
||||
);
|
||||
const handleNavigateToFavorite = useCallback(
|
||||
() => navigate({ to: "/favorite" }),
|
||||
[navigate],
|
||||
);
|
||||
|
||||
return (
|
||||
<AppBar
|
||||
className={
|
||||
scrollTrigger
|
||||
? "library-header scrolling flex flex-row"
|
||||
: "library-header flex flex-row"
|
||||
}
|
||||
style={appBarStyling}
|
||||
elevation={0}
|
||||
color="transparent"
|
||||
>
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton disabled>
|
||||
<div className="material-symbols-rounded">menu</div>
|
||||
</IconButton>
|
||||
<MemoizeBackButton />
|
||||
<IconButton onClick={handleNavigateToHome}>
|
||||
<div
|
||||
className={
|
||||
location.pathname === "/home"
|
||||
? "material-symbols-rounded fill"
|
||||
: "material-symbols-rounded"
|
||||
}
|
||||
>
|
||||
home
|
||||
</div>
|
||||
</IconButton>
|
||||
</div>
|
||||
<div
|
||||
className="flex flex-row library-header-center"
|
||||
style={{ gap: "0.6em" }}
|
||||
>
|
||||
<div
|
||||
className="library-title-count flex flex-row flex-align-center"
|
||||
title={`${libraryName}${typeof totalCount === "number" ? ` · ${totalCount.toLocaleString()} items` : ""}`}
|
||||
>
|
||||
<Typography variant="subtitle1" noWrap align="center">
|
||||
{libraryName}
|
||||
</Typography>
|
||||
{typeof totalCount === "number" && (
|
||||
<Chip label={totalCount} sx={{ px: 0.5, ml: 1 }} />
|
||||
)}
|
||||
</div>
|
||||
<TextField
|
||||
select
|
||||
size="small"
|
||||
value={String(normalizedViewType)}
|
||||
onChange={handleChangeViewType}
|
||||
>
|
||||
{compatibleViews.map((v) => (
|
||||
<MenuItem key={String(v.value)} value={String(v.value)}>
|
||||
{v.title}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
<IconButton
|
||||
onClick={handleSortAscendingToggle}
|
||||
aria-label="Toggle sort order"
|
||||
>
|
||||
<div
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
transform: sortAscending ? "rotateX(0deg)" : "rotateX(180deg)",
|
||||
}}
|
||||
>
|
||||
sort
|
||||
</div>
|
||||
</IconButton>
|
||||
<TextField
|
||||
select
|
||||
size="small"
|
||||
value={normalizedSortBy}
|
||||
onChange={handleChangeSortBy}
|
||||
disabled={disableSortOption}
|
||||
>
|
||||
{SORT_BY_OPTIONS.map((option) => {
|
||||
const isCompatible =
|
||||
option.compatibleViewTypes?.includes(currentViewType as any) ||
|
||||
option.compatibleCollectionTypes?.includes(
|
||||
currentLibrary.data.CollectionType as any,
|
||||
);
|
||||
if (!isCompatible) return null;
|
||||
const valueStr = Array.isArray(option.value)
|
||||
? option.value.join(",")
|
||||
: option.value;
|
||||
return (
|
||||
<MenuItem
|
||||
key={
|
||||
Array.isArray(option.value)
|
||||
? option.value.join(",")
|
||||
: option.value
|
||||
}
|
||||
value={valueStr}
|
||||
onMouseEnter={() =>
|
||||
prefetchItems(String(valueStr), sortAscending)
|
||||
}
|
||||
>
|
||||
{option.title}
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</TextField>
|
||||
<FiltersDialogTrigger />
|
||||
</div>
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton onClick={handleNavigateToSearch}>
|
||||
<div className="material-symbols-rounded">search</div>
|
||||
</IconButton>
|
||||
<IconButton onClick={handleNavigateToFavorite}>
|
||||
<div className="material-symbols-rounded">favorite</div>
|
||||
</IconButton>
|
||||
<UserAvatarMenu />
|
||||
</div>
|
||||
</AppBar>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
.library-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
inset: 1em 1em auto 1em !important;
|
||||
border-radius: 9999px;
|
||||
margin: 0 auto;
|
||||
width: fit-content;
|
||||
position: sticky;
|
||||
width: calc(100vw - 4em) !important;
|
||||
z-index: 10;
|
||||
padding: 0.25em !important;
|
||||
transition: all 0.2s ease-in-out;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
backdrop-filter: blur(40px);
|
||||
inset: -0.35em;
|
||||
pointer-events: none;
|
||||
border-radius: inherit;
|
||||
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
||||
background: rgb(0 0 0 / 0.4);
|
||||
opacity: 0;
|
||||
z-index: -1;
|
||||
transition: opacity $transition-time-fast;
|
||||
}
|
||||
|
||||
&.scrolling {
|
||||
&::after {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,239 +1,315 @@
|
||||
import {
|
||||
type BaseItemDtoQueryResult,
|
||||
type BaseItemDto,
|
||||
BaseItemKind,
|
||||
ItemFilter,
|
||||
type ItemSortBy,
|
||||
SortOrder,
|
||||
VideoType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getArtistsApi } from "@jellyfin/sdk/lib/utils/api/artists-api";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||
import { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
|
||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { getRouteApi } from "@tanstack/react-router";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import "./libraryItemsGrid.scss";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
import { getLibraryItemsQueryOptions } from "@/utils/queries/libraryItems";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
import { Card } from "../card/card";
|
||||
|
||||
const libraryRoute = getRouteApi("/_api/library/$id");
|
||||
|
||||
/**
|
||||
* Virtualized library items grid.
|
||||
* Virtualizes vertical scrolling only; items are arranged into responsive columns.
|
||||
* Assumptions:
|
||||
* - Card aspect ratio handled by CSS; we approximate a fixed height for virtualization.
|
||||
* - Width changes trigger re-measure via ResizeObserver.
|
||||
* Future improvements:
|
||||
* - Dynamic row height based on item type.
|
||||
* - Horizontal virtualization for extremely wide displays.
|
||||
*/
|
||||
const LibraryItemsGrid = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const { id: currentLibraryId } = libraryRoute.useParams();
|
||||
const {
|
||||
currentViewType,
|
||||
sortAscending = true,
|
||||
sortBy = "SortName",
|
||||
filters = {},
|
||||
videoTypesState = {},
|
||||
} = libraryRoute.useSearch();
|
||||
const currentLibraryId = libraryRoute.useParams().id;
|
||||
sortAscending,
|
||||
sortBy,
|
||||
filters,
|
||||
videoTypesState,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
} = useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const slice = s.libraries[currentLibraryId || ""];
|
||||
return {
|
||||
currentViewType: slice?.currentViewType,
|
||||
sortAscending: slice?.sortAscending ?? true,
|
||||
sortBy: slice?.sortBy ?? "Name",
|
||||
filters: slice?.filters,
|
||||
videoTypesState: slice?.videoTypesState,
|
||||
nameStartsWith: slice?.nameStartsWith,
|
||||
genreIds: slice?.genreIds,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||
const currentLibrary = useSuspenseQuery(
|
||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||
);
|
||||
const items = useSuspenseQuery({
|
||||
queryKey: [
|
||||
"library",
|
||||
"items",
|
||||
currentLibraryId,
|
||||
{
|
||||
currentViewType: currentViewType,
|
||||
sortAscending: sortAscending,
|
||||
sortBy: sortBy,
|
||||
filters,
|
||||
videoTypesState,
|
||||
// genreFilter,
|
||||
},
|
||||
],
|
||||
queryFn: async () => {
|
||||
if (!api) return null;
|
||||
let result: AxiosResponse<BaseItemDtoQueryResult, any>;
|
||||
if (currentViewType === "MusicArtist") {
|
||||
result = await getArtistsApi(api).getAlbumArtists({
|
||||
userId: user?.Id,
|
||||
parentId: currentLibraryId,
|
||||
});
|
||||
} else if (currentViewType === "Artist") {
|
||||
result = await getArtistsApi(api).getArtists({
|
||||
userId: user?.Id,
|
||||
parentId: currentLibraryId,
|
||||
});
|
||||
} else if (currentViewType === "Person") {
|
||||
result = await getPersonsApi(api).getPersons({
|
||||
userId: user?.Id,
|
||||
personTypes: ["Actor"],
|
||||
});
|
||||
} else if (currentViewType === "Studio") {
|
||||
result = await getStudiosApi(api).getStudios({
|
||||
userId: user?.Id,
|
||||
parentId: currentLibraryId,
|
||||
});
|
||||
} else if (currentViewType === "BoxSet") {
|
||||
const videoTypes: VideoType[] = [];
|
||||
if (videoTypesState.BluRay) videoTypes.push(VideoType.BluRay);
|
||||
if (videoTypesState.Dvd) videoTypes.push(VideoType.Dvd);
|
||||
if (videoTypesState.Iso) videoTypes.push(VideoType.Iso);
|
||||
if (videoTypesState.VideoFile) videoTypes.push(VideoType.VideoFile);
|
||||
|
||||
const filtersArray: ItemFilter[] = [];
|
||||
if (filters.isPlayed) filtersArray.push(ItemFilter.IsPlayed);
|
||||
if (filters.isUnPlayed) filtersArray.push(ItemFilter.IsUnplayed);
|
||||
if (filters.isResumable) filtersArray.push(ItemFilter.IsResumable);
|
||||
if (filters.isFavorite) filtersArray.push(ItemFilter.IsFavorite);
|
||||
|
||||
result = await getItemsApi(api).getItems({
|
||||
userId: user?.Id,
|
||||
parentId: currentLibraryId,
|
||||
recursive:
|
||||
currentLibrary.data.CollectionType === "boxsets" ? undefined : true,
|
||||
// includeItemTypes: [currentViewType],
|
||||
sortOrder: [
|
||||
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||
],
|
||||
sortBy: sortBy.split(",") as ItemSortBy[],
|
||||
filters: filtersArray,
|
||||
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
||||
hasTrailer: filters.hasTrailer ? true : undefined,
|
||||
hasSpecialFeature: filters.hasSpecialFeature ? true : undefined,
|
||||
hasThemeSong: filters.hasThemeSong ? true : undefined,
|
||||
hasThemeVideo: filters.hasThemeVideo ? true : undefined,
|
||||
videoTypes: videoTypes,
|
||||
isHd: filters.isSD ? true : filters.isHD || undefined,
|
||||
is4K: filters.is4K || undefined,
|
||||
is3D: filters.is3D || undefined,
|
||||
enableUserData: true,
|
||||
// genreIds: genreFilter,
|
||||
});
|
||||
} else {
|
||||
const videoTypes: VideoType[] = [];
|
||||
if (videoTypesState.BluRay) videoTypes.push(VideoType.BluRay);
|
||||
if (videoTypesState.Dvd) videoTypes.push(VideoType.Dvd);
|
||||
if (videoTypesState.Iso) videoTypes.push(VideoType.Iso);
|
||||
if (videoTypesState.VideoFile) videoTypes.push(VideoType.VideoFile);
|
||||
|
||||
const filtersArray: ItemFilter[] = [];
|
||||
if (filters.isPlayed) filtersArray.push(ItemFilter.IsPlayed);
|
||||
if (filters.isUnPlayed) filtersArray.push(ItemFilter.IsUnplayed);
|
||||
if (filters.isResumable) filtersArray.push(ItemFilter.IsResumable);
|
||||
if (filters.isFavorite) filtersArray.push(ItemFilter.IsFavorite);
|
||||
if (!currentViewType) {
|
||||
throw new Error("currentViewType is required");
|
||||
}
|
||||
result = await getItemsApi(api).getItems({
|
||||
userId: user?.Id,
|
||||
parentId: currentLibraryId,
|
||||
recursive: true,
|
||||
includeItemTypes: [currentViewType],
|
||||
sortOrder: [
|
||||
sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||
],
|
||||
sortBy: sortBy.split(",") as ItemSortBy[],
|
||||
filters: filtersArray,
|
||||
hasSubtitles: filters.hasSubtitles ? true : undefined,
|
||||
hasTrailer: filters.hasTrailer ? true : undefined,
|
||||
hasSpecialFeature: filters.hasSpecialFeature ? true : undefined,
|
||||
hasThemeSong: filters.hasThemeSong ? true : undefined,
|
||||
hasThemeVideo: filters.hasThemeVideo ? true : undefined,
|
||||
videoTypes: videoTypes,
|
||||
isHd: filters.isSD ? true : filters.isHD || undefined,
|
||||
is4K: filters.is4K || undefined,
|
||||
is3D: filters.is3D || undefined,
|
||||
enableUserData: true,
|
||||
// genreIds: genreFilter,
|
||||
});
|
||||
}
|
||||
return result.data;
|
||||
},
|
||||
networkMode: "always",
|
||||
});
|
||||
const items = useSuspenseQuery(
|
||||
getLibraryItemsQueryOptions(api, user?.Id, currentLibraryId, {
|
||||
currentViewType,
|
||||
sortAscending,
|
||||
sortBy,
|
||||
filters,
|
||||
videoTypesState,
|
||||
nameStartsWith,
|
||||
genreIds,
|
||||
collectionType: currentLibrary.data.CollectionType as any,
|
||||
}),
|
||||
);
|
||||
// --- Backdrop ---
|
||||
const setBackdrop = useBackdropStore(useShallow((s) => s.setBackdrop));
|
||||
const [currentBackdropIndex, setCurrentBackdropIndex] = useState(1);
|
||||
const backdropItems = useMemo(() => {
|
||||
if (items.isSuccess) {
|
||||
const temp = items.data?.Items?.filter(
|
||||
(item) => Object.keys(item.ImageBlurHashes?.Backdrop ?? {}).length > 0,
|
||||
);
|
||||
const backdropItem = temp?.[0];
|
||||
|
||||
const currentBackdropItemHash =
|
||||
backdropItem?.ImageBlurHashes?.Backdrop?.[
|
||||
Object.keys(backdropItem?.ImageBlurHashes?.Backdrop ?? {})[0]
|
||||
];
|
||||
setBackdrop(currentBackdropItemHash);
|
||||
|
||||
return temp;
|
||||
}
|
||||
}, [items]);
|
||||
const backdropIndexRef = useRef(0);
|
||||
const backdropItems = useMemo<BaseItemDto[]>(() => {
|
||||
if (!items.isSuccess || !items.data?.Items) return [];
|
||||
return items.data.Items.filter(
|
||||
(item) => Object.keys(item.ImageBlurHashes?.Backdrop ?? {}).length > 0,
|
||||
);
|
||||
}, [items.isSuccess, items.data?.Items]);
|
||||
useEffect(() => {
|
||||
if (backdropItems?.length === 0 || !api || !backdropItems) {
|
||||
return; // No backdrop items available
|
||||
}
|
||||
if (!api || !backdropItems || backdropItems.length === 0) return;
|
||||
// Set initial backdrop once when items change
|
||||
const firstBackdrop = backdropItems[0];
|
||||
const firstKey = Object.keys(
|
||||
firstBackdrop?.ImageBlurHashes?.Backdrop ?? {},
|
||||
)[0];
|
||||
const initialHash = firstBackdrop?.ImageBlurHashes?.Backdrop?.[firstKey];
|
||||
if (initialHash) setBackdrop(initialHash);
|
||||
backdropIndexRef.current = 0;
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
const currentBackdropItemHash =
|
||||
backdropItems[currentBackdropIndex].ImageBlurHashes?.Backdrop?.[
|
||||
Object.keys(
|
||||
backdropItems[currentBackdropIndex].ImageBlurHashes?.Backdrop ?? {},
|
||||
)[0]
|
||||
];
|
||||
if (!currentBackdropItemHash) return; // No backdrop image available
|
||||
setBackdrop(currentBackdropItemHash);
|
||||
setCurrentBackdropIndex(
|
||||
(prevIndex) => (prevIndex + 1) % backdropItems.length,
|
||||
backdropIndexRef.current =
|
||||
(backdropIndexRef.current + 1) % backdropItems.length;
|
||||
const idx = backdropIndexRef.current;
|
||||
const keys = Object.keys(
|
||||
backdropItems[idx]?.ImageBlurHashes?.Backdrop ?? {},
|
||||
);
|
||||
const nextHash = backdropItems[idx]?.ImageBlurHashes?.Backdrop?.[keys[0]];
|
||||
if (nextHash) {
|
||||
// Defer backdrop update to idle/raf to avoid blocking UI
|
||||
const schedule =
|
||||
(window as any).requestIdleCallback || window.requestAnimationFrame;
|
||||
schedule(() => setBackdrop(nextHash));
|
||||
}
|
||||
}, 10_000); // Update backdrop every 10s
|
||||
return () => clearInterval(intervalId);
|
||||
}, [backdropItems]);
|
||||
}, [api, backdropItems, setBackdrop]);
|
||||
// --- Virtualization setup ---
|
||||
const parentRef = useRef<HTMLDivElement | null>(null);
|
||||
const scrollParentRef = useRef<HTMLElement | null>(null);
|
||||
const [containerWidth, setContainerWidth] = useState<number>(0);
|
||||
|
||||
// Determine column count based on container width (simple heuristic)
|
||||
const [columns, setColumns] = useState(1);
|
||||
const measureColumns = useCallback(() => {
|
||||
if (!parentRef.current) return;
|
||||
const width = parentRef.current.clientWidth;
|
||||
setContainerWidth(width);
|
||||
// Base desired approximate card width (including gap) 180px
|
||||
const ideal = Math.max(1, Math.floor(width / 180));
|
||||
setColumns(ideal);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
measureColumns();
|
||||
if (!parentRef.current) return;
|
||||
// Find the page's scroll container ('.scrollY') to avoid nested scrolling
|
||||
scrollParentRef.current = parentRef.current.closest(
|
||||
".scrollY",
|
||||
) as HTMLElement | null;
|
||||
const ro = new ResizeObserver(() => measureColumns());
|
||||
ro.observe(parentRef.current);
|
||||
return () => ro.disconnect();
|
||||
}, [measureColumns]);
|
||||
|
||||
const itemCount = items.data?.Items?.length ?? 0;
|
||||
// Compute number of virtual rows
|
||||
const rowCount = Math.ceil(itemCount / columns);
|
||||
|
||||
// Estimated row height (depends on card type). Using 260px as base (portrait taller)
|
||||
// Compute card width minus gaps
|
||||
const cardGap = 16; // px gap between cards
|
||||
const cardWidth = useMemo(() => {
|
||||
if (columns <= 0) return 180;
|
||||
const totalGap = (columns - 1) * cardGap;
|
||||
return Math.floor((containerWidth - totalGap) / columns);
|
||||
}, [columns, containerWidth]);
|
||||
|
||||
// Approximate tallest card height (portrait ratio ~ 2:3 => height ≈ width / 0.666) + text/footer area
|
||||
// We add a small buffer (20px) for hover overlays and progress bars
|
||||
const estimatedTallCardHeight = useMemo(
|
||||
() => Math.round(cardWidth / 0.666666 + 90),
|
||||
[cardWidth],
|
||||
);
|
||||
|
||||
const estimateRowHeight = useCallback(
|
||||
() => estimatedTallCardHeight,
|
||||
[estimatedTallCardHeight],
|
||||
);
|
||||
|
||||
const virtualizer = useVirtualizer({
|
||||
count: rowCount,
|
||||
getScrollElement: () => scrollParentRef.current,
|
||||
estimateSize: estimateRowHeight,
|
||||
overscan: 2,
|
||||
});
|
||||
|
||||
const virtualItems = virtualizer.getVirtualItems();
|
||||
|
||||
// Update count in Zustand so header can display it without extra fetches
|
||||
useEffect(() => {
|
||||
const total = items.data?.TotalRecordCount;
|
||||
if (currentLibraryId && typeof total === "number") {
|
||||
updateLibrary(currentLibraryId, { itemsTotalCount: total });
|
||||
}
|
||||
}, [items.data?.TotalRecordCount, currentLibraryId, updateLibrary]);
|
||||
|
||||
return (
|
||||
<div className="library-items-container">
|
||||
{items.data?.Items?.map((item) => (
|
||||
<Card
|
||||
item={item}
|
||||
key={item?.Id}
|
||||
seriesId={item?.SeriesId}
|
||||
cardTitle={
|
||||
item?.Type === BaseItemKind.Episode ? item.SeriesName : item?.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item?.Type === BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item?.Type === BaseItemKind.Series
|
||||
? `${item.ProductionYear} - ${
|
||||
item.EndDate
|
||||
? new Date(item.EndDate).toLocaleString([], {
|
||||
year: "numeric",
|
||||
})
|
||||
: "Present"
|
||||
}`
|
||||
: item?.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item?.Type === BaseItemKind.Person ||
|
||||
item?.Type === BaseItemKind.Genre ||
|
||||
item?.Type === BaseItemKind.MusicGenre ||
|
||||
item?.Type === BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item?.Type === BaseItemKind.MusicAlbum ||
|
||||
item?.Type === BaseItemKind.Audio ||
|
||||
item?.Type === BaseItemKind.Genre ||
|
||||
item?.Type === BaseItemKind.MusicGenre ||
|
||||
item?.Type === BaseItemKind.Studio ||
|
||||
item?.Type === BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
// queryKey={items}
|
||||
userId={user?.Id}
|
||||
/>
|
||||
))}
|
||||
<div
|
||||
ref={parentRef}
|
||||
className="library-items-container virtualized"
|
||||
style={{ position: "relative" }}
|
||||
>
|
||||
{items.isSuccess && itemCount === 0 ? (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
minHeight: 240,
|
||||
width: "100%",
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<div
|
||||
className="material-symbols-rounded"
|
||||
style={{ fontSize: 48, marginBottom: 8 }}
|
||||
>
|
||||
sentiment_dissatisfied
|
||||
</div>
|
||||
<div style={{ fontSize: 16 }}>No items to show</div>
|
||||
<div style={{ fontSize: 13, marginTop: 6 }}>
|
||||
Try adjusting filters, sort, or the A–Z selector.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
style={{
|
||||
position: "relative",
|
||||
height: virtualizer.getTotalSize(),
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
{virtualItems.map((row) => {
|
||||
const startIndex = row.index * columns;
|
||||
const endIndex = Math.min(startIndex + columns, itemCount);
|
||||
return (
|
||||
<div
|
||||
key={row.key}
|
||||
style={{
|
||||
position: "absolute",
|
||||
transform: `translateY(${row.start}px)`,
|
||||
left: 0,
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "flex-start",
|
||||
gap: `${cardGap}px`,
|
||||
// Allow natural height; virtualizer will update size after measurement.
|
||||
paddingBottom: "0.6em",
|
||||
}}
|
||||
data-index={row.index}
|
||||
ref={(el) => {
|
||||
if (el) virtualizer.measureElement(el);
|
||||
}}
|
||||
>
|
||||
{items.data?.Items?.slice(startIndex, endIndex).map(
|
||||
(item: BaseItemDto, localIndex: number) => {
|
||||
return (
|
||||
<div
|
||||
key={item?.Id ?? localIndex}
|
||||
style={{
|
||||
width: `${cardWidth}px`,
|
||||
flex: "0 0 auto",
|
||||
// Override default card margins to avoid compounding with gaps
|
||||
margin: 0,
|
||||
}}
|
||||
>
|
||||
<Card
|
||||
item={item}
|
||||
seriesId={item?.SeriesId}
|
||||
skipInView
|
||||
cardTitle={
|
||||
item?.Type === BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item?.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item?.Type === BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item?.Type === BaseItemKind.Series
|
||||
? `${item.ProductionYear} - ${
|
||||
item.EndDate
|
||||
? new Date(item.EndDate).toLocaleString(
|
||||
[],
|
||||
{
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
: "Present"
|
||||
}`
|
||||
: item?.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item?.Type === BaseItemKind.Person ||
|
||||
item?.Type === BaseItemKind.Genre ||
|
||||
item?.Type === BaseItemKind.MusicGenre ||
|
||||
item?.Type === BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item?.Type === BaseItemKind.MusicAlbum ||
|
||||
item?.Type === BaseItemKind.Audio ||
|
||||
item?.Type === BaseItemKind.Genre ||
|
||||
item?.Type === BaseItemKind.MusicGenre ||
|
||||
item?.Type === BaseItemKind.Studio ||
|
||||
item?.Type === BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
userId={user?.Id}
|
||||
// Inline style overrides to neutralize original margins for virtualization
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Overrides for virtualized library items layout to prevent horizontal overflow
|
||||
.library-items-container.virtualized {
|
||||
overflow-x: hidden;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
display: block !important; // override grid from route styles
|
||||
padding: 0 !important; // override padding from route styles
|
||||
position: relative; // required for absolutely positioned rows
|
||||
gap: 0 !important;
|
||||
justify-items: normal !important;
|
||||
align-content: stretch !important;
|
||||
> .card {
|
||||
max-width: none !important;
|
||||
}
|
||||
// Ensure no unintended padding expands width
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
.card {
|
||||
margin-right: 0 !important;
|
||||
margin-bottom: 0.6em !important; // keep a consistent vertical rhythm
|
||||
}
|
||||
.card-image-container {
|
||||
// Remove box shadow spread from affecting layout width calculation
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
// When page has audio-playing class, avoid extra bottom padding causing scrollbars
|
||||
.audio-playing .library-items-container.virtualized {
|
||||
padding-bottom: 8em; // mimic original intent without affecting width
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { useScrollTrigger } from "@mui/material";
|
||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||
import { getRouteApi, useNavigate } from "@tanstack/react-router";
|
||||
import React, { type ChangeEvent, useMemo } from "react";
|
||||
import {
|
||||
AVAILABLE_VIEWS,
|
||||
type FILTERS,
|
||||
SORT_BY_OPTIONS,
|
||||
} from "@/utils/constants/library";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
|
||||
const route = getRouteApi("/_api/library/$id");
|
||||
|
||||
const LibraryMenu = () => {
|
||||
const { currentViewType, sortAscending, filters, sortBy } = route.useSearch();
|
||||
const { id: currentLibraryId } = route.useParams();
|
||||
const { api, user } = route.useRouteContext();
|
||||
const currentLibrary = useSuspenseQuery(
|
||||
getLibraryQueryOptions(api, user?.Id, currentLibraryId),
|
||||
);
|
||||
const scrollTrigger = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 20,
|
||||
});
|
||||
const navigate = useNavigate();
|
||||
const _handleSortAsecendingToggle = () => {
|
||||
navigate({
|
||||
search: {
|
||||
sortAscending: !sortAscending,
|
||||
sortBy,
|
||||
},
|
||||
to: "/library/$id",
|
||||
params: {
|
||||
id: currentLibraryId ?? "",
|
||||
},
|
||||
});
|
||||
};
|
||||
const _handleChangeSortBy = () => {
|
||||
navigate({
|
||||
search: {
|
||||
sortBy,
|
||||
},
|
||||
to: "/library/$id",
|
||||
params: {
|
||||
id: currentLibraryId ?? "",
|
||||
},
|
||||
});
|
||||
};
|
||||
const _handleChangeCurrentViewType = (viewType: BaseItemKind) => {
|
||||
navigate({
|
||||
search: {
|
||||
currentViewType: viewType,
|
||||
},
|
||||
to: "/library/$id",
|
||||
params: {
|
||||
id: currentLibraryId ?? "",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const [filterButtonAnchorEl, setFilterButtonAnchorEl] =
|
||||
React.useState<null | HTMLElement>(null);
|
||||
const _filterMenuOpen = useMemo(
|
||||
() => Boolean(filterButtonAnchorEl),
|
||||
[filterButtonAnchorEl],
|
||||
);
|
||||
const _handleFilterDropdown = (event: React.MouseEvent<HTMLElement>) => {
|
||||
setFilterButtonAnchorEl(event.currentTarget);
|
||||
};
|
||||
|
||||
const _handleFilterChange = (key: FILTERS, value: boolean) => {
|
||||
// Update filter state and navigate
|
||||
navigate({
|
||||
search: {
|
||||
filters: { ...filters, [key]: value },
|
||||
},
|
||||
to: "/library/$id",
|
||||
params: {
|
||||
id: currentLibraryId ?? "",
|
||||
},
|
||||
});
|
||||
// Close the filter menu
|
||||
setFilterButtonAnchorEl(null);
|
||||
};
|
||||
|
||||
const _disableSortOption = useMemo(() => {
|
||||
return (
|
||||
!currentViewType ||
|
||||
!SORT_BY_OPTIONS.some(
|
||||
(option) =>
|
||||
option.compatibleViewTypes?.includes(currentViewType as any) ||
|
||||
option.compatibleCollectionTypes?.includes(
|
||||
currentLibrary.data.CollectionType as any,
|
||||
),
|
||||
)
|
||||
);
|
||||
}, [currentViewType, currentLibrary.data.CollectionType]);
|
||||
const _disableFilters = useMemo(() => {
|
||||
switch (currentViewType) {
|
||||
case BaseItemKind.Movie:
|
||||
case BaseItemKind.Audio:
|
||||
case BaseItemKind.Series:
|
||||
case BaseItemKind.BoxSet:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}, [currentViewType]);
|
||||
|
||||
if (!filters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
scrollTrigger
|
||||
? "library-items-header glass scrolling"
|
||||
: "library-items-header"
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default LibraryMenu;
|
||||
@@ -0,0 +1,144 @@
|
||||
import {
|
||||
Avatar,
|
||||
Divider,
|
||||
IconButton,
|
||||
ListItemIcon,
|
||||
Menu,
|
||||
MenuItem,
|
||||
} from "@mui/material";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useNavigate, useRouter } from "@tanstack/react-router";
|
||||
import React, {
|
||||
type MouseEventHandler,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
|
||||
export const UserAvatarMenu = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
const [user, resetCurrentUser] = useCentralStore((s) => [
|
||||
s.currentUser,
|
||||
s.resetCurrentUser,
|
||||
]);
|
||||
const navigate = useNavigate();
|
||||
const router = useRouter();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
||||
const openMenu = Boolean(anchorEl);
|
||||
|
||||
const handleMenuOpen: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||
(event) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const handleMenuClose = useCallback(() => {
|
||||
setAnchorEl(null);
|
||||
}, []);
|
||||
|
||||
const handleLogout = useCallback(async () => {
|
||||
console.log("Logging out user...");
|
||||
await api?.logout();
|
||||
createApi(api?.basePath ?? "", undefined);
|
||||
resetCurrentUser();
|
||||
delUser();
|
||||
sessionStorage.removeItem("accessToken");
|
||||
queryClient.clear();
|
||||
await router.invalidate();
|
||||
setAnchorEl(null);
|
||||
navigate({ to: "/login", replace: true });
|
||||
}, [api, createApi, navigate, queryClient, resetCurrentUser, router]);
|
||||
|
||||
const menuButtonSx = useMemo(() => ({ p: 0 }), []);
|
||||
const menuStyle = useMemo(() => ({ mt: 2 }), []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<IconButton sx={menuButtonSx} onClick={handleMenuOpen}>
|
||||
{!!user?.Id &&
|
||||
(user?.PrimaryImageTag === undefined ? (
|
||||
<Avatar className="appBar-avatar" alt={user?.Name ?? "image"}>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
) : (
|
||||
<Avatar
|
||||
className="appBar-avatar"
|
||||
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
||||
alt={user?.Name ?? "image"}
|
||||
>
|
||||
<span className="material-symbols-rounded appBar-avatar-icon">
|
||||
account_circle
|
||||
</span>
|
||||
</Avatar>
|
||||
))}
|
||||
</IconButton>
|
||||
<Menu
|
||||
anchorEl={anchorEl}
|
||||
open={openMenu}
|
||||
onClose={handleMenuClose}
|
||||
sx={menuStyle}
|
||||
disableScrollLock
|
||||
>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
handleLogout();
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">logout</div>
|
||||
</ListItemIcon>
|
||||
Logout
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
setSettingsTabValue(1);
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">settings</div>
|
||||
</ListItemIcon>
|
||||
Settings
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/preferences" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">tune</div>
|
||||
</ListItemIcon>
|
||||
Preferences
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/about" });
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">info</div>
|
||||
</ListItemIcon>
|
||||
About
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -190,10 +190,7 @@ function Home() {
|
||||
disableOverlay
|
||||
onClick={() => {
|
||||
if (item.Id) {
|
||||
navigate({
|
||||
to: "/library/$id",
|
||||
params: { id: item.Id },
|
||||
});
|
||||
navigate({ to: "/library/$id", params: { id: item.Id } });
|
||||
}
|
||||
}}
|
||||
overrideIcon={item.CollectionType}
|
||||
@@ -209,9 +206,7 @@ function Home() {
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{upNextItems.isSuccess && !upNextItems.data?.TotalRecordCount ? (
|
||||
<></>
|
||||
) : (
|
||||
{upNextItems.isSuccess && !upNextItems.data?.TotalRecordCount && (
|
||||
<CardScroller displayCards={4} title="Up Next">
|
||||
{upNextItems.data?.Items?.map((item) => {
|
||||
return (
|
||||
|
||||
+74
-139
@@ -1,17 +1,19 @@
|
||||
import { BaseItemKind, ItemSortBy } from "@jellyfin/sdk/lib/generated-client";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||
import React, { Suspense } from "react";
|
||||
import React, { Suspense, useEffect } from "react";
|
||||
import "./library.scss";
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import { z } from "zod";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { AlphaSelector } from "@/components/alphaSelector";
|
||||
import { LibraryHeader } from "@/components/libraryHeader";
|
||||
import LibraryItemsGrid from "@/components/libraryItemsGrid";
|
||||
import LibraryMenu from "@/components/libraryMenu";
|
||||
import LibraryItemsSkeleton from "@/components/skeleton/libraryItems";
|
||||
import { getDefaultSortByForCollectionType } from "@/utils/constants/library";
|
||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import useHeaderStore from "@/utils/store/header";
|
||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||
|
||||
// type SortByObject = { title: string; value: string };
|
||||
// type ViewObject = { title: string; value: BaseItemKind | "Artist" };
|
||||
@@ -19,107 +21,6 @@ import { useCentralStore } from "@/utils/store/central";
|
||||
|
||||
export const Route = createFileRoute("/_api/library/$id")({
|
||||
component: Library,
|
||||
validateSearch: z.object({
|
||||
sortBy: z.optional(z.enum(ItemSortBy)),
|
||||
sortAscending: z.optional(z.boolean()),
|
||||
currentViewType: z.optional(
|
||||
z.union([z.enum(BaseItemKind), z.literal("Artist")]),
|
||||
),
|
||||
filters: z.optional(
|
||||
z.object({
|
||||
isPlayed: z.optional(z.boolean()),
|
||||
isUnPlayed: z.optional(z.boolean()),
|
||||
isResumable: z.optional(z.boolean()),
|
||||
isFavorite: z.optional(z.boolean()),
|
||||
hasSubtitles: z.optional(z.boolean()),
|
||||
hasTrailer: z.optional(z.boolean()),
|
||||
hasSpecialFeature: z.optional(z.boolean()),
|
||||
hasThemeSong: z.optional(z.boolean()),
|
||||
hasThemeVideo: z.optional(z.boolean()),
|
||||
isSD: z.optional(z.boolean()),
|
||||
isHD: z.optional(z.boolean()),
|
||||
is4K: z.optional(z.boolean()),
|
||||
is3D: z.optional(z.boolean()),
|
||||
}),
|
||||
),
|
||||
videoTypesState: z.optional(
|
||||
z.object({
|
||||
BluRay: z.optional(z.boolean()),
|
||||
Dvd: z.optional(z.boolean()),
|
||||
Iso: z.optional(z.boolean()),
|
||||
VideoFile: z.optional(z.boolean()),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
loaderDeps: ({ search }) => ({
|
||||
...search,
|
||||
}),
|
||||
loader: async ({
|
||||
context: { queryClient, api, user },
|
||||
params,
|
||||
deps: { ...search },
|
||||
}) => {
|
||||
if (!api || !user?.Id) return null;
|
||||
|
||||
if (Object.keys(search).length > 0) {
|
||||
console.log("Using search params:", search);
|
||||
// If search is not empty, ensure the library data is fetched
|
||||
return await queryClient.ensureQueryData(
|
||||
getLibraryQueryOptions(api, user.Id, params.id),
|
||||
);
|
||||
}
|
||||
const cachedSearch = sessionStorage.getItem(`library-${params.id}-config`);
|
||||
if (cachedSearch) {
|
||||
console.log("Using cached search params:", cachedSearch);
|
||||
throw redirect({
|
||||
to: "/library/$id",
|
||||
params: { id: params.id },
|
||||
search: JSON.parse(cachedSearch),
|
||||
replace: true,
|
||||
});
|
||||
}
|
||||
|
||||
// Priority 3: No params anywhere, fetch the initial type to create them
|
||||
const initialData = await queryClient.ensureQueryData(
|
||||
getLibraryQueryOptions(api, user.Id, params.id),
|
||||
);
|
||||
|
||||
// Now, redirect to the URL with the new initial params
|
||||
throw redirect({
|
||||
to: "/library/$id",
|
||||
search: {
|
||||
sortAscending: true,
|
||||
sortBy: ItemSortBy.Name,
|
||||
currentViewType:
|
||||
initialData?.CollectionType === "music"
|
||||
? BaseItemKind.MusicAlbum
|
||||
: BaseItemKind.Movie,
|
||||
filters: {
|
||||
isPlayed: false,
|
||||
isUnPlayed: false,
|
||||
isResumable: false,
|
||||
isFavorite: false,
|
||||
hasSubtitles: false,
|
||||
hasTrailer: false,
|
||||
hasSpecialFeature: false,
|
||||
hasThemeSong: false,
|
||||
hasThemeVideo: false,
|
||||
isSD: false,
|
||||
isHD: undefined,
|
||||
is4K: false,
|
||||
is3D: false,
|
||||
},
|
||||
videoTypesState: {
|
||||
BluRay: false,
|
||||
Dvd: false,
|
||||
Iso: false,
|
||||
VideoFile: false,
|
||||
},
|
||||
},
|
||||
params: { id: params.id },
|
||||
replace: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
function Library() {
|
||||
@@ -132,45 +33,79 @@ function Library() {
|
||||
const currentLib = useSuspenseQuery(
|
||||
getLibraryQueryOptions(api, user?.Id, id),
|
||||
);
|
||||
const initLibrary = useLibraryStateStore((s) => s.initLibrary);
|
||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||
const { currentViewType: storeViewType, libraryName: storeLibraryName } =
|
||||
useLibraryStateStore(
|
||||
useShallow((s) => {
|
||||
const sl = s.libraries[id || ""];
|
||||
return {
|
||||
currentViewType: sl?.currentViewType,
|
||||
libraryName: sl?.libraryName,
|
||||
} as const;
|
||||
}),
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!id || !currentLib.data) return;
|
||||
// Ensure library name is available in Zustand for header consumption
|
||||
updateLibrary(id, { libraryName: currentLib.data.Name ?? undefined });
|
||||
const collectionType = currentLib.data.CollectionType;
|
||||
|
||||
const detectedViewType: BaseItemKind | "Artist" =
|
||||
collectionType === "music"
|
||||
? BaseItemKind.MusicAlbum
|
||||
: collectionType === "movies"
|
||||
? BaseItemKind.Movie
|
||||
: collectionType === "tvshows"
|
||||
? BaseItemKind.Series
|
||||
: collectionType === "boxsets"
|
||||
? BaseItemKind.BoxSet
|
||||
: collectionType === "books"
|
||||
? BaseItemKind.Book
|
||||
: collectionType === "playlists"
|
||||
? BaseItemKind.Playlist
|
||||
: BaseItemKind.Movie;
|
||||
|
||||
// Initialize defaults if state not yet set
|
||||
if (storeViewType === undefined) {
|
||||
initLibrary(id, {
|
||||
currentViewType: detectedViewType,
|
||||
sortBy:
|
||||
getDefaultSortByForCollectionType(collectionType as any) ||
|
||||
ItemSortBy.Name,
|
||||
sortAscending: true,
|
||||
});
|
||||
}
|
||||
}, [id, storeViewType, initLibrary, updateLibrary, currentLib.data]);
|
||||
|
||||
const { setPageTitle } = useHeaderStore(
|
||||
useShallow((state) => ({
|
||||
setPageTitle: state.setPageTitle,
|
||||
})),
|
||||
);
|
||||
// Derive top app title from Zustand slice (library name)
|
||||
useEffect(() => {
|
||||
const title = storeLibraryName ?? "Library";
|
||||
setPageTitle(title);
|
||||
}, [storeLibraryName, setPageTitle]);
|
||||
|
||||
/* if (!id) {
|
||||
// show loading if any route param is missing
|
||||
return <LoadingIndicator />;
|
||||
} */
|
||||
|
||||
return (
|
||||
<main className="scrollY library padded-top">
|
||||
<div
|
||||
style={{
|
||||
padding: "1em 1em 1em 0.6em",
|
||||
height: "4.4em",
|
||||
zIndex: "10",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-start",
|
||||
position: "absolute",
|
||||
top: "0px",
|
||||
left: "50%",
|
||||
transform: "translate(-50%)",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
width: "fit-content",
|
||||
padding: "0 1em",
|
||||
}}
|
||||
>
|
||||
<Typography variant="h5" sx={{ mr: 2, flexShrink: 0 }} noWrap>
|
||||
{currentLib.isPending ? (
|
||||
<CircularProgress sx={{ p: 1 }} />
|
||||
) : (
|
||||
currentLib.data?.Name
|
||||
)}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
<LibraryHeader />
|
||||
|
||||
<Suspense fallback={<LibraryItemsSkeleton />}>
|
||||
<div className="library-items">
|
||||
<LibraryMenu />
|
||||
<LibraryItemsGrid />
|
||||
</div>
|
||||
<div style={{ position: "fixed", right: 14, top: 80 }}>
|
||||
<AlphaSelector />
|
||||
</div>
|
||||
</Suspense>
|
||||
</main>
|
||||
);
|
||||
|
||||
@@ -54,10 +54,10 @@
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 1.5em $page-margin;
|
||||
padding-top: 4em;
|
||||
// padding-top: 4em;
|
||||
&-header {
|
||||
position: fixed;
|
||||
top: 4.4em;
|
||||
top: 1em;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -67,12 +67,11 @@
|
||||
transform: translate(-50%);
|
||||
border-radius: 100px;
|
||||
overflow: hidden;
|
||||
transition: $transition-time-default;
|
||||
transition: background $transition-time-default, box-shadow $transition-time-default;
|
||||
z-index: 1000;
|
||||
&.scrolling {
|
||||
background: rgb(0 0 0 / 0.4) !important;
|
||||
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
||||
top: 1em;
|
||||
}
|
||||
}
|
||||
&-options {
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { Chip, Typography } from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
import { Chip, Typography } from "@mui/material";
|
||||
|
||||
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice.jsx";
|
||||
import "./login.scss";
|
||||
|
||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useBackdropStore } from "@/utils/store/backdrop.js";
|
||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { Link, createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
import avatar from "../../../assets/icons/avatar.png";
|
||||
|
||||
@@ -44,7 +41,7 @@ const UserCard = ({ user }: { user: UserDto }) => {
|
||||
</Typography>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function LoginPublicUsersList() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
@@ -61,7 +58,7 @@ function LoginPublicUsersList() {
|
||||
|
||||
const setBackdrop = useBackdropStore((state) => state.setBackdrop);
|
||||
useEffect(() => {
|
||||
setBackdrop("", "");
|
||||
setBackdrop("");
|
||||
}, []);
|
||||
|
||||
if (users.isSuccess) {
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import {
|
||||
clrBackgroundDefault,
|
||||
clrSecondaryDefault, //@ts-ignore
|
||||
} from "./palette.module.scss";
|
||||
|
||||
const { palette } = createTheme({});
|
||||
const { augmentColor } = palette;
|
||||
export const theme = createTheme({
|
||||
@@ -23,7 +24,7 @@ export const theme = createTheme({
|
||||
default: clrBackgroundDefault,
|
||||
paper: clrBackgroundDark,
|
||||
},
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
white: augmentColor({ color: { main: "#ffffff" } }),
|
||||
black: augmentColor({ color: { main: "#000" } }),
|
||||
mode: "dark",
|
||||
|
||||
@@ -173,14 +173,14 @@ export const SORT_BY_OPTIONS: Array<{
|
||||
title: "Random",
|
||||
value: ItemSortBy.Random,
|
||||
compatibleViewTypes: [
|
||||
BaseItemKind.MusicAlbum,
|
||||
BaseItemKind.Audio,
|
||||
BaseItemKind.Playlist,
|
||||
// BaseItemKind.MusicAlbum,
|
||||
// BaseItemKind.Audio,
|
||||
// BaseItemKind.Playlist,
|
||||
],
|
||||
compatibleCollectionTypes: [
|
||||
CollectionType.Movies,
|
||||
CollectionType.Tvshows,
|
||||
CollectionType.Boxsets,
|
||||
// CollectionType.Movies,
|
||||
// CollectionType.Tvshows,
|
||||
// CollectionType.Boxsets,
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -242,6 +242,18 @@ export const SORT_BY_OPTIONS: Array<{
|
||||
},
|
||||
];
|
||||
|
||||
export const getDefaultSortByForCollectionType = (
|
||||
collectionType: CollectionType,
|
||||
): ItemSortBy => {
|
||||
const option = SORT_BY_OPTIONS.find((opt) =>
|
||||
opt.compatibleCollectionTypes?.includes(collectionType),
|
||||
);
|
||||
return Array.isArray(option?.value)
|
||||
? option.value[0]
|
||||
: option?.value || ItemSortBy.SortName;
|
||||
};
|
||||
|
||||
|
||||
export type FILTERS =
|
||||
| "isPlayed"
|
||||
| "isUnPlayed"
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Deprecated: navigation helpers for search-param based library state were removed.
|
||||
// This file will be removed in a future commit. No exports remain.
|
||||
|
||||
export {}; // keep as empty module
|
||||
@@ -23,4 +23,5 @@ export const getLibraryQueryOptions = (
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: !!api && !!userId,
|
||||
});
|
||||
@@ -0,0 +1,174 @@
|
||||
import type { Api } from "@jellyfin/sdk";
|
||||
import type {
|
||||
BaseItemDtoQueryResult,
|
||||
BaseItemKind,
|
||||
ItemSortBy,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import {
|
||||
ItemFilter,
|
||||
SortOrder,
|
||||
VideoType,
|
||||
} from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getArtistsApi } from "@jellyfin/sdk/lib/utils/api/artists-api";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||
import { getStudiosApi } from "@jellyfin/sdk/lib/utils/api/studios-api";
|
||||
import { queryOptions } from "@tanstack/react-query";
|
||||
|
||||
export interface LibraryItemsParams {
|
||||
currentViewType?:
|
||||
| BaseItemKind
|
||||
| "Artist"
|
||||
| "Person"
|
||||
| "Studio"
|
||||
| "MusicArtist"
|
||||
| "BoxSet";
|
||||
sortAscending: boolean;
|
||||
sortBy: string; // comma separated
|
||||
filters?: Record<string, boolean | undefined>;
|
||||
videoTypesState?: {
|
||||
BluRay?: boolean;
|
||||
Dvd?: boolean;
|
||||
Iso?: boolean;
|
||||
VideoFile?: boolean;
|
||||
};
|
||||
nameStartsWith?: string;
|
||||
genreIds?: string[];
|
||||
collectionType?: string; // from library metadata (e.g. boxsets)
|
||||
limit?: number; // optional (e.g. 0 for count-only)
|
||||
}
|
||||
|
||||
/** Build TanStack Query options for fetching library items with unified branching logic. */
|
||||
export const getLibraryItemsQueryOptions = (
|
||||
api: Api | null | undefined,
|
||||
userId: string | null | undefined,
|
||||
libraryId: string | null | undefined,
|
||||
params: LibraryItemsParams,
|
||||
) => {
|
||||
return queryOptions<BaseItemDtoQueryResult>({
|
||||
queryKey: [
|
||||
"library",
|
||||
"items",
|
||||
libraryId,
|
||||
{
|
||||
currentViewType: params.currentViewType,
|
||||
sortAscending: params.sortAscending,
|
||||
sortBy: params.sortBy,
|
||||
filters: params.filters,
|
||||
videoTypesState: params.videoTypesState,
|
||||
nameStartsWith: params.nameStartsWith,
|
||||
genreIds: params.genreIds,
|
||||
collectionType: params.collectionType,
|
||||
limit: params.limit,
|
||||
},
|
||||
],
|
||||
queryFn: async () => {
|
||||
if (!api || !userId || !libraryId || !params.currentViewType) {
|
||||
return { Items: [], TotalRecordCount: 0 } as BaseItemDtoQueryResult;
|
||||
}
|
||||
const { currentViewType, videoTypesState, filters } = params;
|
||||
const buildVideoTypes = (state: typeof videoTypesState) => {
|
||||
const videoTypes: VideoType[] = [];
|
||||
if (state?.BluRay) videoTypes.push(VideoType.BluRay);
|
||||
if (state?.Dvd) videoTypes.push(VideoType.Dvd);
|
||||
if (state?.Iso) videoTypes.push(VideoType.Iso);
|
||||
if (state?.VideoFile) videoTypes.push(VideoType.VideoFile);
|
||||
return videoTypes;
|
||||
};
|
||||
const buildFilters = (f: typeof filters) => {
|
||||
const filtersArray: ItemFilter[] = [];
|
||||
if (f?.isPlayed) filtersArray.push(ItemFilter.IsPlayed);
|
||||
if (f?.isUnPlayed) filtersArray.push(ItemFilter.IsUnplayed);
|
||||
if (f?.isResumable) filtersArray.push(ItemFilter.IsResumable);
|
||||
if (f?.isFavorite) filtersArray.push(ItemFilter.IsFavorite);
|
||||
return filtersArray;
|
||||
};
|
||||
let result: { data: BaseItemDtoQueryResult };
|
||||
if (currentViewType === "MusicArtist") {
|
||||
result = await getArtistsApi(api).getAlbumArtists({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
limit: params.limit,
|
||||
});
|
||||
} else if (currentViewType === "Artist") {
|
||||
result = await getArtistsApi(api).getArtists({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
limit: params.limit,
|
||||
});
|
||||
} else if (currentViewType === "Person") {
|
||||
result = await getPersonsApi(api).getPersons({
|
||||
userId: userId,
|
||||
personTypes: ["Actor"],
|
||||
limit: params.limit,
|
||||
});
|
||||
} else if (currentViewType === "Studio") {
|
||||
result = await getStudiosApi(api).getStudios({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
limit: params.limit,
|
||||
});
|
||||
} else if (currentViewType === "BoxSet") {
|
||||
result = await getItemsApi(api).getItems({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
recursive: params.collectionType === "boxsets" ? undefined : true,
|
||||
sortOrder: [
|
||||
params.sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||
],
|
||||
sortBy: params.sortBy.split(",") as ItemSortBy[],
|
||||
filters: buildFilters(filters),
|
||||
hasSubtitles: filters?.hasSubtitles ? true : undefined,
|
||||
hasTrailer: filters?.hasTrailer ? true : undefined,
|
||||
hasSpecialFeature: filters?.hasSpecialFeature ? true : undefined,
|
||||
hasThemeSong: filters?.hasThemeSong ? true : undefined,
|
||||
hasThemeVideo: filters?.hasThemeVideo ? true : undefined,
|
||||
videoTypes: buildVideoTypes(videoTypesState),
|
||||
isHd: filters?.isSD ? true : filters?.isHD || undefined,
|
||||
is4K: filters?.is4K || undefined,
|
||||
is3D: filters?.is3D || undefined,
|
||||
enableUserData: true,
|
||||
nameStartsWith: params.nameStartsWith || undefined,
|
||||
genreIds:
|
||||
params.genreIds && params.genreIds.length > 0
|
||||
? params.genreIds
|
||||
: undefined,
|
||||
limit: params.limit,
|
||||
});
|
||||
} else {
|
||||
result = await getItemsApi(api).getItems({
|
||||
userId: userId,
|
||||
parentId: libraryId,
|
||||
recursive: true,
|
||||
includeItemTypes: [currentViewType],
|
||||
sortOrder: [
|
||||
params.sortAscending ? SortOrder.Ascending : SortOrder.Descending,
|
||||
],
|
||||
sortBy: params.sortBy.split(",") as ItemSortBy[],
|
||||
filters: buildFilters(filters),
|
||||
hasSubtitles: filters?.hasSubtitles ? true : undefined,
|
||||
hasTrailer: filters?.hasTrailer ? true : undefined,
|
||||
hasSpecialFeature: filters?.hasSpecialFeature ? true : undefined,
|
||||
hasThemeSong: filters?.hasThemeSong ? true : undefined,
|
||||
hasThemeVideo: filters?.hasThemeVideo ? true : undefined,
|
||||
videoTypes: buildVideoTypes(videoTypesState),
|
||||
isHd: filters?.isSD ? true : filters?.isHD || undefined,
|
||||
is4K: filters?.is4K || undefined,
|
||||
is3D: filters?.is3D || undefined,
|
||||
enableUserData: true,
|
||||
nameStartsWith: params.nameStartsWith || undefined,
|
||||
genreIds:
|
||||
params.genreIds && params.genreIds.length > 0
|
||||
? params.genreIds
|
||||
: undefined,
|
||||
limit: params.limit,
|
||||
});
|
||||
}
|
||||
return result.data;
|
||||
},
|
||||
staleTime: 5_000,
|
||||
gcTime: 5 * 60_000,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
// Deprecated: Router search schema removed in favor of Zustand store.
|
||||
// This file will be removed in a future commit. No exports remain.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
type HeaderStoreType = {
|
||||
pageTitle: string | null;
|
||||
setPageTitle: (title: string | null) => void;
|
||||
};
|
||||
|
||||
const useHeaderStore = create<HeaderStoreType>((set) => ({
|
||||
pageTitle: null,
|
||||
setPageTitle: (title: string | null) => set(() => ({ pageTitle: title })),
|
||||
}));
|
||||
|
||||
export default useHeaderStore;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Deprecated: Draft store replaced by unified library state store in Zustand.
|
||||
// This file will be removed in a future commit. No exports remain.
|
||||
|
||||
export {}; // ensure this is a module with no exports
|
||||
@@ -0,0 +1,87 @@
|
||||
import type { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { create } from "zustand";
|
||||
import { createJSONStorage, persist } from "zustand/middleware";
|
||||
|
||||
export type VideoTypesState = {
|
||||
BluRay?: boolean;
|
||||
Dvd?: boolean;
|
||||
Iso?: boolean;
|
||||
VideoFile?: boolean;
|
||||
};
|
||||
|
||||
export type FiltersState = Record<string, boolean | undefined>;
|
||||
|
||||
export interface LibraryStateSlice {
|
||||
currentViewType?: BaseItemKind | "Artist";
|
||||
sortBy: string; // comma joined for multi-key
|
||||
sortAscending: boolean;
|
||||
nameStartsWith?: string;
|
||||
genreIds: string[];
|
||||
filters: FiltersState;
|
||||
videoTypesState: VideoTypesState;
|
||||
libraryName?: string;
|
||||
itemsTotalCount?: number;
|
||||
}
|
||||
|
||||
export interface LibraryStateStore {
|
||||
libraries: Record<string, LibraryStateSlice>;
|
||||
initLibrary: (
|
||||
libraryId: string,
|
||||
defaults: Partial<LibraryStateSlice>,
|
||||
) => void;
|
||||
updateLibrary: (
|
||||
libraryId: string,
|
||||
partial: Partial<LibraryStateSlice>,
|
||||
) => void;
|
||||
resetLibrary: (libraryId: string) => void;
|
||||
}
|
||||
|
||||
const defaultSlice: LibraryStateSlice = {
|
||||
currentViewType: undefined,
|
||||
sortBy: "Name",
|
||||
sortAscending: true,
|
||||
nameStartsWith: undefined,
|
||||
genreIds: [],
|
||||
filters: {},
|
||||
videoTypesState: {},
|
||||
libraryName: undefined,
|
||||
itemsTotalCount: undefined,
|
||||
};
|
||||
|
||||
export const useLibraryStateStore = create<LibraryStateStore>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
libraries: {},
|
||||
initLibrary: (libraryId, defaults) =>
|
||||
set((s) => {
|
||||
if (s.libraries[libraryId]) return s; // already initialized
|
||||
return {
|
||||
libraries: {
|
||||
...s.libraries,
|
||||
[libraryId]: { ...defaultSlice, ...defaults },
|
||||
},
|
||||
};
|
||||
}),
|
||||
updateLibrary: (libraryId, partial) =>
|
||||
set((s) => ({
|
||||
libraries: {
|
||||
...s.libraries,
|
||||
[libraryId]: {
|
||||
...(s.libraries[libraryId] || defaultSlice),
|
||||
...partial,
|
||||
},
|
||||
},
|
||||
})),
|
||||
resetLibrary: (libraryId) =>
|
||||
set((s) => ({
|
||||
libraries: { ...s.libraries, [libraryId]: { ...defaultSlice } },
|
||||
})),
|
||||
}),
|
||||
{
|
||||
name: "blink-library-state",
|
||||
storage: createJSONStorage(() => sessionStorage),
|
||||
partialize: (state) => ({ libraries: state.libraries }),
|
||||
version: 1,
|
||||
},
|
||||
),
|
||||
);
|
||||
Reference in new issue
Block a user