diff --git a/src/feed/TimelineFeed.js b/src/feed/TimelineFeed.js index 82f1b9a7..a1e38edb 100644 --- a/src/feed/TimelineFeed.js +++ b/src/feed/TimelineFeed.js @@ -3,13 +3,13 @@ import EventKind from "../nostr/EventKind"; import { Subscriptions } from "../nostr/Subscriptions"; import useSubscription from "./Subscription"; -export default function useTimelineFeed(pubKeys) { +export default function useTimelineFeed(pubKeys, global = false) { const sub = useMemo(() => { if (!Array.isArray(pubKeys)) { pubKeys = [pubKeys]; } - if (!pubKeys || pubKeys.length === 0) { + if (!global && (!pubKeys || pubKeys.length === 0)) { return null; } diff --git a/src/pages/Layout.js b/src/pages/Layout.js index b13fb6c8..cf55ec71 100644 --- a/src/pages/Layout.js +++ b/src/pages/Layout.js @@ -14,6 +14,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; export default function Layout(props) { const dispatch = useDispatch(); const navigate = useNavigate(); + const isInit = useSelector(s => s.login.loggedOut); const key = useSelector(s => s.login.publicKey); const relays = useSelector(s => s.login.relays); const notifications = useSelector(s => s.login.notifications); @@ -46,6 +47,10 @@ export default function Layout(props) { ) } + if (typeof isInit !== "boolean") { + return null; + } + return (
diff --git a/src/pages/Root.js b/src/pages/Root.js index 05c04b5f..86c32ad4 100644 --- a/src/pages/Root.js +++ b/src/pages/Root.js @@ -3,11 +3,12 @@ import { useSelector } from "react-redux"; import Note from "../element/Note"; import useTimelineFeed from "../feed/TimelineFeed"; import { NoteCreator } from "../element/NoteCreator"; +import { useMemo } from "react"; export default function RootPage() { - const pubKey = useSelector(s => s.login.publicKey); - const follows = useSelector(a => a.login.follows); - const { notes } = useTimelineFeed(follows); + const [loggedOut, pubKey, follows] = useSelector(s => [s.login.loggedOut, s.login.publicKey, s.login.follows]); + + const { notes } = useTimelineFeed(follows, loggedOut === true); function followHints() { if (follows?.length === 0 && pubKey) { diff --git a/src/state/Login.js b/src/state/Login.js index b122fee5..8093cb4d 100644 --- a/src/state/Login.js +++ b/src/state/Login.js @@ -8,6 +8,11 @@ const NotificationsReadItem = "notifications-read"; const LoginSlice = createSlice({ name: "Login", initialState: { + /** + * If there is no login + */ + loggedOut: null, + /** * Current user private key */ @@ -49,7 +54,11 @@ const LoginSlice = createSlice({ if (state.privateKey) { window.localStorage.removeItem(Nip07PublicKeyItem); // reset nip07 if using private key state.publicKey = secp.utils.bytesToHex(secp.schnorr.getPublicKey(state.privateKey, true)); + state.loggedOut = false; + } else { + state.loggedOut = true; } + state.relays = { "wss://nostr.v0l.io": { read: true, write: true }, "wss://relay.damus.io": { read: true, write: true },