@atmo-dev/kit 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getCDNImageBlobUrl } from './atproto-helpers.js';
|
|
3
3
|
import { getEventThumbnail } from './event-media.js';
|
|
4
4
|
import { Avatar, Button, ToggleGroup, ToggleGroupItem } from '../index.js';
|
|
5
|
-
import { onMount } from 'svelte';
|
|
5
|
+
import { onMount, untrack } from 'svelte';
|
|
6
6
|
import { InlineEditor, type Editor } from '../index.js';
|
|
7
7
|
import DateTimePicker from './DateTimePicker.svelte';
|
|
8
8
|
import TimezonePicker from './TimezonePicker.svelte';
|
|
@@ -185,22 +185,17 @@
|
|
|
185
185
|
return s.slice(0, 16);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
//
|
|
188
|
+
// Only a changed start should move the end. Watching endsAt as well would
|
|
189
|
+
// overwrite intermediate keystrokes (e.g. entering 6 before switching to PM).
|
|
189
190
|
$effect(() => {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
// Auto-adjust end date if start moves past it
|
|
196
|
-
$effect(() => {
|
|
197
|
-
if (startsAt && endsAt) {
|
|
198
|
-
const s = parseDateTime(startsAt);
|
|
199
|
-
const e = parseDateTime(endsAt);
|
|
200
|
-
if (s.compare(e) >= 0) {
|
|
191
|
+
const start = startsAt;
|
|
192
|
+
untrack(() => {
|
|
193
|
+
if (!start) return;
|
|
194
|
+
const s = parseDateTime(start);
|
|
195
|
+
if (!endsAt || s.compare(parseDateTime(endsAt)) >= 0) {
|
|
201
196
|
endsAt = cdtToDatetimeLocal(s.add({ hours: 1 }).toString());
|
|
202
197
|
}
|
|
203
|
-
}
|
|
198
|
+
});
|
|
204
199
|
});
|
|
205
200
|
|
|
206
201
|
async function handleSubmit() {
|
|
@@ -209,6 +204,8 @@
|
|
|
209
204
|
if (!name.trim()) return void (error = 'Name is required.');
|
|
210
205
|
if (!startsAt) return void (error = 'Start date is required.');
|
|
211
206
|
if (!endsAt) return void (error = 'End date is required.');
|
|
207
|
+
if (parseDateTime(endsAt).compare(parseDateTime(startsAt)) <= 0)
|
|
208
|
+
return void (error = 'End time must be after the start time.');
|
|
212
209
|
if (!viewer.isLoggedIn || !viewer.did) return void (error = 'You must be logged in.');
|
|
213
210
|
|
|
214
211
|
submitting = true;
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
let { value = $bindable('') }: { value: string } = $props();
|
|
5
5
|
let isOpen = $state(false);
|
|
6
6
|
let search = $state('');
|
|
7
|
-
|
|
7
|
+
// WebKit already includes UTC; duplicate keys crash the list when opened.
|
|
8
|
+
const allTimezones = [...new Set(['UTC', ...Intl.supportedValuesOf('timeZone')])];
|
|
8
9
|
// Memoized formatting results are not reactive state.
|
|
9
10
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
10
11
|
const offsets = new Map<string, string>();
|
|
@@ -98,6 +98,10 @@
|
|
|
98
98
|
// to preserve the wall time across DST transitions.
|
|
99
99
|
const baseStart = parseDateTime(startsAt);
|
|
100
100
|
const baseEnd = endsAt ? parseDateTime(endsAt) : null;
|
|
101
|
+
if (baseEnd && baseEnd.compare(baseStart) <= 0) {
|
|
102
|
+
errorMsg = 'End time must be after the start time.';
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
101
105
|
const durationMs = baseEnd
|
|
102
106
|
? baseEnd.toDate(timezone).getTime() - baseStart.toDate(timezone).getTime()
|
|
103
107
|
: 0;
|