Add relay status badge, toast notifications, per-tab feed timestamps, relay UX improvements

- 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
This commit is contained in:
Jure
2026-03-23 11:28:53 +01:00
parent c9a92b9b47
commit ac4e39fcbf
12 changed files with 337 additions and 166 deletions
+1 -113
View File
@@ -4,7 +4,7 @@ import { writeTextFile } from "@tauri-apps/plugin-fs";
import { useUserStore } from "../../stores/user";
import { useMuteStore } from "../../stores/mute";
import { useBookmarkStore } from "../../stores/bookmark";
import { getNDK, getStoredRelayUrls, addRelay, removeRelay, publishRelayList } from "../../lib/nostr";
import { getStoredRelayUrls } from "../../lib/nostr";
import { useProfile } from "../../hooks/useProfile";
import { NWCWizard } from "./NWCWizard";
import { getNotificationSettings, saveNotificationSettings, ensurePermission } from "../../lib/notifications";
@@ -113,117 +113,6 @@ function MutedKeywordsSection() {
);
}
function RelayRow({ url, onRemove }: { url: string; onRemove: () => void }) {
const ndk = getNDK();
const relay = ndk.pool?.relays.get(url);
const connected = relay?.connected ?? false;
return (
<div className="flex items-center gap-3 px-3 py-2 border border-border text-[12px] group">
<span className={`w-1.5 h-1.5 rounded-full shrink-0 ${connected ? "bg-success" : "bg-text-dim"}`} />
<span className="text-text truncate flex-1 font-mono">{url}</span>
<button
onClick={onRemove}
className="text-text-dim hover:text-danger text-[10px] opacity-0 group-hover:opacity-100 transition-opacity shrink-0"
>
remove
</button>
</div>
);
}
function RelaySection() {
const { loggedIn } = useUserStore();
const [relays, setRelays] = useState<string[]>(() => getStoredRelayUrls());
const [input, setInput] = useState("");
const [error, setError] = useState<string | null>(null);
const [publishing, setPublishing] = useState(false);
const [publishedAt, setPublishedAt] = useState<number | null>(null);
const handleAdd = () => {
const url = input.trim();
if (!url) return;
if (!url.startsWith("ws://") && !url.startsWith("wss://")) {
setError("URL must start with ws:// or wss://");
return;
}
if (relays.includes(url)) {
setError("Already in list");
return;
}
addRelay(url);
setRelays(getStoredRelayUrls());
setInput("");
setError(null);
};
const handleRemove = (url: string) => {
removeRelay(url);
setRelays(getStoredRelayUrls());
};
const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === "Enter") handleAdd();
if (e.key === "Escape") setInput("");
};
const handlePublishRelayList = async () => {
setPublishing(true);
try {
await publishRelayList(getStoredRelayUrls());
setPublishedAt(Date.now());
} catch {
// ignore — publishing failure is non-critical
} finally {
setPublishing(false);
}
};
return (
<section>
<h2 className="text-text text-[11px] font-medium uppercase tracking-widest mb-2 text-text-dim">Relays</h2>
<div className="space-y-1 mb-3">
{relays.length === 0 && (
<p className="text-text-dim text-[12px] px-1">No relays configured.</p>
)}
{relays.map((url) => (
<RelayRow key={url} url={url} onRemove={() => handleRemove(url)} />
))}
</div>
<div className="flex gap-2">
<input
value={input}
onChange={(e) => { setInput(e.target.value); setError(null); }}
onKeyDown={handleKeyDown}
placeholder="wss://relay.example.com"
className="flex-1 bg-bg border border-border px-3 py-1.5 text-text text-[12px] font-mono focus:outline-none focus:border-accent/50 placeholder:text-text-dim"
/>
<button
onClick={handleAdd}
className="px-3 py-1.5 text-[11px] border border-border text-text-muted hover:text-accent hover:border-accent/40 transition-colors shrink-0"
>
add
</button>
</div>
{error && <p className="text-danger text-[11px] mt-1">{error}</p>}
{loggedIn && !!getNDK().signer && (
<div className="mt-3">
<button
onClick={handlePublishRelayList}
disabled={publishing}
className="text-[11px] px-3 py-1.5 border border-border text-text-muted hover:text-accent hover:border-accent/40 transition-colors disabled:opacity-40 disabled:cursor-not-allowed"
>
{publishing ? "publishing…" : publishedAt ? "published ✓" : "publish relay list to Nostr"}
</button>
<p className="text-text-dim text-[10px] mt-1">
Saves your relay list as a kind 10002 event (NIP-65) so other clients can find your notes.
</p>
</div>
)}
</section>
);
}
function IdentitySection() {
const { npub, loggedIn } = useUserStore();
const [copied, setCopied] = useState(false);
@@ -391,7 +280,6 @@ export function SettingsView() {
<div className="flex-1 overflow-y-auto p-4 space-y-8">
<WalletSection />
<NotificationSection />
<RelaySection />
<ExportSection />
<IdentitySection />
<MuteSection />