mirror of
https://github.com/hoornet/vega.git
synced 2026-05-07 12:49:13 -07:00
- Relay status badge in feed header: shows connected/total relay count with color coding (green >75%, yellow 25-75%, red <25%), hover tooltip with per-relay status - Toast notification system: transient messages for connection lost, reconnecting, relay reset, and back-online events - Per-tab "last updated" relative timestamp in feed header (global, following, trending tracked independently) - Consolidated all relay management into RelaysView (removed duplicate relay section from Settings); per-relay remove button on health cards - Show all supported NIP badges on relay cards (was filtering to 11 notable) - Tooltips on relay status dots explaining green/yellow/red/gray meaning - Fix relay removal with trailing-slash URL normalization - Fix stale health results lingering after relay removal - Add acknowledgements section to README
32 lines
980 B
TypeScript
32 lines
980 B
TypeScript
import { create } from "zustand";
|
|
import { checkAllRelays, type RelayHealthResult } from "../lib/nostr/relayHealth";
|
|
import { getStoredRelayUrls } from "../lib/nostr";
|
|
|
|
interface RelayHealthState {
|
|
results: RelayHealthResult[];
|
|
checking: boolean;
|
|
lastChecked: number | null;
|
|
checkAll: () => Promise<void>;
|
|
}
|
|
|
|
export const useRelayHealthStore = create<RelayHealthState>((set, get) => ({
|
|
results: [],
|
|
checking: false,
|
|
lastChecked: null,
|
|
|
|
checkAll: async () => {
|
|
if (get().checking) return;
|
|
// Immediately prune stale results for relays no longer stored
|
|
const currentUrls = new Set(getStoredRelayUrls());
|
|
const pruned = get().results.filter((r) => currentUrls.has(r.url));
|
|
set({ checking: true, results: pruned });
|
|
try {
|
|
const urls = Array.from(currentUrls);
|
|
const results = await checkAllRelays(urls);
|
|
set({ results, lastChecked: Date.now(), checking: false });
|
|
} catch {
|
|
set({ checking: false });
|
|
}
|
|
},
|
|
}));
|