Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: one stream hook, and one rule for confirming a change

Part of the unification order in the UI sweep issue (steps e and f).

The terminal, turn-state and message feeds each opened an EventSource, tracked
connecting/open/reconnecting/closed, probed the session when the browser gave
up, and reconnected through an attempt counter. openStream (no Preact, source
injected, tested with a fake) and useEventStream now own that; each feed keeps
only what it does with a message.

A change confirmed itself three ways: a toast, inline, or nothing. The design
guide now says forms confirm inline, actions on a card in a refreshing list
confirm with a toast, and a change the page already shows says nothing. Fire
now, saving a schedule and removing an egress entry gain the toast they lacked.
This commit is contained in:
iris 2026-11-26 00:57:53 +01:00
commit bbdd32c2e0

View file

@ -34,8 +34,9 @@ function useDomainList(url: string) {
reload,
} = useResource((signal) => fetchJson<Listing>(url, signal), [url]);
async function remove(entry: AllowedDomain) {
if (busy) return;
/** True when the entry was removed. */
async function remove(entry: AllowedDomain): Promise<boolean> {
if (busy) return false;
setBusy(true);
try {
const r = await fetch(url, {
@ -45,12 +46,14 @@ function useDomainList(url: string) {
});
if (!r.ok) {
setRemoveError(await readApiError(r));
return;
return false;
}
setRemoveError(null);
reload();
return true;
} catch (e: unknown) {
setRemoveError({ detail: String(e) });
return false;
} finally {
setBusy(false);
}