fix: keep a calendar event visible after its date is moved (#29085)

This commit is contained in:
G30 2026-08-27 16:44:58 -04:00 committed by GitHub
parent 0afe69e1a7
commit 1c5128c4aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 4 deletions

View file

@ -533,7 +533,8 @@ class CalendarEventTable:
& (CalendarEvent.start_at < end)
& or_(
CalendarEvent.end_at.is_(None) & (CalendarEvent.start_at >= start),
CalendarEvent.end_at.isnot(None) & (CalendarEvent.end_at > start),
CalendarEvent.end_at.isnot(None)
& ((CalendarEvent.end_at > start) | (CalendarEvent.start_at >= start)),
)
),
# Recurring: fetch all (expansion in Python)

View file

@ -129,7 +129,12 @@
loading = true;
try {
const startNs = dateTimeToNs(startDate, allDay ? '00:00' : startTime);
const endNs = endDate ? dateTimeToNs(endDate, allDay ? '23:59' : endTime) : undefined;
let endNs = endDate ? dateTimeToNs(endDate, allDay ? '23:59' : endTime) : undefined;
if (endNs !== undefined && endNs < startNs) {
const duration =
event?.end_at && event.end_at > event.start_at ? event.end_at - event.start_at : 0;
endNs = startNs + duration;
}
if (event && !event.meta?.automation_id) {
const result = await updateCalendarEvent(localStorage.token, event.id, {

View file

@ -31,7 +31,10 @@
const startDate = new Date(startMs);
const endDate = new Date(endMs);
const d = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
const last = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()).getTime();
const last = Math.max(
d.getTime(),
new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()).getTime()
);
while (d.getTime() <= last) {
const key = d.getTime().toString();
(map[key] ??= []).push(e);
@ -90,7 +93,7 @@
const dayEndMs = dayStartMs + 86_400_000;
return filteredEvents.filter((e) => {
const startMs = e.start_at / NS;
const endMs = (e.end_at || e.start_at) / NS;
const endMs = Math.max(startMs, (e.end_at || e.start_at) / NS);
return startMs < dayEndMs && endMs >= dayStartMs;
});
}