Skip to content

Commit

Permalink
Calendar: Sort Events by start DateTime
Browse files Browse the repository at this point in the history
This PR allows Calendar to display Events in chronological order.
  • Loading branch information
alec3660 authored and AtkinsSJ committed Jul 11, 2024
1 parent 3961002 commit 1dca789
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Userland/Applications/Calendar/EventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "EventManager.h"
#include <AK/JsonParser.h>
#include <AK/QuickSort.h>
#include <LibConfig/Client.h>
#include <LibFileSystemAccessClient/Client.h>

Expand All @@ -26,13 +27,15 @@ OwnPtr<EventManager> EventManager::create()
void EventManager::add_event(Event event)
{
m_events.append(move(event));
quick_sort(m_events, [&](auto& a, auto& b) { return a.start < b.start; });
m_dirty = true;
on_events_change();
}

void EventManager::set_events(Vector<Event> events)
{
m_events = move(events);
quick_sort(m_events, [&](auto& a, auto& b) { return a.start < b.start; });
m_dirty = true;
on_events_change();
}
Expand Down

0 comments on commit 1dca789

Please sign in to comment.