Skip to content

Commit e74ce79

Browse files
Show Ongoing Events in Upcoming Events Section of LeftSidebar (#809)
1 parent e07922e commit e74ce79

File tree

4 files changed

+92
-10
lines changed

4 files changed

+92
-10
lines changed

apps/desktop/src/components/left-sidebar/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useQuery } from "@tanstack/react-query";
22
import { useMatch } from "@tanstack/react-router";
3-
import { addDays } from "date-fns";
3+
import { addDays, subHours } from "date-fns";
44
import { AnimatePresence, LayoutGroup, motion } from "motion/react";
55

66
import { useHypr, useHyprSearch, useLeftSidebar } from "@/contexts";
@@ -43,22 +43,34 @@ export default function LeftSidebar() {
4343
refetchInterval: 5000,
4444
queryKey: ["events", ongoingSessionId],
4545
queryFn: async () => {
46-
const events = await dbCommands.listEvents({
46+
const now = new Date();
47+
// Fetch events that started up to 12 hours ago.
48+
// This is to include events that are currently ongoing but might have started earlier.
49+
// These are then filtered by end_date to ensure we only show active or upcoming events.
50+
const rawEvents = await dbCommands.listEvents({
4751
type: "dateRange",
4852
user_id: userId,
4953
limit: 3,
50-
start: new Date().toISOString(),
51-
end: addDays(new Date(), 28).toISOString(),
54+
start: subHours(now, 12).toISOString(),
55+
end: addDays(now, 28).toISOString(),
5256
});
5357

58+
const ongoingOrUpcomingEvents = rawEvents.filter(
59+
(event) => event.end_date > now.toISOString(),
60+
);
61+
62+
if (ongoingOrUpcomingEvents.length === 0) {
63+
return [];
64+
}
65+
5466
const sessions = await Promise.all(
55-
events.map((event) => dbCommands.getSession({ calendarEventId: event.id })),
67+
ongoingOrUpcomingEvents.map((event) => dbCommands.getSession({ calendarEventId: event.id })),
5668
);
5769
sessions
5870
.filter((s) => s !== null)
59-
.forEach((s) => insertSession(s));
71+
.forEach((s) => insertSession(s!));
6072

61-
return events.map((event, index) => ({
73+
return ongoingOrUpcomingEvents.map((event, index) => ({
6274
...event,
6375
session: sessions[index],
6476
}));

apps/desktop/src/locales/en/messages.po

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,41 @@ msgstr "1 day later"
208208
msgid "{weeks} weeks later"
209209
msgstr "{weeks} weeks later"
210210

211+
#. js-lingui-explicit-id
212+
#: ../../packages/utils/src/datetime.ts:168
213+
#~ msgid "just now"
214+
#~ msgstr "just now"
215+
216+
#. js-lingui-explicit-id
217+
#: ../../packages/utils/src/datetime.ts:207
218+
#~ msgid "in progress"
219+
#~ msgstr "in progress"
220+
221+
#. js-lingui-explicit-id
222+
#: ../../packages/utils/src/datetime.ts:223
223+
#~ msgid "in {seconds} seconds"
224+
#~ msgstr "in {seconds} seconds"
225+
226+
#. js-lingui-explicit-id
227+
#: ../../packages/utils/src/datetime.ts:225
228+
#~ msgid "in 1 minute"
229+
#~ msgstr "in 1 minute"
230+
231+
#. js-lingui-explicit-id
232+
#: ../../packages/utils/src/datetime.ts:227
233+
#~ msgid "in {minutes} minutes"
234+
#~ msgstr "in {minutes} minutes"
235+
236+
#. js-lingui-explicit-id
237+
#: ../../packages/utils/src/datetime.ts:229
238+
#~ msgid "in 1 hour"
239+
#~ msgstr "in 1 hour"
240+
241+
#. js-lingui-explicit-id
242+
#: ../../packages/utils/src/datetime.ts:231
243+
#~ msgid "in {hours} hours"
244+
#~ msgstr "in {hours} hours"
245+
211246
#: src/components/settings/views/notifications.tsx:105
212247
msgid "(Beta) Detect meetings automatically"
213248
msgstr "(Beta) Detect meetings automatically"

apps/desktop/src/locales/ko/messages.po

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,41 @@ msgstr ""
208208
msgid "{weeks} weeks later"
209209
msgstr ""
210210

211+
#. js-lingui-explicit-id
212+
#: ../../packages/utils/src/datetime.ts:168
213+
#~ msgid "just now"
214+
#~ msgstr ""
215+
216+
#. js-lingui-explicit-id
217+
#: ../../packages/utils/src/datetime.ts:207
218+
#~ msgid "in progress"
219+
#~ msgstr ""
220+
221+
#. js-lingui-explicit-id
222+
#: ../../packages/utils/src/datetime.ts:223
223+
#~ msgid "in {seconds} seconds"
224+
#~ msgstr ""
225+
226+
#. js-lingui-explicit-id
227+
#: ../../packages/utils/src/datetime.ts:225
228+
#~ msgid "in 1 minute"
229+
#~ msgstr ""
230+
231+
#. js-lingui-explicit-id
232+
#: ../../packages/utils/src/datetime.ts:227
233+
#~ msgid "in {minutes} minutes"
234+
#~ msgstr ""
235+
236+
#. js-lingui-explicit-id
237+
#: ../../packages/utils/src/datetime.ts:229
238+
#~ msgid "in 1 hour"
239+
#~ msgstr ""
240+
241+
#. js-lingui-explicit-id
242+
#: ../../packages/utils/src/datetime.ts:231
243+
#~ msgid "in {hours} hours"
244+
#~ msgstr ""
245+
211246
#: src/components/settings/views/notifications.tsx:105
212247
msgid "(Beta) Detect meetings automatically"
213248
msgstr ""

apps/docs/data/i18n.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[
22
{
33
"language": "ko",
4-
"total": 239,
5-
"missing": 239
4+
"total": 267,
5+
"missing": 267
66
},
77
{
88
"language": "en (source)",
9-
"total": 239,
9+
"total": 267,
1010
"missing": 0
1111
}
1212
]

0 commit comments

Comments
 (0)