mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 18:33:33 +00:00
feat: add filtering for now playing view and sidebar
This commit is contained in:
parent
4dd52b0cef
commit
4cbbb4035d
7 changed files with 83 additions and 28 deletions
|
|
@ -39,6 +39,7 @@ import {
|
|||
useSettingsStoreActions,
|
||||
useTableSettings,
|
||||
} from '/@/renderer/store/settings.store';
|
||||
import { searchSongs } from '/@/renderer/utils/search-songs';
|
||||
import { setQueue, setQueueNext } from '/@/renderer/utils/set-transcoded-queue-data';
|
||||
import { LibraryItem, QueueSong } from '/@/shared/types/domain-types';
|
||||
import { PlaybackType, TableType } from '/@/shared/types/types';
|
||||
|
|
@ -46,10 +47,11 @@ import { PlaybackType, TableType } from '/@/shared/types/types';
|
|||
const mpvPlayer = isElectron() ? window.api.mpvPlayer : null;
|
||||
|
||||
type QueueProps = {
|
||||
searchTerm?: string;
|
||||
type: TableType;
|
||||
};
|
||||
|
||||
export const PlayQueue = forwardRef(({ type }: QueueProps, ref: Ref<any>) => {
|
||||
export const PlayQueue = forwardRef(({ searchTerm, type }: QueueProps, ref: Ref<any>) => {
|
||||
const tableRef = useRef<AgGridReactType | null>(null);
|
||||
const mergedRef = useMergedRef(ref, tableRef);
|
||||
const queue = useDefaultQueue();
|
||||
|
|
@ -67,6 +69,14 @@ export const PlayQueue = forwardRef(({ type }: QueueProps, ref: Ref<any>) => {
|
|||
const isFocused = useAppFocus();
|
||||
const isFocusedRef = useRef<boolean>(isFocused);
|
||||
|
||||
const songs = useMemo(() => {
|
||||
if (searchTerm) {
|
||||
return searchSongs(queue, searchTerm);
|
||||
}
|
||||
|
||||
return queue;
|
||||
}, [queue, searchTerm]);
|
||||
|
||||
useEffect(() => {
|
||||
if (tableRef.current) {
|
||||
setGridApi(tableRef.current);
|
||||
|
|
@ -276,7 +286,7 @@ export const PlayQueue = forwardRef(({ type }: QueueProps, ref: Ref<any>) => {
|
|||
ref={mergedRef}
|
||||
rowBuffer={50}
|
||||
rowClassRules={rowClassRules}
|
||||
rowData={queue}
|
||||
rowData={songs}
|
||||
rowDragEntireRow
|
||||
rowDragMultiRow
|
||||
rowHeight={tableConfig.rowHeight || 40}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue