@hadoku/game-ui 0.1.15 → 0.1.17

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,11 +2,11 @@ import { type AttachedForm } from '@wolffm/platform-wire/events';
2
2
  import { type Fetch } from '../http.js';
3
3
  export type Poll = AttachedForm;
4
4
  export declare function pollsClient(fetchImpl?: Fetch): {
5
- /** The open forms; one the page cannot read is skipped, never the whole list. A refused read throws. */
5
+ /** The listed forms; one the page cannot read is skipped, never the whole list. A refused read throws. */
6
6
  list(): Promise<Poll[]>;
7
7
  };
8
8
  /** Soonest to close first; a form with no closing time last. */
9
- export declare function openPolls(polls: readonly Poll[]): Poll[];
9
+ export declare function bySoonestClose(polls: readonly Poll[]): Poll[];
10
10
  type PollsClient = Pick<ReturnType<typeof pollsClient>, 'list'>;
11
11
  /** Tests swap the client (and reset the store) here. */
12
12
  export declare function setPollsClient(next: PollsClient): void;
@@ -1,7 +1,8 @@
1
1
  /*
2
- * The Upcoming card's Polls page: the open Rally forms attached to events (`GET /api/events/forms`,
2
+ * The Upcoming card's Polls page: the Rally forms attached to events (`GET /api/events/forms`,
3
3
  * `games/magic/server/src/http/events.ts`), each Rally's own summary of it plus who attached it
4
- * (`AttachedForm`). Its Open button goes to the form on Rally.
4
+ * (`AttachedForm`). The server decides which are listed: the open ones, and to whoever attached it
5
+ * a closed one still waiting for its event. Its Open button goes to the form on Rally.
5
6
  */
6
7
  import { useEffect, useState } from 'react';
7
8
  import { AttachedFormSchema } from '@wolffm/platform-wire/events';
@@ -10,7 +11,7 @@ import { rereadWhileVisible } from "../visible.js";
10
11
  const defaultFetch = (input, init) => fetch(input, init);
11
12
  export function pollsClient(fetchImpl = defaultFetch) {
12
13
  return {
13
- /** The open forms; one the page cannot read is skipped, never the whole list. A refused read throws. */
14
+ /** The listed forms; one the page cannot read is skipped, never the whole list. A refused read throws. */
14
15
  async list() {
15
16
  const res = await getJson(apiUrl('events/forms'), fetchImpl);
16
17
  const body = await bodyOf(res);
@@ -19,13 +20,13 @@ export function pollsClient(fetchImpl = defaultFetch) {
19
20
  const forms = isRecord(body) && Array.isArray(body.forms) ? body.forms : [];
20
21
  return forms.flatMap((f) => {
21
22
  const poll = AttachedFormSchema.safeParse(f);
22
- return poll.success && poll.data.status === 'open' ? [poll.data] : [];
23
+ return poll.success ? [poll.data] : [];
23
24
  });
24
25
  },
25
26
  };
26
27
  }
27
28
  /** Soonest to close first; a form with no closing time last. */
28
- export function openPolls(polls) {
29
+ export function bySoonestClose(polls) {
29
30
  const closes = (p) => (p.closesAt === null ? Infinity : Date.parse(p.closesAt));
30
31
  return [...polls].sort((a, b) => closes(a) - closes(b));
31
32
  }
@@ -57,7 +58,7 @@ export async function refreshPolls() {
57
58
  const mine = ++generation;
58
59
  let next;
59
60
  try {
60
- next = openPolls(await client.list());
61
+ next = bySoonestClose(await client.list());
61
62
  }
62
63
  catch {
63
64
  // Not reachable for a moment: the page keeps what it showed, or says there are none.
@@ -74,8 +75,7 @@ export async function refreshPolls() {
74
75
  */
75
76
  export async function pollAttached(form) {
76
77
  generation += 1;
77
- if (form.status === 'open')
78
- publish(openPolls([...(current ?? []).filter((p) => p.id !== form.id), form]));
78
+ publish(bySoonestClose([...(current ?? []).filter((p) => p.id !== form.id), form]));
79
79
  await refreshPolls();
80
80
  }
81
81
  /** How often a mounted reader re-reads the polls, so another organizer's form shows without a reload (as `./events.ts` does). */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/game-ui",
3
- "version": "0.1.15",
4
- "gitHead": "e7913f63c2dd654746ec20121f07cc1f611a63d4",
3
+ "version": "0.1.17",
4
+ "gitHead": "e955dbb35206a70f8c047896214df8491d80b6a1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The browser parts any hosted game shares, above ui-shell: the room shell and session, seats and looks, the room route, the front page's generic pieces (gate, polls, gallery, patch notes), the bundle slot and relay channel a game's client mounts in, settings and trim screens, the HTTP and socket helpers, and the generic components (modal, popover, avatar, action button, radio cards). Knows no game; Magic's UI (games/magic/ui) plugs in, composed by the site (apps/ui). MIT; imports only react, react-dom, socket.io-client, @wolffm/* and the platform packages.",
@@ -21,14 +21,14 @@
21
21
  "react-dom": "^19.2.8"
22
22
  },
23
23
  "dependencies": {
24
- "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.15",
25
- "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.15",
24
+ "@wolffm/platform-wire": "npm:@hadoku/platform-wire@0.1.17",
25
+ "@wolffm/ui-shell": "npm:@hadoku/ui-shell@0.1.17",
26
26
  "@wolffm/prefs-client": "npm:@hadoku/prefs-client@^1.1.27",
27
- "@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.98",
28
- "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.98",
27
+ "@wolffm/rooms-client": "npm:@hadoku/rooms-client@^0.45.99",
28
+ "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.99",
29
29
  "@wolffm/task-ui-components": "npm:@hadoku/task-ui-components@^4.23.35",
30
30
  "@wolffm/themes": "npm:@hadoku/themes@^5.14.4",
31
- "@wolffm/watchparty-ui": "npm:@hadoku/watchparty-ui@^0.45.98",
31
+ "@wolffm/watchparty-ui": "npm:@hadoku/watchparty-ui@^0.45.99",
32
32
  "socket.io-client": "^4.8.3",
33
33
  "zod": "4.5.4"
34
34
  },