mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
feat: add 'personal' sort criteria to allow prioritising personal/your media results
This commit is contained in:
@@ -739,12 +739,19 @@ export class AIOStreams {
|
||||
? -1
|
||||
: 1; // cached > uncached
|
||||
}
|
||||
} else if (field === 'hasProvider') {
|
||||
// files from a provider should be prioritised and then
|
||||
let aHasProvider = a.provider;
|
||||
let bHasProvider = b.provider;
|
||||
if (aHasProvider && !bHasProvider) return -1;
|
||||
if (!aHasProvider && bHasProvider) return 1;
|
||||
} else if (field === 'personal') {
|
||||
// depending on direction, sort by personal or not personal
|
||||
const direction = this.config.sortBy.find(
|
||||
(sort) => Object.keys(sort)[0] === 'personal'
|
||||
)?.direction;
|
||||
if (direction === 'asc') {
|
||||
// prefer not personal over personal
|
||||
return a.personal === b.personal ? 0 : a.personal ? 1 : -1;
|
||||
}
|
||||
if (direction === 'desc') {
|
||||
// prefer personal over not personal
|
||||
return a.personal === b.personal ? 0 : a.personal ? -1 : 1;
|
||||
}
|
||||
} else if (field === 'service') {
|
||||
// sort files with providers by name
|
||||
let aProvider = a.provider?.id;
|
||||
|
||||
@@ -104,6 +104,7 @@ const defaultEncodes: Encode[] = [
|
||||
];
|
||||
|
||||
const defaultSortCriteria: SortBy[] = [
|
||||
{ personal: true, direction: 'desc' },
|
||||
{ cached: true, direction: 'desc' },
|
||||
{ resolution: true },
|
||||
{ language: true },
|
||||
|
||||
Reference in New Issue
Block a user