feat(frontend): add Spotlight-style command palette with recent tracking
- Add CommandPalette component with keyboard navigation (arrows, Enter, Shift+Enter, Esc) - Add useCommandPaletteStore Zustand store with localStorage-persisted recently viewed - Show two distinct sections: Library results and TMDB Results (no duplicates) - Exclude library entries from TMDB Results section by TMDB ID index - Add "View all" links: Library section → /library, TMDB section → /search - Persist non-library TMDB entries in localStorage for recently viewed support - Register global Ctrl+P / Cmd+P / slash shortcuts in AppLayout - Track entry visits in EntryDetailsPage for recently viewed - Track TMDB preview visits in TmdbPreviewPage for recently viewed - Updated related docs files Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
1 parent
4303b33677
commit
3448142242
9 files changed
+710
-3
No files matched your search
@@ -1,9 +1,10 @@
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, Link, useNavigate } from 'react-router-dom';
|
||||
import { useEntry, useEntrySeasons, useRefreshEntry } from '@/hooks/useEntries';
|
||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
||||
import { useCollections } from '@/hooks/useCollections';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import { useCommandPaletteStore } from '@/stores/useCommandPaletteStore';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
@@ -83,6 +84,21 @@ export function EntryDetailsPage() {
|
||||
const [showWatchHistoryDialog, setShowWatchHistoryDialog] = useState(false);
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||
|
||||
// Track recently viewed for command palette
|
||||
const addRecentlyViewed = useCommandPaletteStore((s) => s.addRecentlyViewed);
|
||||
useEffect(() => {
|
||||
if (displayEntry) {
|
||||
addRecentlyViewed({
|
||||
id: `lib-${entryId}`,
|
||||
title: displayEntry.title,
|
||||
type: displayEntry.is_tvseries ? 'tv' : 'movie',
|
||||
poster_path: displayEntry.poster_path,
|
||||
libraryId: entryId,
|
||||
tmdbId: displayEntry.entryIds?.tmdb_id ?? undefined,
|
||||
});
|
||||
}
|
||||
}, [entryId, displayEntry?.title]);
|
||||
|
||||
if (isLoading || !displayEntry) {
|
||||
return <EntryDetailsSkeleton />;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { useEffect } from 'react';
|
||||
import { useTmdbPreview, useCreateEntry } from '@/hooks/useEntries';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import { useCommandPaletteStore } from '@/stores/useCommandPaletteStore';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
@@ -29,6 +31,21 @@ export function TmdbPreviewPage() {
|
||||
return null;
|
||||
});
|
||||
|
||||
// Track recently viewed for command palette
|
||||
const addRecentlyViewed = useCommandPaletteStore((s) => s.addRecentlyViewed);
|
||||
useEffect(() => {
|
||||
if (preview) {
|
||||
addRecentlyViewed({
|
||||
id: `tmdb-${tmdbIdNum}`,
|
||||
title: preview.title,
|
||||
type: mediaType,
|
||||
poster_path: preview.poster_path,
|
||||
libraryId: libraryEntry?.id,
|
||||
tmdbId: tmdbIdNum,
|
||||
});
|
||||
}
|
||||
}, [tmdbIdNum, preview?.title]);
|
||||
|
||||
if (isLoading || !preview) {
|
||||
return <EntryDetailsSkeleton />;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user