Refactor Frigate specific details out of ViewMediaBase.

This commit is contained in:
Dermot Duffy
2023-01-24 19:36:54 -08:00
parent 36f14e153c
commit f073f06789
9 changed files with 243 additions and 234 deletions
+23 -21
View File
@@ -179,7 +179,8 @@ export const mergeFrigateBrowseMediaSources = async (
return createEventParentForChildren(
'Merged events',
children.sort(sortYoungestToOldest),
children
// TODO: Restore sort or remove: children.sort(sortYoungestToOldest),
);
};
@@ -350,25 +351,26 @@ export const createChild = (
return result;
};
/**
* Sort the timeline items most recent to least recent.
* @param a The first item.
* @param b The second item.
* @returns -1, 0, 1 (standard array sort function configuration).
*/
export const sortYoungestToOldest = (
a: FrigateBrowseMediaSource,
b: FrigateBrowseMediaSource,
): number => {
const a_source = a.frigate?.event ?? a.frigate?.recording;
const b_source = b.frigate?.event ?? b.frigate?.recording;
// TODO Remove or fix this if not needed post gallery.
// /**
// * Sort the timeline items most recent to least recent.
// * @param a The first item.
// * @param b The second item.
// * @returns -1, 0, 1 (standard array sort function configuration).
// */
// export const sortYoungestToOldest = (
// a: FrigateBrowseMediaSource,
// b: FrigateBrowseMediaSource,
// ): number => {
// const a_source = a.frigate?.event ?? a.frigate?.recording;
// const b_source = b.frigate?.event ?? b.frigate?.recording;
if (!a_source || (b_source && b_source.start_time > a_source.start_time)) {
return 1;
}
// if (!a_source || (b_source && b_source.start_time > a_source.start_time)) {
// return 1;
// }
if (!b_source || (a_source && b_source.start_time < a_source.start_time)) {
return -1;
}
return 0;
};
// if (!b_source || (a_source && b_source.start_time < a_source.start_time)) {
// return -1;
// }
// return 0;
// };