feat: add new search dialog

This commit is contained in:
--remove-section committed 2026-01-17 19:30:43 +05:30
1 parent cf1f3c772d
commit 79c70e6d46
17 files changed
+751 -7

No files matched your search

+1
View File
@@ -38,6 +38,7 @@
"@tauri-apps/api": "2.9.1",
"@tauri-apps/plugin-clipboard-manager": "2.3.2",
"@tauri-apps/plugin-dialog": "2.5.0",
"@tauri-apps/plugin-global-shortcut": "~2.3.1",
"@tauri-apps/plugin-notification": "2.3.3",
"@tauri-apps/plugin-process": "2.3.1",
"@tauri-apps/plugin-store": "github:tauri-apps/tauri-plugin-store#v2",
+10
View File
@@ -83,6 +83,9 @@ importers:
'@tauri-apps/plugin-dialog':
specifier: 2.5.0
version: 2.5.0
'@tauri-apps/plugin-global-shortcut':
specifier: ~2.3.1
version: 2.3.1
'@tauri-apps/plugin-notification':
specifier: 2.3.3
version: 2.3.3
@@ -1490,6 +1493,9 @@ packages:
'@tauri-apps/plugin-dialog@2.5.0':
resolution: {integrity: sha512-I0R0ygwRd9AN8Wj5GnzCogOlqu2+OWAtBd0zEC4+kQCI32fRowIyuhPCBoUv4h/lQt2bM39kHlxPHD5vDcFjiA==}
'@tauri-apps/plugin-global-shortcut@2.3.1':
resolution: {integrity: sha512-vr40W2N6G63dmBPaha1TsBQLLURXG538RQbH5vAm0G/ovVZyXJrmZR1HF1W+WneNloQvwn4dm8xzwpEXRW560g==}
'@tauri-apps/plugin-http@2.5.5':
resolution: {integrity: sha512-4hTS7AIBLmj8opDM3s8muEp7PBJQEiGDFvFF4fdMscQCOwhzXJf5hIZEHC867eH2Ck145Oce+H0AU0G/k9TbNg==}
@@ -4297,6 +4303,10 @@ snapshots:
dependencies:
'@tauri-apps/api': 2.9.1
'@tauri-apps/plugin-global-shortcut@2.3.1':
dependencies:
'@tauri-apps/api': 2.9.1
'@tauri-apps/plugin-http@2.5.5':
dependencies:
'@tauri-apps/api': 2.9.1
+40
View File
@@ -334,6 +334,7 @@ dependencies = [
"tauri-build",
"tauri-plugin-clipboard-manager",
"tauri-plugin-dialog",
"tauri-plugin-global-shortcut",
"tauri-plugin-localhost",
"tauri-plugin-log",
"tauri-plugin-notification",
@@ -1621,6 +1622,24 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
[[package]]
name = "global-hotkey"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9247516746aa8e53411a0db9b62b0e24efbcf6a76e0ba73e5a91b512ddabed7"
dependencies = [
"crossbeam-channel",
"keyboard-types",
"objc2",
"objc2-app-kit",
"once_cell",
"serde",
"thiserror 2.0.17",
"windows-sys 0.59.0",
"x11rb",
"xkeysym",
]
[[package]]
name = "gobject-sys"
version = "0.18.0"
@@ -4493,6 +4512,21 @@ dependencies = [
"url",
]
[[package]]
name = "tauri-plugin-global-shortcut"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "424af23c7e88d05e4a1a6fc2c7be077912f8c76bd7900fd50aa2b7cbf5a2c405"
dependencies = [
"global-hotkey",
"log",
"serde",
"serde_json",
"tauri",
"tauri-plugin",
"thiserror 2.0.17",
]
[[package]]
name = "tauri-plugin-localhost"
version = "2.3.2"
@@ -6233,6 +6267,12 @@ dependencies = [
"rustix",
]
[[package]]
name = "xkeysym"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56"
[[package]]
name = "yoke"
version = "0.8.1"
+1
View File
@@ -39,4 +39,5 @@ default = [ "custom-protocol" ]
custom-protocol = [ "tauri/custom-protocol" ]
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-global-shortcut = "2"
tauri-plugin-window-state = "2"
+5 -1
View File
@@ -9,6 +9,10 @@
"main"
],
"permissions": [
"window-state:default"
"window-state:default",
"global-shortcut:default",
"global-shortcut:allow-is-registered",
"global-shortcut:allow-register",
"global-shortcut:allow-unregister"
]
}
+1 -1
View File
@@ -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","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
{"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
+1 -1
View File
@@ -1 +1 @@
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"windows":["main"],"permissions":["window-state:default"],"platforms":["macOS","windows","linux"]},"main-capabilities":{"identifier":"main-capabilities","description":"Capability for desktop window","local":true,"windows":["main"],"permissions":["store:allow-get","store:allow-set","store:allow-save","store:allow-clear","store:allow-delete","store:allow-keys","store:allow-load","updater:allow-check","updater:allow-download-and-install","notification:default","core:webview:allow-internal-toggle-devtools","dialog:default","upload:allow-download","clipboard-manager:allow-write-text"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-fullscreen"]}}
{"desktop-capability":{"identifier":"desktop-capability","description":"","local":true,"windows":["main"],"permissions":["window-state:default","global-shortcut:default","global-shortcut:allow-is-registered","global-shortcut:allow-register","global-shortcut:allow-unregister"],"platforms":["macOS","windows","linux"]},"main-capabilities":{"identifier":"main-capabilities","description":"Capability for desktop window","local":true,"windows":["main"],"permissions":["store:allow-get","store:allow-set","store:allow-save","store:allow-clear","store:allow-delete","store:allow-keys","store:allow-load","updater:allow-check","updater:allow-download-and-install","notification:default","core:webview:allow-internal-toggle-devtools","dialog:default","upload:allow-download","clipboard-manager:allow-write-text"]},"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-set-fullscreen"]}}
+66
View File
@@ -2288,6 +2288,72 @@
"const": "dialog:deny-save",
"markdownDescription": "Denies the save command without any pre-configured scope."
},
{
"description": "No features are enabled by default, as we believe\nthe shortcuts can be inherently dangerous and it is\napplication specific if specific shortcuts should be\nregistered or unregistered.\n",
"type": "string",
"const": "global-shortcut:default",
"markdownDescription": "No features are enabled by default, as we believe\nthe shortcuts can be inherently dangerous and it is\napplication specific if specific shortcuts should be\nregistered or unregistered.\n"
},
{
"description": "Enables the is_registered command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-is-registered",
"markdownDescription": "Enables the is_registered command without any pre-configured scope."
},
{
"description": "Enables the register command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-register",
"markdownDescription": "Enables the register command without any pre-configured scope."
},
{
"description": "Enables the register_all command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-register-all",
"markdownDescription": "Enables the register_all command without any pre-configured scope."
},
{
"description": "Enables the unregister command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-unregister",
"markdownDescription": "Enables the unregister command without any pre-configured scope."
},
{
"description": "Enables the unregister_all command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-unregister-all",
"markdownDescription": "Enables the unregister_all command without any pre-configured scope."
},
{
"description": "Denies the is_registered command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-is-registered",
"markdownDescription": "Denies the is_registered command without any pre-configured scope."
},
{
"description": "Denies the register command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-register",
"markdownDescription": "Denies the register command without any pre-configured scope."
},
{
"description": "Denies the register_all command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-register-all",
"markdownDescription": "Denies the register_all command without any pre-configured scope."
},
{
"description": "Denies the unregister command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-unregister",
"markdownDescription": "Denies the unregister command without any pre-configured scope."
},
{
"description": "Denies the unregister_all command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-unregister-all",
"markdownDescription": "Denies the unregister_all command without any pre-configured scope."
},
{
"description": "Allows the log command\n#### This default permission set includes:\n\n- `allow-log`",
"type": "string",
+66
View File
@@ -2288,6 +2288,72 @@
"const": "dialog:deny-save",
"markdownDescription": "Denies the save command without any pre-configured scope."
},
{
"description": "No features are enabled by default, as we believe\nthe shortcuts can be inherently dangerous and it is\napplication specific if specific shortcuts should be\nregistered or unregistered.\n",
"type": "string",
"const": "global-shortcut:default",
"markdownDescription": "No features are enabled by default, as we believe\nthe shortcuts can be inherently dangerous and it is\napplication specific if specific shortcuts should be\nregistered or unregistered.\n"
},
{
"description": "Enables the is_registered command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-is-registered",
"markdownDescription": "Enables the is_registered command without any pre-configured scope."
},
{
"description": "Enables the register command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-register",
"markdownDescription": "Enables the register command without any pre-configured scope."
},
{
"description": "Enables the register_all command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-register-all",
"markdownDescription": "Enables the register_all command without any pre-configured scope."
},
{
"description": "Enables the unregister command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-unregister",
"markdownDescription": "Enables the unregister command without any pre-configured scope."
},
{
"description": "Enables the unregister_all command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:allow-unregister-all",
"markdownDescription": "Enables the unregister_all command without any pre-configured scope."
},
{
"description": "Denies the is_registered command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-is-registered",
"markdownDescription": "Denies the is_registered command without any pre-configured scope."
},
{
"description": "Denies the register command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-register",
"markdownDescription": "Denies the register command without any pre-configured scope."
},
{
"description": "Denies the register_all command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-register-all",
"markdownDescription": "Denies the register_all command without any pre-configured scope."
},
{
"description": "Denies the unregister command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-unregister",
"markdownDescription": "Denies the unregister command without any pre-configured scope."
},
{
"description": "Denies the unregister_all command without any pre-configured scope.",
"type": "string",
"const": "global-shortcut:deny-unregister-all",
"markdownDescription": "Denies the unregister_all command without any pre-configured scope."
},
{
"description": "Allows the log command\n#### This default permission set includes:\n\n- `allow-log`",
"type": "string",
+1
View File
@@ -4,6 +4,7 @@ use tauri_plugin_log::{fern::colors::ColoredLevelConfig, Target, TargetKind};
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
.plugin(tauri_plugin_window_state::Builder::new().build())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_upload::init())
+7 -2
View File
@@ -15,6 +15,7 @@ import { useShallow } from "zustand/shallow";
import { useApiInContext } from "@/utils/store/api";
import { useCentralStore } from "@/utils/store/central";
import useHeaderStore from "@/utils/store/header";
import useSearchStore from "@/utils/store/search";
import {
setSettingsDialogOpen,
setSettingsTabValue,
@@ -42,6 +43,10 @@ export const AppBar = () => {
const navigate = useNavigate();
const location = useLocation();
const toggleSearchDialog = useSearchStore(
useShallow((s) => s.toggleSearchDialog),
);
const display = !HIDDEN_PATHS.some(
(path) =>
(location.pathname.startsWith(path) &&
@@ -87,7 +92,7 @@ export const AppBar = () => {
};
}, []);
const handleNavigateToSearch = useCallback(
const _handleNavigateToSearch = useCallback(
() => navigate({ to: "/search", search: { query: "" } }),
[navigate],
);
@@ -142,7 +147,7 @@ export const AppBar = () => {
</div>
<div className="flex flex-row" style={{ gap: "0.6em" }}>
<IconButton onClick={handleNavigateToSearch}>
<IconButton onClick={toggleSearchDialog}>
<div className="material-symbols-rounded">search</div>
</IconButton>
<IconButton onClick={handleNavigateToFavorite}>
+2 -1
View File
@@ -1,6 +1,6 @@
.carousel {
position: relative;
overflow: hidden;
overflow: visible;
height: 62vh;
margin-bottom: 2em;
display: grid;
@@ -18,6 +18,7 @@
&::-webkit-scrollbar {
width: 14px;
border-left: 1px solid rgb(255 255 255 / 0.1);
}
&::-webkit-scrollbar-track {
+400
View File
@@ -0,0 +1,400 @@
import { ItemSortBy } from "@jellyfin/sdk/lib/generated-client";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
import {
alpha,
Box,
Button,
Dialog,
IconButton,
InputBase,
LinearProgress,
Stack,
Typography,
useTheme,
} from "@mui/material";
import { useQuery } from "@tanstack/react-query";
import { useNavigate } from "@tanstack/react-router";
import { register } from "@tauri-apps/plugin-global-shortcut";
import React, {
type ChangeEvent,
useCallback,
useEffect,
useMemo,
useState,
} from "react";
import { useShallow } from "zustand/shallow";
import useDebounce from "@/utils/hooks/useDebounce";
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
import { useApiInContext } from "@/utils/store/api";
import { useCentralStore } from "@/utils/store/central";
import useSearchStore from "@/utils/store/search";
import SearchItem from "./item";
const Search = () => {
const theme = useTheme();
const { isOpen, handleClose, toggleSearchDialog } = useSearchStore(
useShallow((s) => ({
isOpen: s.showSearchDialog,
handleClose: s.toggleSearchDialog,
toggleSearchDialog: s.toggleSearchDialog,
})),
);
const api = useApiInContext((s) => s.api);
const userId = useCentralStore((s) => s.currentUser?.Id || "");
const suggestions = useQuery({
queryKey: ["search", "suggestions"],
queryFn: async () =>
api &&
(
await getItemsApi(api).getItems({
userId: userId,
limit: 5,
sortBy: [ItemSortBy.IsFavoriteOrLiked, ItemSortBy.Random],
includeItemTypes: ["Movie", "Series", "MusicArtist"],
enableImages: true,
recursive: true,
})
).data,
});
const [searchTerm, setSearchTerm] = useState("");
const debouncedSearchTerm = useDebounce(searchTerm, 300);
const handleSearchChange = (e: ChangeEvent<HTMLInputElement>) => {
setSearchTerm(e.target.value);
};
const searchResults = useQuery({
queryKey: ["search", debouncedSearchTerm],
queryFn: async () => {
if (!api) return null;
if (debouncedSearchTerm.trim() === "") {
return null;
}
return (
await getSearchApi(api).getSearchHints({
searchTerm: debouncedSearchTerm,
userId: userId,
limit: 10,
includeItemTypes: [
"Movie",
"Series",
"MusicAlbum",
"Person",
"Audio",
"Photo",
"PhotoAlbum",
"Playlist",
],
// enableImages: true,
})
).data;
},
});
const showSuggestions = useMemo(
() =>
(debouncedSearchTerm.length === 0 || searchResults.isLoading) &&
(suggestions.data?.Items?.length ?? 0) > 0,
[
debouncedSearchTerm.length,
searchResults.isLoading,
suggestions.data?.Items?.length,
],
);
const navigate = useNavigate();
const handleClearSearch = useCallback(() => {
setSearchTerm("");
}, []);
const handleAdvancedSearch = useCallback(() => {
navigate({ to: "/search", search: { query: debouncedSearchTerm } });
toggleSearchDialog();
}, [navigate, toggleSearchDialog, debouncedSearchTerm]);
useEffect(() => {
async function registerglobalShortcut() {
await register("CommandOrControl+K", (e) => {
if (e.state === "Pressed") {
toggleSearchDialog();
}
});
}
registerglobalShortcut();
}, []);
return (
<Dialog
open={isOpen}
onClose={handleClose}
fullWidth
maxWidth="sm"
PaperProps={{
sx: {
backgroundColor: "rgba(20, 20, 30, 0.7)",
backdropFilter: "blur(24px) saturate(180%)",
backgroundImage:
"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0))",
border: "1px solid rgba(255, 255, 255, 0.08)",
boxShadow: "0 20px 50px rgba(0,0,0,0.5)",
borderRadius: 4,
overflow: "hidden",
},
}}
>
<Box sx={{ position: "relative" }}>
<Stack
direction="row"
alignItems="center"
spacing={1.5}
sx={{
p: "16px 24px",
}}
>
<span
className="material-symbols-rounded"
style={{
color: "var(--mui-palette-text-secondary)",
fontSize: "1.75rem",
opacity: 0.7,
}}
>
search
</span>
<InputBase
placeholder="Search movies, shows, and more..."
onChange={handleSearchChange}
value={searchTerm}
fullWidth
autoFocus
sx={{
fontSize: "1.25rem",
fontWeight: 400,
color: "text.primary",
"& input::placeholder": {
color: "text.disabled",
opacity: 1,
},
}}
/>
{searchTerm && (
<IconButton
onClick={handleClearSearch}
size="small"
sx={{
color: "text.secondary",
bgcolor: "rgba(255,255,255,0.05)",
"&:hover": {
bgcolor: "rgba(255,255,255,0.15)",
},
}}
>
<span
className="material-symbols-rounded"
style={{ fontSize: "1.25rem" }}
>
close
</span>
</IconButton>
)}
</Stack>
{searchResults.isLoading && (
<LinearProgress
sx={{
height: 2,
backgroundColor: "transparent",
"& .MuiLinearProgress-bar": {
backgroundImage: `linear-gradient(90deg, ${theme.palette.primary.main}, ${theme.palette.secondary.main})`,
},
position: "absolute",
bottom: 0,
left: 0,
right: 0,
}}
/>
)}
<Box
sx={{
height: "1px",
bgcolor: "divider",
opacity: 0.1,
mx: 2,
}}
/>
</Box>
<Stack
spacing={1}
sx={{
p: 1,
maxHeight: "55vh",
overflowY: "auto",
minHeight:
showSuggestions ||
(debouncedSearchTerm &&
searchResults.data?.SearchHints?.length !== 0)
? "auto"
: "150px",
"&::-webkit-scrollbar": {
width: "8px",
},
"&::-webkit-scrollbar-thumb": {
background: "rgba(255,255,255,0.1)",
borderRadius: "4px",
},
}}
>
{debouncedSearchTerm.length > 0 &&
searchResults.data?.SearchHints &&
searchResults.data.SearchHints.length > 0 && (
<Box>
<Typography
variant="caption"
fontWeight={600}
sx={{
px: 2,
py: 1.5,
color: "text.secondary",
textTransform: "uppercase",
letterSpacing: "0.05em",
display: "block",
}}
>
Results
</Typography>
<Stack spacing={0.5} sx={{ px: 1 }}>
{searchResults.data.SearchHints.map((item) => (
<SearchItem
key={item.Id}
itemName={item.Name || "Untitled"}
imageUrl={
api &&
item.PrimaryImageTag &&
getImageUrlsApi(api).getItemImageUrl(item, "Primary", {
maxWidth: 90,
maxHeight: 140,
tag: item.PrimaryImageTag,
})
}
itemYear={
item.Type === "Series"
? `${item.ProductionYear?.toString()} - ${new Date(item.EndDate ?? "").getFullYear().toString()}`
: item.ProductionYear?.toString()
}
itemType={item.Type}
itemId={item.Id ?? ""}
/>
))}
</Stack>
</Box>
)}
{showSuggestions && (
<Box>
<Typography
variant="caption"
fontWeight={600}
sx={{
px: 2,
py: 1.5,
color: "text.secondary",
textTransform: "uppercase",
letterSpacing: "0.05em",
display: "block",
}}
>
Suggestions
</Typography>
<Stack spacing={0.5} sx={{ px: 1 }}>
{suggestions.data?.Items?.map((item) => (
<SearchItem
key={item.Id}
itemName={item.Name || "Untitled"}
imageUrl={
api &&
item.ImageTags?.Primary &&
getImageUrlsApi(api).getItemImageUrl(item, "Primary", {
maxWidth: 90,
maxHeight: 140,
})
}
itemYear={
item.Type === "Series"
? `${item.ProductionYear?.toString()} - ${new Date(item.EndDate ?? "").getFullYear().toString()}`
: item.ProductionYear?.toString()
}
itemType={item.Type}
itemId={item.Id ?? ""}
/>
))}
</Stack>
</Box>
)}
{searchResults.isSuccess &&
searchResults.data?.SearchHints?.length === 0 && (
<Stack
alignItems="center"
justifyContent="center"
sx={{
height: "100%",
minHeight: "200px",
color: "text.secondary",
gap: 2,
}}
>
<span
className="material-symbols-rounded"
style={{ fontSize: "48px", opacity: 0.2 }}
>
search_off
</span>
<Typography variant="body1">
No results found for "{debouncedSearchTerm}"
</Typography>
</Stack>
)}
</Stack>
<Stack
direction="row"
justifyContent="flex-end"
sx={{
p: 1.5,
mt: 1,
backgroundImage:
"linear-gradient(to top, rgba(0,0,0,0.2), transparent)",
}}
>
<Button
onClick={handleAdvancedSearch}
endIcon={
<span
className="material-symbols-rounded"
style={{ fontSize: "1.25rem" }}
>
arrow_forward
</span>
}
sx={{
color: "text.secondary",
textTransform: "none",
fontWeight: 500,
padding: "6px 16px",
borderRadius: "8px",
"&:hover": {
color: "primary.main",
backgroundColor: "rgba(255,255,255,0.05)",
},
}}
>
Advanced Search
</Button>
</Stack>
</Dialog>
);
};
export default Search;
+132
View File
@@ -0,0 +1,132 @@
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
import { Box, Button, Stack, Typography } from "@mui/material";
import { useNavigate } from "@tanstack/react-router";
import React from "react";
import { useShallow } from "zustand/react/shallow";
import useSearchStore from "@/utils/store/search";
import { getTypeIcon } from "../utils/iconsCollection";
type SearchItemProps = {
itemName: string;
imageUrl?: string | null;
itemYear?: string;
itemType?: BaseItemKind;
itemId: string;
};
const SearchItem = (props: SearchItemProps) => {
const { itemName, imageUrl, itemYear, itemType, itemId } = props;
const toggleSearchDialog = useSearchStore(
useShallow((s) => s.toggleSearchDialog),
);
const navigate = useNavigate();
const handleOnClick = () => {
toggleSearchDialog();
switch (itemType) {
case BaseItemKind.BoxSet:
navigate({ to: "/boxset/$id", params: { id: itemId } });
break;
case BaseItemKind.Episode:
navigate({ to: "/episode/$id", params: { id: itemId } });
break;
case BaseItemKind.MusicAlbum:
navigate({ to: "/album/$id", params: { id: itemId } });
break;
case BaseItemKind.MusicArtist:
navigate({ to: "/artist/$id", params: { id: itemId } });
break;
case BaseItemKind.Person:
navigate({ to: "/person/$id", params: { id: itemId } });
break;
case BaseItemKind.Series:
navigate({ to: "/series/$id", params: { id: itemId } });
break;
case BaseItemKind.Playlist:
navigate({ to: "/playlist/$id", params: { id: itemId } });
break;
default:
navigate({ to: "/item/$id", params: { id: itemId } });
break;
}
};
return (
<Button
onClick={handleOnClick}
fullWidth
sx={{
justifyContent: "flex-start",
textAlign: "left",
p: 1,
borderRadius: 2,
textTransform: "none",
color: "text.primary",
"&:hover": {
bgcolor: "action.hover",
},
}}
>
<Box
sx={{
width: 50,
height: 75,
mr: 2,
borderRadius: 1,
overflow: "hidden",
bgcolor: "action.selected",
flexShrink: 0,
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
{imageUrl ? (
<Box
component="img"
src={imageUrl}
alt={itemName}
sx={{
height: "100%",
width: "100%",
objectFit: "cover",
}}
/>
) : (
<span
className="material-symbols-rounded"
style={{
fontSize: "2rem",
color: "var(--mui-palette-text-secondary)",
}}
>
{getTypeIcon(itemType ?? "unknown")}
</span>
)}
</Box>
<Stack sx={{ minWidth: 0, flex: 1 }}>
<Typography variant="body1" noWrap fontWeight={500}>
{itemName}
</Typography>
<Stack direction="row" spacing={1} alignItems="center">
{itemYear && (
<Typography variant="caption" color="text.secondary">
{itemYear}
</Typography>
)}
{itemYear && itemType && (
<Typography variant="caption" color="text.secondary">
•
</Typography>
)}
{itemType && (
<Typography variant="caption" color="text.secondary">
{itemType}
</Typography>
)}
</Stack>
</Stack>
</Button>
);
};
export default SearchItem;
+2
View File
@@ -29,6 +29,7 @@ import { HTML5Backend } from "react-dnd-html5-backend";
import Backdrop from "@/components/backdrop";
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
import RouterLoading from "@/components/routerLoading";
import Search from "@/components/search";
import Updater from "@/components/updater";
import { EasterEgg } from "@/components/utils/easterEgg";
@@ -56,6 +57,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
<Updater />
<Backdrop />
<Search />
<AppBar />
<AudioPlayer />
<Outlet />
+2 -1
View File
@@ -1,7 +1,7 @@
.hero-carousel {
position: relative;
overflow: hidden;
overflow: visible;
isolation: isolate;
height: 100%;
width: 100%;
@@ -16,6 +16,7 @@
border-radius: 20px;
grid-area: main;
border: 1.2px solid rgb(255 255 255 / 0.1);
box-shadow: 0 0 20px rgba(0,0,0,0.2);
}
&-background {
+14
View File
@@ -0,0 +1,14 @@
import { create } from "zustand";
type SearchStore = {
showSearchDialog: boolean;
toggleSearchDialog: () => void;
};
const useSearchStore = create<SearchStore>((set) => ({
showSearchDialog: false,
toggleSearchDialog: () =>
set((state) => ({ showSearchDialog: !state.showSearchDialog })),
}));
export default useSearchStore;