From 7706acaafa89691dba33c216e6287a8405c4c302 Mon Sep 17 00:00:00 2001
From: polwex <polwex@sortug.com>
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/pages/Feed.tsx | 91 ++------------------------------------------------
 1 file changed, 2 insertions(+), 89 deletions(-)

(limited to 'gui/src/pages/Feed.tsx')

diff --git a/gui/src/pages/Feed.tsx b/gui/src/pages/Feed.tsx
index ac596dd..02f7b1a 100644
--- a/gui/src/pages/Feed.tsx
+++ b/gui/src/pages/Feed.tsx
@@ -8,10 +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 { eventsToFc } from "@/logic/nostrill";
 import { ErrorPage } from "@/Router";
+import NostrFeed from "@/components/nostr/Feed";
 
 type FeedType = "global" | "following" | "nostr";
 function Loader() {
@@ -59,7 +57,7 @@ function FeedPage({ t }: { t: FeedType }) {
         ) : active === "following" ? (
           <Following />
         ) : active === "nostr" ? (
-          <Nostr />
+          <NostrFeed />
         ) : null}
       </div>
     </main>
@@ -102,91 +100,6 @@ function Following() {
     </div>
   );
 }
-function Nostr() {
-  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;
-
-  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 (
-      <div className="nostr-empty-state">
-        <div className="empty-content">
-          <Icon name="nostr" size={48} color="textMuted" />
-          <h3>No Nostr Posts</h3>
-          <p>
-            Your Nostr feed appears to be empty. Try syncing with your relays to
-            fetch the latest posts.
-          </p>
-          <button
-            onClick={handleResync}
-            disabled={isSyncing}
-            className="resync-btn"
-          >
-            {isSyncing ? (
-              <>
-                <img src={spinner} alt="Loading" className="btn-spinner" />
-                Syncing...
-              </>
-            ) : (
-              <>
-                <Icon name="settings" size={16} />
-                Sync Relays
-              </>
-            )}
-          </button>
-        </div>
-      </div>
-    );
-  }
-
-  // Show feed with resync button in header
-  return (
-    <div className="nostr-feed">
-      <div className="nostr-header">
-        <div className="feed-info">
-          <h4>Nostr Feed</h4>
-          <span className="post-count">
-            {Object.keys(feed.feed).length} posts
-          </span>
-        </div>
-        <button
-          onClick={handleResync}
-          disabled={isSyncing}
-          className="resync-btn-small"
-          title="Sync with Nostr relays"
-        >
-          {isSyncing ? (
-            <img src={spinner} alt="Loading" className="btn-spinner-small" />
-          ) : (
-            <Icon name="settings" size={16} />
-          )}
-        </button>
-      </div>
-      <PostList data={feed} refetch={refetch} />
-    </div>
-  );
-}
 
 export default Loader;
 // TODO
-- 
cgit v1.2.3

