From 7706acaafa89691dba33c216e6287a8405c4c302 Mon Sep 17 00:00:00 2001 From: polwex Date: Tue, 18 Nov 2025 08:32:45 +0700 Subject: gui fixes to nostr post rendering, added nostr-tools lib for primal compatibility --- gui/src/components/nostr/Feed.tsx | 115 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 gui/src/components/nostr/Feed.tsx (limited to 'gui/src/components/nostr/Feed.tsx') diff --git a/gui/src/components/nostr/Feed.tsx b/gui/src/components/nostr/Feed.tsx new file mode 100644 index 0000000..0e74cea --- /dev/null +++ b/gui/src/components/nostr/Feed.tsx @@ -0,0 +1,115 @@ +import PostList from "@/components/feed/PostList"; +import useLocalState from "@/state/state"; +import spinner from "@/assets/triangles.svg"; +import { useState } from "react"; +import { eventsToFc } from "@/logic/nostrill"; +import Icon from "@/components/Icon"; +import toast from "react-hot-toast"; + +export default function Nostr() { + const { nostrFeed, api, relays } = useLocalState((s) => ({ + nostrFeed: s.nostrFeed, + api: s.api, + relays: s.relays, + })); + console.log({ relays }); + const [isSyncing, setIsSyncing] = useState(false); + const feed = eventsToFc(nostrFeed); + console.log({ feed }); + const refetch = () => feed; + + const handleResync = async () => { + if (!api) return; + + setIsSyncing(true); + try { + await api.syncRelays(); + toast.success("Nostr feed sync initiated"); + } catch (error) { + toast.error("Failed to sync Nostr feed"); + console.error("Sync error:", error); + } finally { + setIsSyncing(false); + } + }; + + if (Object.keys(relays).length === 0) + return ( +
+
+ +

No Nostr Relays Set Up

+

+ You haven't set any Nostr Relays to sync data from. You can do so in + the Settings page. +

+

+ If you don't know of any, we recommend the following public relays: +

+
    +
  • wss://nos.lol
  • +
  • wss://relay.damus.io
  • +
+
+
+ ); + // Show empty state with resync option when no feed data + if (!feed || !feed.feed || Object.keys(feed.feed).length === 0) { + return ( +
+
+ +

No Nostr Posts

+

+ Your Nostr feed appears to be empty. Try syncing with your relays to + fetch the latest posts. +

+ +
+
+ ); + } + + // Show feed with resync button in header + return ( +
+
+
+

Nostr Feed

+ + {Object.keys(feed.feed).length} posts + +
+ +
+ +
+ ); +} -- cgit v1.2.3