Dedup same cameras with different zones.
This commit is contained in:
@@ -183,27 +183,7 @@ export const mergeFrigateBrowseMediaSources = async (
|
||||
}
|
||||
}
|
||||
|
||||
const eventSort = (
|
||||
a: FrigateBrowseMediaSource,
|
||||
b: FrigateBrowseMediaSource,
|
||||
): number => {
|
||||
if (
|
||||
!a.frigate?.event ||
|
||||
(b.frigate?.event && b.frigate.event.start_time > a.frigate.event.start_time)
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (
|
||||
!b.frigate?.event ||
|
||||
(a.frigate?.event && b.frigate.event.start_time < a.frigate.event.start_time)
|
||||
) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
return createEventParentForChildren('Merged events', children.sort(eventSort));
|
||||
return createEventParentForChildren('Merged events', children.sort(sortYoungestToOldest));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -445,3 +425,32 @@ 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;
|
||||
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user