fix: keep a calendar event visible after its date is moved (#29085)
This commit is contained in:
3 files changed
+13
-4
No files matched your search
@@ -533,7 +533,8 @@ class CalendarEventTable:
|
|||||||
& (CalendarEvent.start_at < end)
|
& (CalendarEvent.start_at < end)
|
||||||
& or_(
|
& or_(
|
||||||
CalendarEvent.end_at.is_(None) & (CalendarEvent.start_at >= start),
|
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)
|
# Recurring: fetch all (expansion in Python)
|
||||||
|
|||||||
@@ -129,7 +129,12 @@
|
|||||||
loading = true;
|
loading = true;
|
||||||
try {
|
try {
|
||||||
const startNs = dateTimeToNs(startDate, allDay ? '00:00' : startTime);
|
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) {
|
if (event && !event.meta?.automation_id) {
|
||||||
const result = await updateCalendarEvent(localStorage.token, event.id, {
|
const result = await updateCalendarEvent(localStorage.token, event.id, {
|
||||||
|
|||||||
@@ -31,7 +31,10 @@
|
|||||||
const startDate = new Date(startMs);
|
const startDate = new Date(startMs);
|
||||||
const endDate = new Date(endMs);
|
const endDate = new Date(endMs);
|
||||||
const d = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
|
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) {
|
while (d.getTime() <= last) {
|
||||||
const key = d.getTime().toString();
|
const key = d.getTime().toString();
|
||||||
(map[key] ??= []).push(e);
|
(map[key] ??= []).push(e);
|
||||||
@@ -90,7 +93,7 @@
|
|||||||
const dayEndMs = dayStartMs + 86_400_000;
|
const dayEndMs = dayStartMs + 86_400_000;
|
||||||
return filteredEvents.filter((e) => {
|
return filteredEvents.filter((e) => {
|
||||||
const startMs = e.start_at / NS;
|
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;
|
return startMs < dayEndMs && endMs >= dayStartMs;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user