@atmo-dev/kit 0.10.1 → 0.11.1

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.
@@ -7,6 +7,7 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import type { Snippet } from 'svelte';
10
+ import { SvelteMap } from 'svelte/reactivity';
10
11
  import type { AttendeeInfo, AttendeeListLoader } from './contrail.js';
11
12
  import { Avatar } from '../index.js';
12
13
  import { scale } from 'svelte/transition';
@@ -64,20 +65,32 @@
64
65
  );
65
66
  let loadingAll = $state(false);
66
67
  let loadedAll = $state(false);
68
+ const localUpdates = new SvelteMap<string, AttendeeInfo | null>();
67
69
 
68
70
  async function loadEveryone() {
69
71
  if (!loadAll || loadedAll || loadingAll || !hasMore) return;
70
72
  loadingAll = true;
71
73
  try {
72
74
  const full = await loadAll();
73
- goingAttendeesOverride = full.going;
74
- interestedAttendeesOverride = full.interested;
75
- goingCountOverride = Math.max(goingCount, full.goingCount ?? 0, full.going.length);
76
- interestedCountOverride = Math.max(
77
- interestedCount,
78
- full.interestedCount ?? 0,
79
- full.interested.length
80
- );
75
+ // The index may still contain a just-cancelled RSVP (or omit a new
76
+ // one). Do not let a late lazy load undo successful local mutations.
77
+ const updates = [...localUpdates.values()].filter((a) => a !== null);
78
+ goingAttendeesOverride = [
79
+ ...updates.filter((a) => a.status === 'going'),
80
+ ...full.going.filter((a) => !localUpdates.has(a.did))
81
+ ];
82
+ interestedAttendeesOverride = [
83
+ ...updates.filter((a) => a.status === 'interested'),
84
+ ...full.interested.filter((a) => !localUpdates.has(a.did))
85
+ ];
86
+ if (localUpdates.size === 0) {
87
+ goingCountOverride = Math.max(goingCount, full.goingCount ?? 0, full.going.length);
88
+ interestedCountOverride = Math.max(
89
+ interestedCount,
90
+ full.interestedCount ?? 0,
91
+ full.interested.length
92
+ );
93
+ }
81
94
  loadedAll = true;
82
95
  } catch {
83
96
  // Keep the sample; the next open tries again.
@@ -92,9 +105,21 @@
92
105
  void loadEveryone();
93
106
  }
94
107
 
95
- export function addAttendee(attendee: AttendeeInfo) {
96
- const wasGoing = goingAttendees.some((a) => a.did === attendee.did);
97
- const wasInterested = interestedAttendees.some((a) => a.did === attendee.did);
108
+ // A partial list cannot tell us whether an account already contributes to
109
+ // the totals. Callers that know its previous status must supply it.
110
+ export function addAttendee(
111
+ attendee: AttendeeInfo,
112
+ previousStatus?: 'going' | 'interested' | 'notgoing' | null
113
+ ) {
114
+ const wasGoing =
115
+ previousStatus === undefined
116
+ ? goingAttendees.some((a) => a.did === attendee.did)
117
+ : previousStatus === 'going';
118
+ const wasInterested =
119
+ previousStatus === undefined
120
+ ? interestedAttendees.some((a) => a.did === attendee.did)
121
+ : previousStatus === 'interested';
122
+ localUpdates.set(attendee.did, attendee);
98
123
  const nextGoing = goingAttendees.filter((a) => a.did !== attendee.did);
99
124
  const nextInterested = interestedAttendees.filter((a) => a.did !== attendee.did);
100
125
 
@@ -103,11 +128,11 @@
103
128
  goingAttendeesOverride = [attendee, ...nextGoing];
104
129
  interestedAttendeesOverride = nextInterested;
105
130
  goingCountOverride = goingCount + (wasGoing ? 0 : 1);
106
- interestedCountOverride = interestedCount - (wasInterested ? 1 : 0);
131
+ interestedCountOverride = Math.max(0, interestedCount - (wasInterested ? 1 : 0));
107
132
  } else if (attendee.status === 'interested') {
108
133
  goingAttendeesOverride = nextGoing;
109
134
  interestedAttendeesOverride = [attendee, ...nextInterested];
110
- goingCountOverride = goingCount - (wasGoing ? 1 : 0);
135
+ goingCountOverride = Math.max(0, goingCount - (wasGoing ? 1 : 0));
111
136
  interestedCountOverride = interestedCount + (wasInterested ? 0 : 1);
112
137
  }
113
138
  }
@@ -116,13 +141,23 @@
116
141
  return url?.replace('/avatar/', '/avatar_thumbnail/');
117
142
  }
118
143
 
119
- export function removeAttendee(did: string) {
120
- const wasGoing = goingAttendees.some((a) => a.did === did);
121
- const wasInterested = interestedAttendees.some((a) => a.did === did);
144
+ export function removeAttendee(
145
+ did: string,
146
+ previousStatus?: 'going' | 'interested' | 'notgoing' | null
147
+ ) {
148
+ const wasGoing =
149
+ previousStatus === undefined
150
+ ? goingAttendees.some((a) => a.did === did)
151
+ : previousStatus === 'going';
152
+ const wasInterested =
153
+ previousStatus === undefined
154
+ ? interestedAttendees.some((a) => a.did === did)
155
+ : previousStatus === 'interested';
156
+ localUpdates.set(did, null);
122
157
  goingAttendeesOverride = goingAttendees.filter((a) => a.did !== did);
123
158
  interestedAttendeesOverride = interestedAttendees.filter((a) => a.did !== did);
124
- if (wasGoing) goingCountOverride = goingCount - 1;
125
- if (wasInterested) interestedCountOverride = interestedCount - 1;
159
+ if (wasGoing) goingCountOverride = Math.max(0, goingCount - 1);
160
+ if (wasInterested) interestedCountOverride = Math.max(0, interestedCount - 1);
126
161
  }
127
162
  </script>
128
163
 
@@ -14,8 +14,8 @@ type $$ComponentProps = {
14
14
  loadAll?: AttendeeListLoader;
15
15
  };
16
16
  declare const EventAttendees: import("svelte").Component<$$ComponentProps, {
17
- addAttendee: (attendee: AttendeeInfo) => void;
18
- removeAttendee: (did: string) => void;
17
+ addAttendee: (attendee: AttendeeInfo, previousStatus?: "going" | "interested" | "notgoing" | null) => void;
18
+ removeAttendee: (did: string, previousStatus?: "going" | "interested" | "notgoing" | null) => void;
19
19
  }, "">;
20
20
  type EventAttendees = ReturnType<typeof EventAttendees>;
21
21
  export default EventAttendees;
@@ -9,10 +9,13 @@
9
9
 
10
10
  let {
11
11
  event,
12
- actor
12
+ actor,
13
+ href
13
14
  }: {
14
15
  event: FlatEventRecord;
15
16
  actor?: string;
17
+ /** Where the card links, for an event whose page is not its creator's. */
18
+ href?: string;
16
19
  } = $props();
17
20
 
18
21
  function formatDateTime(dateStr: string): string {
@@ -85,7 +88,7 @@
85
88
  </script>
86
89
 
87
90
  <a
88
- href={eventUrl(event, actor)}
91
+ href={href ?? eventUrl(event, actor)}
89
92
  class="group grid grid-cols-[5rem_minmax(0,1fr)] gap-3 rounded-ui outline-offset-4 transition-colors focus-visible:outline-2 focus-visible:outline-accent-700 sm:grid-cols-[6rem_minmax(0,1fr)] sm:gap-3.5 dark:focus-visible:outline-accent-300"
90
93
  >
91
94
  <div class="w-full">
@@ -2,6 +2,8 @@ import { type FlatEventRecord } from './contrail.js';
2
2
  type $$ComponentProps = {
3
3
  event: FlatEventRecord;
4
4
  actor?: string;
5
+ /** Where the card links, for an event whose page is not its creator's. */
6
+ href?: string;
5
7
  };
6
8
  declare const EventCard: import("svelte").Component<$$ComponentProps, {}, "">;
7
9
  type EventCard = ReturnType<typeof EventCard>;
@@ -94,6 +94,8 @@
94
94
  let selectedPreset: string | null = $state(
95
95
  initialThumbnailFile ? null : eventData === null ? DEFAULT_PRESET : null
96
96
  );
97
+ let images = $derived(adapter.features.images !== false);
98
+ let showVisibility = $derived(adapter.features.visibility !== false);
97
99
  let submitting = $state(false);
98
100
  let error: string | null = $state(null);
99
101
  let titleEditor = $state<Editor | null>(null);
@@ -132,7 +134,7 @@
132
134
  }
133
135
 
134
136
  function populateThumbnailFromEventData() {
135
- if (!eventData) return;
137
+ if (!eventData || !images) return;
136
138
  if (eventData.media && eventData.media.length > 0) {
137
139
  const media = getEventThumbnail(eventData.media);
138
140
  if (media?.content) {
@@ -212,7 +214,7 @@
212
214
 
213
215
  try {
214
216
  // Generate thumbnail from preset if selected and no custom upload
215
- if (selectedPreset && !thumbnailFile) {
217
+ if (images && selectedPreset && !thumbnailFile) {
216
218
  const rendered = await renderPresetThumbnail({
217
219
  design: selectedPreset,
218
220
  seed: hashSeed(rkey),
@@ -227,14 +229,18 @@
227
229
  }
228
230
 
229
231
  const existingMedia = (eventData?.media ?? []) as Array<Record<string, unknown>>;
230
- const media = await buildThumbnailMedia({
231
- isNew,
232
- thumbnailChanged,
233
- thumbnailFile,
234
- existingMedia,
235
- uploadBlob: (blob) =>
236
- adapter.uploadBlob(blob) as unknown as Promise<Record<string, unknown>>
237
- });
232
+ const media = images
233
+ ? await buildThumbnailMedia({
234
+ isNew,
235
+ thumbnailChanged,
236
+ thumbnailFile,
237
+ existingMedia,
238
+ uploadBlob: (blob) =>
239
+ adapter.uploadBlob(blob) as unknown as Promise<Record<string, unknown>>
240
+ })
241
+ : existingMedia.length > 0
242
+ ? existingMedia
243
+ : undefined;
238
244
 
239
245
  const record = await buildEventRecord({
240
246
  eventData,
@@ -245,7 +251,7 @@
245
251
  endsAt,
246
252
  timezone,
247
253
  mode,
248
- visibility,
254
+ visibility: showVisibility ? visibility : null,
249
255
  theme: eventTheme,
250
256
  links,
251
257
  location,
@@ -288,7 +294,8 @@
288
294
  collection: 'community.lexicon.calendar.event',
289
295
  rkey
290
296
  });
291
- const eventUri = `at://${viewer.did}/community.lexicon.calendar.event/${rkey}`;
297
+ const eventUri =
298
+ eventData?.uri || `at://${viewer.did}/community.lexicon.calendar.event/${rkey}`;
292
299
  await adapter.notifyUpdate?.(eventUri);
293
300
  adapter.onDeleted?.();
294
301
  } catch (e) {
@@ -326,16 +333,18 @@
326
333
  <div
327
334
  class="grid grid-cols-1 gap-8 md:grid-cols-[14rem_1fr] md:gap-x-10 md:gap-y-6 lg:grid-cols-[16rem_1fr]"
328
335
  >
329
- <ThumbnailSection
330
- {rkey}
331
- {name}
332
- dateStr={thumbnailDateStr}
333
- accent={eventTheme.accentColor}
334
- bind:thumbnailFile
335
- bind:thumbnailPreview
336
- bind:thumbnailChanged
337
- bind:selectedPreset
338
- />
336
+ {#if images}
337
+ <ThumbnailSection
338
+ {rkey}
339
+ {name}
340
+ dateStr={thumbnailDateStr}
341
+ accent={eventTheme.accentColor}
342
+ bind:thumbnailFile
343
+ bind:thumbnailPreview
344
+ bind:thumbnailChanged
345
+ bind:selectedPreset
346
+ />
347
+ {/if}
339
348
 
340
349
  <!-- Right column: event details -->
341
350
  <div class="order-2 min-w-0 md:order-0 md:col-start-2 md:row-span-5 md:row-start-1">
@@ -371,29 +380,31 @@
371
380
  </div>
372
381
 
373
382
  <!-- Visibility toggle -->
374
- <div class="mb-8">
375
- <ToggleGroup
376
- type="single"
377
- bind:value={
378
- () => visibility,
379
- (val) => {
380
- if (val) visibility = val as Visibility;
383
+ {#if showVisibility}
384
+ <div class="mb-8">
385
+ <ToggleGroup
386
+ type="single"
387
+ bind:value={
388
+ () => visibility,
389
+ (val) => {
390
+ if (val) visibility = val as Visibility;
391
+ }
381
392
  }
382
- }
383
- class="w-fit"
384
- size="xs"
385
- >
386
- <ToggleGroupItem value="public">Public</ToggleGroupItem>
387
- <ToggleGroupItem value="unlisted">Unlisted</ToggleGroupItem>
388
- </ToggleGroup>
389
- <div class="mt-1.5 text-xs text-base-600 dark:text-base-400">
390
- {#if visibility === 'public'}
391
- Anyone can view and it appears in discovery.
392
- {:else}
393
- Public to anyone with the link, but hidden from discovery.
394
- {/if}
393
+ class="w-fit"
394
+ size="xs"
395
+ >
396
+ <ToggleGroupItem value="public">Public</ToggleGroupItem>
397
+ <ToggleGroupItem value="unlisted">Unlisted</ToggleGroupItem>
398
+ </ToggleGroup>
399
+ <div class="mt-1.5 text-xs text-base-600 dark:text-base-400">
400
+ {#if visibility === 'public'}
401
+ Anyone can view and it appears in discovery.
402
+ {:else}
403
+ Public to anyone with the link, but hidden from discovery.
404
+ {/if}
405
+ </div>
395
406
  </div>
396
- </div>
407
+ {/if}
397
408
 
398
409
  <!-- Date row -->
399
410
  <div class="mb-5 grid min-w-0 gap-2">
@@ -48,6 +48,7 @@
48
48
  pageUrl,
49
49
  embedMode = false,
50
50
  shareUrlOverride,
51
+ share = true,
51
52
  extraActions,
52
53
  attendeeActions,
53
54
  loadAttendees
@@ -62,6 +63,9 @@
62
63
  * of the canonical atmo.rsvp event URL. Useful for embedders that want
63
64
  * share links to point at their own event page. */
64
65
  shareUrlOverride?: string;
66
+ /** False for an event with no public page to share, such as a private one: no share pop-up
67
+ * after creating the event or answering Going. */
68
+ share?: boolean;
65
69
  /** App-owned actions such as private reporting; omitted in embeds. */
66
70
  extraActions?: Snippet;
67
71
  /** App-owned actions below the attendee lists, with current RSVP counts. */
@@ -143,6 +147,7 @@
143
147
  url.searchParams.delete('created');
144
148
  history.replaceState({}, '', url.pathname);
145
149
  launchConfetti();
150
+ if (!share) return;
146
151
  shareModalTitle = 'Event created!';
147
152
  shareModalText = `I'm hosting "${eventData.name}"!\n\n${shareUrl}`;
148
153
  canSetEventComments = isHost;
@@ -200,7 +205,8 @@
200
205
  return null;
201
206
  });
202
207
 
203
- let eventUri = $derived(`at://${did}/community.lexicon.calendar.event/${rkey}`);
208
+ // The record's own address, which isn't in its creator's repo for every event (one in a space).
209
+ let eventUri = $derived(eventData.uri || `at://${did}/community.lexicon.calendar.event/${rkey}`);
204
210
 
205
211
  let ogImageUrl = $derived(data.ogImage ?? `${pageUrl.origin}${pageUrl.pathname}/og.png`);
206
212
 
@@ -232,18 +238,29 @@
232
238
  let vodApi: VodPlayerApi | undefined = $state();
233
239
 
234
240
  let attendeesRef: EventAttendees | undefined = $state();
241
+ let viewerRsvpStatusOverride: 'going' | 'interested' | 'notgoing' | null | undefined =
242
+ $state(undefined);
243
+ let viewerRsvpStatus = $derived(
244
+ viewerRsvpStatusOverride === undefined
245
+ ? (data.viewerRsvpStatus ?? null)
246
+ : viewerRsvpStatusOverride
247
+ );
235
248
 
236
249
  function handleRsvp(status: 'going' | 'interested') {
237
250
  if (!viewer.did) return;
238
- attendeesRef?.addAttendee({
239
- did: viewer.did,
240
- status,
241
- avatar: viewer.avatar,
242
- name: viewer.displayName || viewer.handle || viewer.did,
243
- handle: viewer.handle,
244
- url: `/p/${encodeURIComponent(viewer.handle || viewer.did)}`
245
- });
246
- if (status === 'interested') return;
251
+ attendeesRef?.addAttendee(
252
+ {
253
+ did: viewer.did,
254
+ status,
255
+ avatar: viewer.avatar,
256
+ name: viewer.displayName || viewer.handle || viewer.did,
257
+ handle: viewer.handle,
258
+ url: `/p/${encodeURIComponent(viewer.handle || viewer.did)}`
259
+ },
260
+ viewerRsvpStatus
261
+ );
262
+ viewerRsvpStatusOverride = status;
263
+ if (status === 'interested' || !share) return;
247
264
  shareModalTitle = "You're going!";
248
265
  shareModalText = `I'm going to "${eventData.name}".\n\n${shareUrl}`;
249
266
  canSetEventComments = false;
@@ -252,7 +269,8 @@
252
269
 
253
270
  function handleRsvpCancel() {
254
271
  if (!viewer.did) return;
255
- attendeesRef?.removeAttendee(viewer.did);
272
+ attendeesRef?.removeAttendee(viewer.did, viewerRsvpStatus);
273
+ viewerRsvpStatusOverride = null;
256
274
  }
257
275
  </script>
258
276
 
@@ -14,6 +14,9 @@ type $$ComponentProps = {
14
14
  * of the canonical atmo.rsvp event URL. Useful for embedders that want
15
15
  * share links to point at their own event page. */
16
16
  shareUrlOverride?: string;
17
+ /** False for an event with no public page to share, such as a private one: no share pop-up
18
+ * after creating the event or answering Going. */
19
+ share?: boolean;
17
20
  /** App-owned actions such as private reporting; omitted in embeds. */
18
21
  extraActions?: Snippet;
19
22
  /** App-owned actions below the attendee lists, with current RSVP counts. */
@@ -33,6 +33,17 @@ export type EditorAdapter = {
33
33
  features: {
34
34
  delete: boolean;
35
35
  recurring: boolean;
36
+ /**
37
+ * False to offer and upload no cover image in the editor, for an event whose page can't
38
+ * show one, such as one that isn't public. EventView doesn't read it: it shows whatever
39
+ * `eventData.media` holds.
40
+ */
41
+ images?: boolean;
42
+ /**
43
+ * False for an event with no public listing to appear in: no Public / Unlisted switch, and
44
+ * the record's discovery preference is left as it is.
45
+ */
46
+ visibility?: boolean;
36
47
  };
37
48
  putRecord(opts: {
38
49
  collection: string;
@@ -30,7 +30,8 @@ export declare function buildEventRecord(args: {
30
30
  endsAt: string;
31
31
  timezone: string;
32
32
  mode: EventMode;
33
- visibility: Visibility;
33
+ /** Null when no Public / Unlisted choice was offered: the discovery preference is left as it is. */
34
+ visibility: Visibility | null;
34
35
  theme: EventTheme;
35
36
  links: Array<{
36
37
  uri: string;
@@ -158,11 +158,14 @@ export async function buildEventRecord(args) {
158
158
  if (Array.isArray(record.locations)) {
159
159
  record.locations = normalizeEventLocations(record.locations);
160
160
  }
161
- const existingPrefs = (record.preferences ??
162
- {});
163
- record.preferences = {
164
- ...existingPrefs,
165
- showInDiscovery: visibility !== 'unlisted'
166
- };
161
+ // With no Public / Unlisted choice offered, the record keeps whatever preference it had.
162
+ if (visibility !== null) {
163
+ const existingPrefs = (record.preferences ??
164
+ {});
165
+ record.preferences = {
166
+ ...existingPrefs,
167
+ showInDiscovery: visibility !== 'unlisted'
168
+ };
169
+ }
167
170
  return record;
168
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmo-dev/kit",
3
- "version": "0.10.1",
3
+ "version": "0.11.1",
4
4
  "description": "The shared UI foundation for Atmo apps.",
5
5
  "license": "MIT",
6
6
  "repository": {