mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
fix: keep a calendar event visible after its date is moved (#29085)
This commit is contained in:
parent
0afe69e1a7
commit
1c5128c4aa
3 changed files with 13 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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, {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue