@atmo-dev/kit 0.10.0 → 0.10.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,7 +7,7 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import type { Snippet } from 'svelte';
10
- import type { AttendeeInfo } from './contrail.js';
10
+ import type { AttendeeInfo, AttendeeListLoader } from './contrail.js';
11
11
  import { Avatar } from '../index.js';
12
12
  import { scale } from 'svelte/transition';
13
13
  import { flip } from 'svelte/animate';
@@ -18,13 +18,16 @@
18
18
  interested = [],
19
19
  goingCount: initialGoingCount = going.length,
20
20
  interestedCount: initialInterestedCount = interested.length,
21
- footer
21
+ footer,
22
+ loadAll
22
23
  }: {
23
24
  going?: AttendeeInfo[];
24
25
  interested?: AttendeeInfo[];
25
26
  goingCount?: number;
26
27
  interestedCount?: number;
27
28
  footer?: Snippet<[AttendeeCounts]>;
29
+ /** Fetches everyone when a list opens and the counts exceed `going`/`interested`. */
30
+ loadAll?: AttendeeListLoader;
28
31
  } = $props();
29
32
 
30
33
  let goingCountOverride: number | null = $state(null);
@@ -51,11 +54,42 @@
51
54
  let interestedOverflow = $derived(interestedCount - interestedDisplay.length);
52
55
 
53
56
  let modalAttendees = $derived(modalGroup === 'going' ? goingAttendees : interestedAttendees);
57
+ let modalCount = $derived(modalGroup === 'going' ? goingCount : interestedCount);
54
58
  let modalTitle = $derived(modalGroup === 'going' ? 'Going' : 'Interested');
55
59
 
60
+ // The sample passed in may be shorter than the counts. Fetch the rest once,
61
+ // on first open; a failed attempt retries on the next open.
62
+ let hasMore = $derived(
63
+ goingCount > goingAttendees.length || interestedCount > interestedAttendees.length
64
+ );
65
+ let loadingAll = $state(false);
66
+ let loadedAll = $state(false);
67
+
68
+ async function loadEveryone() {
69
+ if (!loadAll || loadedAll || loadingAll || !hasMore) return;
70
+ loadingAll = true;
71
+ try {
72
+ 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
+ );
81
+ loadedAll = true;
82
+ } catch {
83
+ // Keep the sample; the next open tries again.
84
+ } finally {
85
+ loadingAll = false;
86
+ }
87
+ }
88
+
56
89
  function openModal(group: 'going' | 'interested') {
57
90
  modalGroup = group;
58
91
  modalOpen = true;
92
+ void loadEveryone();
59
93
  }
60
94
 
61
95
  export function addAttendee(attendee: AttendeeInfo) {
@@ -177,7 +211,7 @@
177
211
  </div>
178
212
  {/if}
179
213
 
180
- <Modal bind:open={modalOpen} title={`${modalTitle} (${modalAttendees.length})`}>
214
+ <Modal bind:open={modalOpen} title={`${modalTitle} (${modalCount})`}>
181
215
  <div
182
216
  class="mx-4 mb-4 max-h-80 space-y-1 overflow-y-auto rounded-xl bg-base-200/30 p-2 dark:bg-base-900/50"
183
217
  >
@@ -201,5 +235,14 @@
201
235
  </div>
202
236
  </a>
203
237
  {/each}
238
+ {#if loadingAll}
239
+ <p
240
+ class="px-2 py-2 text-xs text-base-600 dark:text-base-400"
241
+ role="status"
242
+ aria-live="polite"
243
+ >
244
+ Loading…
245
+ </p>
246
+ {/if}
204
247
  </div>
205
248
  </Modal>
@@ -3,13 +3,15 @@ export interface AttendeeCounts {
3
3
  interestedCount: number;
4
4
  }
5
5
  import type { Snippet } from 'svelte';
6
- import type { AttendeeInfo } from './contrail.js';
6
+ import type { AttendeeInfo, AttendeeListLoader } from './contrail.js';
7
7
  type $$ComponentProps = {
8
8
  going?: AttendeeInfo[];
9
9
  interested?: AttendeeInfo[];
10
10
  goingCount?: number;
11
11
  interestedCount?: number;
12
12
  footer?: Snippet<[AttendeeCounts]>;
13
+ /** Fetches everyone when a list opens and the counts exceed `going`/`interested`. */
14
+ loadAll?: AttendeeListLoader;
13
15
  };
14
16
  declare const EventAttendees: import("svelte").Component<$$ComponentProps, {
15
17
  addAttendee: (attendee: AttendeeInfo) => void;
@@ -1,5 +1,10 @@
1
1
  <script lang="ts">
2
- import { eventUrl, isEventOngoing, type FlatEventRecord } from './contrail.js';
2
+ import {
3
+ eventUrl,
4
+ isEventOngoing,
5
+ type AttendeeListLoader,
6
+ type FlatEventRecord
7
+ } from './contrail.js';
3
8
  import type { EventViewData } from './view-data.js';
4
9
  import { getCDNImageBlobUrl } from './atproto-helpers.js';
5
10
  import { getEventThumbnail, getEventExternalImage } from './event-media.js';
@@ -44,7 +49,8 @@
44
49
  embedMode = false,
45
50
  shareUrlOverride,
46
51
  extraActions,
47
- attendeeActions
52
+ attendeeActions,
53
+ loadAttendees
48
54
  }: {
49
55
  data: EventViewData;
50
56
  adapter: EditorAdapter;
@@ -60,6 +66,9 @@
60
66
  extraActions?: Snippet;
61
67
  /** App-owned actions below the attendee lists, with current RSVP counts. */
62
68
  attendeeActions?: Snippet<[AttendeeCounts]>;
69
+ /** Fetches the complete attendee lists the first time one is opened, when
70
+ * `data.attendees` holds only a sample of the counted RSVPs. */
71
+ loadAttendees?: AttendeeListLoader;
63
72
  } = $props();
64
73
 
65
74
  let eventData: FlatEventRecord = $derived(data.eventData);
@@ -467,6 +476,7 @@
467
476
  goingCount={attendees.goingCount}
468
477
  interestedCount={attendees.interestedCount}
469
478
  footer={embedMode ? undefined : attendeeActions}
479
+ loadAll={loadAttendees}
470
480
  />
471
481
  </div>
472
482
  </div>
@@ -1,3 +1,4 @@
1
+ import { type AttendeeListLoader } from './contrail.js';
1
2
  import type { EventViewData } from './view-data.js';
2
3
  import { type AttendeeCounts } from './EventAttendees.svelte';
3
4
  import { type Snippet } from 'svelte';
@@ -17,6 +18,9 @@ type $$ComponentProps = {
17
18
  extraActions?: Snippet;
18
19
  /** App-owned actions below the attendee lists, with current RSVP counts. */
19
20
  attendeeActions?: Snippet<[AttendeeCounts]>;
21
+ /** Fetches the complete attendee lists the first time one is opened, when
22
+ * `data.attendees` holds only a sample of the counted RSVPs. */
23
+ loadAttendees?: AttendeeListLoader;
20
24
  };
21
25
  declare const EventView: import("svelte").Component<$$ComponentProps, {}, "">;
22
26
  type EventView = ReturnType<typeof EventView>;
@@ -42,6 +42,17 @@ export type AttendeeInfo = {
42
42
  handle?: string;
43
43
  url: string;
44
44
  };
45
+ /**
46
+ * Loads the complete attendee lists. `EventAttendees` calls it the first time
47
+ * a list opens when the counts exceed the attendees it was given, so apps can
48
+ * render a small hydrated sample and defer the expensive full fetch.
49
+ */
50
+ export type AttendeeListLoader = () => Promise<{
51
+ going: AttendeeInfo[];
52
+ interested: AttendeeInfo[];
53
+ goingCount?: number;
54
+ interestedCount?: number;
55
+ }>;
45
56
  export declare const RSVP_GOING = "community.lexicon.calendar.rsvp#going";
46
57
  export declare const RSVP_INTERESTED = "community.lexicon.calendar.rsvp#interested";
47
58
  /** Build the canonical path for an event. */
@@ -3,7 +3,7 @@ export type { EventViewData } from './events/view-data.js';
3
3
  export type { EditorAdapter, EditorBlobRef, EditorViewer } from './events/editor/adapter.js';
4
4
  export type { EventEditorPrefill } from './events/editor/types.js';
5
5
  export type { EventData, EventLexiconMain, EventLocationVariant, EventStatus, EventMode as EventLexiconMode } from './events/event-types.js';
6
- export type { FlatEventRecord, HostProfile, AttendeeInfo } from './events/contrail.js';
6
+ export type { FlatEventRecord, HostProfile, AttendeeInfo, AttendeeListLoader } from './events/contrail.js';
7
7
  export { eventUrl, isEventOngoing, RSVP_GOING, RSVP_INTERESTED } from './events/contrail.js';
8
8
  export * from './events/conference.js';
9
9
  export * from './events/linked-records.js';
package/dist/events.d.ts CHANGED
@@ -7,6 +7,7 @@ export { default as EventRsvp } from './events/EventRsvp.svelte';
7
7
  export { default as EventComments } from './events/EventComments.svelte';
8
8
  export { default as EventAttendees } from './events/EventAttendees.svelte';
9
9
  export type { AttendeeCounts } from './events/EventAttendees.svelte';
10
+ export type { AttendeeListLoader } from './events/contrail.js';
10
11
  export { default as StarterPackButton } from './events/StarterPackButton.svelte';
11
12
  export { default as VodPlayer } from './events/VodPlayer.svelte';
12
13
  export type { VodPlayerApi } from './events/VodPlayer.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmo-dev/kit",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "The shared UI foundation for Atmo apps.",
5
5
  "license": "MIT",
6
6
  "repository": {