mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Backport pull request #4263 from jellyfin/release-10.8.z
Fix change audio track
Original-merge: 9139153d16
Merged-by: Bill Thornton <thornbill@users.noreply.github.com>
Backported-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
parent
5e6de2d7db
commit
abed235b50
4 changed files with 84 additions and 42 deletions
42
src/utils/container.ts
Normal file
42
src/utils/container.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* Checks if the list includes any value from the search.
|
||||
* @param list The list to search in.
|
||||
* @param search The values to search.
|
||||
* @returns _true_ if the list includes any value from the search.
|
||||
* @remarks The list (string) can start with '-', in which case the logic is inverted.
|
||||
*/
|
||||
export function includesAny(list: string | string[] | null | undefined, search: string | string[]): boolean {
|
||||
if (!list) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let inverseMatch = false;
|
||||
|
||||
if (typeof list === 'string') {
|
||||
if (list.startsWith('-')) {
|
||||
inverseMatch = true;
|
||||
list = list.substring(1);
|
||||
}
|
||||
|
||||
list = list.split(',');
|
||||
}
|
||||
|
||||
list = list.filter(i => i);
|
||||
|
||||
if (!list.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (typeof search === 'string') {
|
||||
search = search.split(',');
|
||||
}
|
||||
|
||||
search = search.filter(i => i);
|
||||
|
||||
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
|
||||
if (search.some(s => list!.includes(s))) {
|
||||
return !inverseMatch;
|
||||
}
|
||||
|
||||
return inverseMatch;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue