aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/island/calendar/Cal.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-13 09:35:54 +0100
committerDanilo M. <danix@danix.xyz>2026-11-13 09:35:54 +0100
commitbfdc3ce1e1be950dc810d19490d0b0a8ccaea3e8 (patch)
treebe3223e1cd0691c1d45977c9dd0aad2be0274914 /desktop/island/calendar/Cal.js
parent9c47ad7c10aa5a04de738a5d41acc01cc0e5e059 (diff)
downloadquickshell-bfdc3ce1e1be950dc810d19490d0b0a8ccaea3e8.tar.gz
quickshell-bfdc3ce1e1be950dc810d19490d0b0a8ccaea3e8.zip
feat(calendar): end time follows the start, default length setting
Moving an event's start now moves its end by the island's default event length, whether the start is typed, wheeled or picked, rolling into the next day past midnight. A multi-day timed event keeps its end, since snapping it to the start's day would drop the other days. Typing follows on every edit that normalises to a valid time, so Save without leaving the field still sees the moved end. A new event gets the same length. The length lives in Prefs as island.eventMinutes (5 to 1440, default 60) and is set on a new Island bar group in the settings window, which the island's other settings will join. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/island/calendar/Cal.js')
-rw-r--r--desktop/island/calendar/Cal.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/desktop/island/calendar/Cal.js b/desktop/island/calendar/Cal.js
index 6cf492d..6ec7bb3 100644
--- a/desktop/island/calendar/Cal.js
+++ b/desktop/island/calendar/Cal.js
@@ -112,14 +112,28 @@ function stepTime(s, minutes) {
return pad(Math.floor(m / 60)) + ":" + pad(m % 60);
}
-// A new event on `day`: the next whole hour, one hour long, alarm 1h (the
-// most common alarm in the live calendars). Capped at 22:00 so the end stays
-// on the same day.
-function newDraft(day, now, calendar) {
+// A new event on `day`: the next whole hour, `minutes` long (the island's
+// default event length), alarm 1h (the most common alarm in the live
+// calendars). Capped at 22:00 so a short event stays on the same day.
+function newDraft(day, now, calendar, minutes) {
const h = Math.min(22, now.getHours() + 1);
- return { uid: "", source: "", calendar: calendar, title: "", allDay: false,
- startDay: day, endDay: day, startTime: pad(h) + ":00", endTime: pad(h + 1) + ":00",
- repeat: "none", until: "", alarm: "1h", location: "", notes: "", override: false };
+ return withStart({ uid: "", source: "", calendar: calendar, title: "", allDay: false,
+ startDay: day, endDay: day, startTime: pad(h) + ":00", endTime: pad(h) + ":00",
+ repeat: "none", until: "", alarm: "1h", location: "", notes: "", override: false },
+ pad(h) + ":00", minutes);
+}
+
+// The draft with a new start time, as typed, the end following it `minutes` later,
+// into the next day if need be. A multi-day event keeps its end: snapping it
+// to the start's day would throw the other days away.
+function withStart(draft, time, minutes) {
+ const d = Object.assign({}, draft, { startTime: time });
+ const n = normTime(time);
+ if (!validTime(n) || d.startDay !== d.endDay) return d;
+ const t = +n.slice(0, 2) * 60 + +n.slice(3, 5) + (minutes > 0 ? minutes : 60);
+ d.endDay = addDays(d.startDay, Math.floor(t / 1440));
+ d.endTime = pad(Math.floor(t % 1440 / 60)) + ":" + pad(t % 60);
+ return d;
}
// calctl's event JSON as an editor draft. `source` is the calendar the event