mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13: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
20
src/renderer/utils/search-songs.ts
Normal file
20
src/renderer/utils/search-songs.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import Fuse from 'fuse.js';
|
||||
|
||||
import { Song } from '/@/shared/types/domain-types';
|
||||
|
||||
export const searchSongs = (songs: Song[], searchTerm: string) => {
|
||||
const fuse = new Fuse(songs, {
|
||||
fieldNormWeight: 1,
|
||||
ignoreLocation: true,
|
||||
keys: [
|
||||
'name',
|
||||
'album',
|
||||
{
|
||||
getFn: (song) => song.artists.map((artist) => artist.name),
|
||||
name: 'artist',
|
||||
},
|
||||
],
|
||||
threshold: 0,
|
||||
});
|
||||
return fuse.search(searchTerm).map((item) => item.item);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue