Browse Source

Add invalid entry filtering at song dispatch

master
jeffvli 3 years ago
parent
commit
fa8b3552fd
  1. 18
      src/shared/utils.ts

18
src/shared/utils.ts

@ -473,17 +473,27 @@ export const getTheme = (themes: any[], value: string) => {
export const filterPlayQueue = (filters: any[], entries: any) => { export const filterPlayQueue = (filters: any[], entries: any) => {
const enabledFilters = filters.filter((f: any) => f.enabled === true); const enabledFilters = filters.filter((f: any) => f.enabled === true);
const joinedFilterRegex = enabledFilters.map((f: any) => f.filter).join('|'); const joinedFilterRegex = enabledFilters.map((f: any) => f.filter).join('|');
// Remove invalid songs that may break the player (likely due to Airsonic including folders)
const validEntries = entries.filter((song: any) => {
return song.bitRate && song.duration;
});
if (joinedFilterRegex) { if (joinedFilterRegex) {
const filteredEntries = entries.filter((entry: any) => !entry.title.match(joinedFilterRegex)); const filteredEntries = validEntries.filter(
(entry: any) => !entry.title.match(joinedFilterRegex)
);
return { return {
entries: filteredEntries, entries: filteredEntries,
count: { original: entries.length, filtered: filteredEntries.length }, count: { original: entries.length, filtered: validEntries.length },
}; };
} }
return { entries, count: { original: entries.length, filtered: entries.length } }; return {
entries: validEntries,
count: { original: entries.length, filtered: validEntries.length },
};
}; };
export const getPlayedSongsNotification = (options: { export const getPlayedSongsNotification = (options: {
original: number; original: number;
filtered: number; filtered: number;

Loading…
Cancel
Save