From 985fa2f7c99832cdf3c3351d2273c8fd05402b78 Mon Sep 17 00:00:00 2001 From: polwex Date: Wed, 17 Sep 2025 21:45:18 +0700 Subject: basic comms working --- front/src/pages/Feed.tsx | 84 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 2 deletions(-) (limited to 'front/src/pages/Feed.tsx') diff --git a/front/src/pages/Feed.tsx b/front/src/pages/Feed.tsx index 65dee64..5902162 100644 --- a/front/src/pages/Feed.tsx +++ b/front/src/pages/Feed.tsx @@ -8,6 +8,8 @@ import { useParams } from "wouter"; import spinner from "@/assets/triangles.svg"; import { useState } from "react"; import Composer from "@/components/composer/Composer"; +import Icon from "@/components/Icon"; +import toast from "react-hot-toast"; // import UserFeed from "./User"; import { P404 } from "@/Router"; import { isValidPatp } from "urbit-ob"; @@ -88,11 +90,89 @@ function Global() { return

Error

; } function Nostr() { - const { nostrFeed } = useLocalState(); + const { nostrFeed, api } = useLocalState((s) => ({ + nostrFeed: s.nostrFeed, + api: s.api, + })); + const [isSyncing, setIsSyncing] = useState(false); const feed = eventsToFc(nostrFeed); console.log({ feed }); const refetch = () => feed; - return ; + + 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); + } + }; + + // 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 + +
+ +
+ +
+ ); } export default Loader; -- cgit v1.2.3