diff --git a/src/app/onboarding/create/page.tsx b/src/app/onboarding/create/page.tsx index 8d213bd5..ee91734a 100644 --- a/src/app/onboarding/create/page.tsx +++ b/src/app/onboarding/create/page.tsx @@ -68,7 +68,7 @@ export default function Page() { // broadcast pool.publish(event, relays); // redirect to next step - router.push(`/onboarding/create/step-2?pubkey=${pubkey}&privkey=${privkey}`); + router.push(`/onboarding/create/step-2?pubkey=${pubkey}&privkey=${privkey}`, { forceOptimisticNavigation: true }); }, [pool, pubkey, privkey, metadata, relays, router]); return ( diff --git a/src/app/onboarding/login/page.tsx b/src/app/onboarding/login/page.tsx index 013dfec4..a0eeccfa 100644 --- a/src/app/onboarding/login/page.tsx +++ b/src/app/onboarding/login/page.tsx @@ -40,7 +40,7 @@ export default function Page() { privkey = nip19.decode(privkey).data; } if (typeof getPublicKey(privkey) === 'string') { - router.push(`/onboarding/login/step-2?privkey=${privkey}`); + router.push(`/onboarding/login/step-2?privkey=${privkey}`, { forceOptimisticNavigation: true }); } } catch (error) { setError('key', { diff --git a/src/app/page.tsx b/src/app/page.tsx index a7d7c065..7647f8b8 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -125,7 +125,9 @@ export default function Page() { undefined, () => { updateLastLogin(dateToUnix(now.current)); - timeout.current = setTimeout(() => router.replace('/nostr/newsfeed/following'), 5000); + timeout.current = setTimeout(() => { + router.replace('/nostr/newsfeed/following', { forceOptimisticNavigation: true }); + }, 5000); }, { unsubscribeOnEose: true, @@ -160,7 +162,7 @@ export default function Page() { // fetch data fetchData(account, account.follows); } else { - router.replace('/onboarding'); + router.replace('/onboarding', { forceOptimisticNavigation: true }); } }) .catch(console.error); diff --git a/src/components/channels/channelListItem.tsx b/src/components/channels/channelListItem.tsx index c5571ae6..dbdae2cb 100644 --- a/src/components/channels/channelListItem.tsx +++ b/src/components/channels/channelListItem.tsx @@ -1,17 +1,18 @@ -import { ActiveLink } from '@components/activeLink'; import { ImageWithFallback } from '@components/imageWithFallback'; import { DEFAULT_AVATAR } from '@stores/constants'; import { useChannelMetadata } from '@utils/hooks/useChannelMetadata'; +import Link from 'next/link'; + export const ChannelListItem = ({ data }: { data: any }) => { const channel = useChannelMetadata(data.event_id, data.metadata); return ( -
@@ -25,6 +26,6 @@ export const ChannelListItem = ({ data }: { data: any }) => {
{channel?.name.toLowerCase()}
- + ); }; diff --git a/src/components/chats/chatList.tsx b/src/components/chats/chatList.tsx index 5e6798bb..726bdf47 100644 --- a/src/components/chats/chatList.tsx +++ b/src/components/chats/chatList.tsx @@ -7,30 +7,35 @@ import { DEFAULT_AVATAR } from '@stores/constants'; import { getChats } from '@utils/storage'; import useLocalStorage from '@rehooks/local-storage'; -import { useRouter } from 'next/navigation'; +import Link from 'next/link'; import { useEffect, useState } from 'react'; export default function ChatList() { - const router = useRouter(); - const [list, setList] = useState([]); const [activeAccount]: any = useLocalStorage('account', {}); const profile = JSON.parse(activeAccount.metadata); - const openSelfChat = () => { - router.push(`/nostr/chat?pubkey=${activeAccount.pubkey}`); - }; - useEffect(() => { + let ignore = false; + getChats(activeAccount.id) - .then((res: any) => setList(res)) + .then((res: any) => { + if (!ignore) { + setList(res); + } + }) .catch(console.error); + + return () => { + ignore = true; + }; }, [activeAccount.id]); return (
-
openSelfChat()} +
@@ -46,7 +51,7 @@ export default function ChatList() { {profile?.display_name || profile?.name} (you)
-
+ {list.map((item) => ( ))} diff --git a/src/components/chats/chatListItem.tsx b/src/components/chats/chatListItem.tsx index aa77deea..1e58c7ce 100644 --- a/src/components/chats/chatListItem.tsx +++ b/src/components/chats/chatListItem.tsx @@ -1,4 +1,3 @@ -import { ActiveLink } from '@components/activeLink'; import { ImageWithFallback } from '@components/imageWithFallback'; import { DEFAULT_AVATAR } from '@stores/constants'; @@ -6,13 +5,15 @@ import { DEFAULT_AVATAR } from '@stores/constants'; import { useProfileMetadata } from '@utils/hooks/useProfileMetadata'; import { shortenKey } from '@utils/shortenKey'; +import Link from 'next/link'; + export const ChatListItem = ({ pubkey }: { pubkey: string }) => { const profile = useProfileMetadata(pubkey); return ( -
@@ -28,6 +29,6 @@ export const ChatListItem = ({ pubkey }: { pubkey: string }) => { {profile?.display_name || profile?.name || shortenKey(pubkey)}
-
+ ); }; diff --git a/src/components/chats/chatModal.tsx b/src/components/chats/chatModal.tsx index d2458f77..f132d644 100644 --- a/src/components/chats/chatModal.tsx +++ b/src/components/chats/chatModal.tsx @@ -11,7 +11,7 @@ export const ChatModal = () => { useEffect(() => { getPlebs() - .then((res) => setPlebs(res)) + .then((res: any) => setPlebs(res)) .catch(console.error); }, []); @@ -19,7 +19,7 @@ export const ChatModal = () => {
-
+
diff --git a/src/components/chats/chatModalUser.tsx b/src/components/chats/chatModalUser.tsx index 88bbe429..bf2cbbf9 100644 --- a/src/components/chats/chatModalUser.tsx +++ b/src/components/chats/chatModalUser.tsx @@ -11,7 +11,7 @@ export const ChatModalUser = ({ data }: { data: any }) => { const profile = JSON.parse(data.metadata); const openNewChat = () => { - router.push(`/chats/${data.pubkey}`); + router.push(`/nostr/chat?pubkey=${data.pubkey}`, { forceOptimisticNavigation: true }); }; return ( diff --git a/src/components/multiAccounts/activeAccount.tsx b/src/components/multiAccounts/activeAccount.tsx index 52c67bc9..90cdc165 100644 --- a/src/components/multiAccounts/activeAccount.tsx +++ b/src/components/multiAccounts/activeAccount.tsx @@ -14,7 +14,7 @@ export const ActiveAccount = ({ user }: { user: any }) => { const userData = JSON.parse(user.metadata); const openProfilePage = () => { - router.push(`/nostr/users/${user.pubkey}`); + router.push(`/nostr/user?pubkey=${user.pubkey}`, { forceOptimisticNavigation: true }); }; const copyPublicKey = async () => { diff --git a/src/components/note/base.tsx b/src/components/note/base.tsx index e9e146a9..42856031 100644 --- a/src/components/note/base.tsx +++ b/src/components/note/base.tsx @@ -22,13 +22,13 @@ export const NoteBase = memo(function NoteBase({ event }: { event: any }) { const openUserPage = (e) => { e.stopPropagation(); - router.push(`/nostr/user?pubkey=${event.pubkey}`); + router.push(`/nostr/user?pubkey=${event.pubkey}`, { forceOptimisticNavigation: true }); }; const openThread = (e) => { const selection = window.getSelection(); if (selection.toString().length === 0) { - router.push(`/nostr/newsfeed/note?id=${event.parent_id}`); + router.push(`/nostr/newsfeed/note?id=${event.parent_id}`, { forceOptimisticNavigation: true }); } else { e.stopPropagation(); } diff --git a/src/components/note/meta/comment.tsx b/src/components/note/meta/comment.tsx index 00102710..8e5717c4 100644 --- a/src/components/note/meta/comment.tsx +++ b/src/components/note/meta/comment.tsx @@ -34,7 +34,7 @@ export const NoteComment = ({ const profile = activeAccount.metadata ? JSON.parse(activeAccount.metadata) : null; const openThread = () => { - router.push(`/nostr/newsfeed/${eventID}`); + router.push(`/nostr/newsfeed/note?id=${eventID}`, { forceOptimisticNavigation: true }); }; const submitEvent = () => { diff --git a/src/components/note/rootNote.tsx b/src/components/note/rootNote.tsx index f09d582d..a3678207 100644 --- a/src/components/note/rootNote.tsx +++ b/src/components/note/rootNote.tsx @@ -16,13 +16,13 @@ export const RootNote = memo(function RootNote({ event }: { event: any }) { const openUserPage = (e) => { e.stopPropagation(); - router.push(`/nostr/user?pubkey=${event.pubkey}`); + router.push(`/nostr/user?pubkey=${event.pubkey}`, { forceOptimisticNavigation: true }); }; const openThread = (e) => { const selection = window.getSelection(); if (selection.toString().length === 0) { - router.push(`/nostr/newsfeed/note?id=${event.parent_id}`); + router.push(`/nostr/newsfeed/note?id=${event.parent_id}`, { forceOptimisticNavigation: true }); } else { e.stopPropagation(); }