Skip to content

Commit

Permalink
feat: Do not remove events that collide
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Sep 5, 2024
1 parent 994e80b commit 56edb43
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions lib/screens/events_timeline/events_playback.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,19 @@ class _EventsPlaybackState extends EventsScreenState<EventsPlayback> {

final devices = <Device, List<Event>>{};

for (final event in eventsProvider.loadedEvents!.filteredEvents) {
final events = eventsProvider.loadedEvents!.filteredEvents
..sort((a, b) {
// Sort the events in a way that the continuous events are displayed first
// Ideally, in the Timeline, the motion events should be displayed on
// top of the continuous events. We need to sort the continuous events
// so that the continuous events don't get on top of the motion events.
final aIsContinuous = a.type == EventType.continuous;
final bIsContinuous = b.type == EventType.continuous;
if (aIsContinuous && !bIsContinuous) return -1;
if (!aIsContinuous && bIsContinuous) return 1;
return 0;
});
for (final event in events) {
if (event.isAlarm || event.mediaURL == null) continue;

if (!DateUtils.isSameDay(event.published, date) ||
Expand All @@ -114,16 +126,19 @@ class _EventsPlaybackState extends EventsScreenState<EventsPlayback> {
);
devices[device] ??= [];

if (devices[device]!.any((e) {
return e.published.isInBetween(event.published, event.updated,
allowSameMoment: true) ||
e.updated.isInBetween(event.published, event.updated,
allowSameMoment: true) ||
event.published
.isInBetween(e.published, e.updated, allowSameMoment: true) ||
event.updated
.isInBetween(e.published, e.updated, allowSameMoment: true);
})) continue;
// This ensures that events that happened at the same time are not
// displayed on the same device.
//
// if (devices[device]!.any((e) {
// return e.published.isInBetween(event.published, event.updated,
// allowSameMoment: true) ||
// e.updated.isInBetween(event.published, event.updated,
// allowSameMoment: true) ||
// event.published
// .isInBetween(e.published, e.updated, allowSameMoment: true) ||
// event.updated
// .isInBetween(e.published, e.updated, allowSameMoment: true);
// })) continue;

devices[device]!.add(event);
}
Expand Down

0 comments on commit 56edb43

Please sign in to comment.