From 01dff9f3c8289db5d54d82d41d73e7e1ab46074d Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Tue, 25 Apr 2023 15:24:11 +0700
Subject: [PATCH] update relay list
---
src/components/channels/channelListItem.tsx | 8 +++-
.../channels/createChannelModal.tsx | 21 ++--------
.../channels/messages/hideMessageButton.tsx | 4 +-
.../channels/messages/muteButton.tsx | 4 +-
src/components/eventCollector.tsx | 19 +++------
src/components/form/base.tsx | 4 +-
src/components/form/channel.tsx | 4 +-
src/components/form/chat.tsx | 4 +-
src/components/form/comment.tsx | 4 +-
src/components/note/meta/comment.tsx | 4 +-
src/components/note/meta/reaction.tsx | 4 +-
src/components/note/metadata.tsx | 4 +-
src/components/note/parent.tsx | 4 +-
src/components/note/quote.tsx | 4 +-
src/components/note/rootNote.tsx | 4 +-
src/components/profile/followers.tsx | 4 +-
src/components/profile/follows.tsx | 4 +-
src/components/profile/metadata.tsx | 4 +-
src/components/profile/notes.tsx | 4 +-
src/components/relaysProvider.tsx | 4 +-
src/pages/channel/index.page.tsx | 4 +-
src/pages/chat/index.page.tsx | 4 +-
src/pages/index.page.tsx | 4 +-
src/pages/onboarding/create/index.page.tsx | 4 +-
.../onboarding/create/step-2/index.page.tsx | 4 +-
.../onboarding/login/step-2/index.page.tsx | 4 +-
src/stores/channel.tsx | 10 -----
src/stores/constants.tsx | 41 +++++++------------
src/utils/hooks/useChannelMetadata.tsx | 4 +-
29 files changed, 77 insertions(+), 118 deletions(-)
diff --git a/src/components/channels/channelListItem.tsx b/src/components/channels/channelListItem.tsx
index 24aa3631..f84ac54d 100644
--- a/src/components/channels/channelListItem.tsx
+++ b/src/components/channels/channelListItem.tsx
@@ -20,8 +20,12 @@ export const ChannelListItem = ({ data }: { data: any }) => {
pageID === data.event_id ? 'dark:bg-zinc-900 dark:text-zinc-100 hover:dark:bg-zinc-800' : ''
)}
>
-
-

+
+
{channel?.name}
diff --git a/src/components/channels/createChannelModal.tsx b/src/components/channels/createChannelModal.tsx
index 176a33b7..80a8e5ca 100644
--- a/src/components/channels/createChannelModal.tsx
+++ b/src/components/channels/createChannelModal.tsx
@@ -2,15 +2,13 @@ import { AccountContext } from '@components/accountProvider';
import { AvatarUploader } from '@components/avatarUploader';
import { RelayContext } from '@components/relaysProvider';
-import { defaultChannelsAtom } from '@stores/channel';
-import { DEFAULT_AVATAR, MESSAGE_RELAYS } from '@stores/constants';
+import { DEFAULT_AVATAR, WRITEONLY_RELAYS } from '@stores/constants';
import { dateToUnix } from '@utils/getDate';
import { createChannel } from '@utils/storage';
import { Dialog, Transition } from '@headlessui/react';
import { Cancel, Plus } from 'iconoir-react';
-import { useSetAtom } from 'jotai';
import { getEventHash, signEvent } from 'nostr-tools';
import { Fragment, useContext, useEffect, useState } from 'react';
import { useForm } from 'react-hook-form';
@@ -24,8 +22,6 @@ export const CreateChannelModal = () => {
const [image, setImage] = useState(DEFAULT_AVATAR);
const [loading, setLoading] = useState(false);
- const setChannel = useSetAtom(defaultChannelsAtom);
-
const closeModal = () => {
setIsOpen(false);
};
@@ -56,21 +52,12 @@ export const CreateChannelModal = () => {
event.sig = signEvent(event, activeAccount.privkey);
// publish channel
- pool.publish(event, MESSAGE_RELAYS);
- // update jotai state
- setChannel((prev: any) => [
- ...prev,
- {
- event_id: event.id,
- metadata: { name: data.name, picture: data.picture, about: data.about },
- created_at: event.created_at,
- },
- ]);
+ pool.publish(event, WRITEONLY_RELAYS);
+ // insert to database
+ createChannel(event.id, event.pubkey, event.content, event.created_at);
// reset form
reset();
setTimeout(() => {
- // insert to database
- createChannel(event.id, event.content, event.created_at);
// close modal
setIsOpen(false);
// redirect to channel page
diff --git a/src/components/channels/messages/hideMessageButton.tsx b/src/components/channels/messages/hideMessageButton.tsx
index eb85c5f7..4861c35b 100644
--- a/src/components/channels/messages/hideMessageButton.tsx
+++ b/src/components/channels/messages/hideMessageButton.tsx
@@ -2,7 +2,7 @@ import { AccountContext } from '@components/accountProvider';
import { RelayContext } from '@components/relaysProvider';
import Tooltip from '@components/tooltip';
-import { MESSAGE_RELAYS } from '@stores/constants';
+import { WRITEONLY_RELAYS } from '@stores/constants';
import { dateToUnix } from '@utils/getDate';
@@ -26,7 +26,7 @@ export const HideMessageButton = ({ id }: { id: string }) => {
event.sig = signEvent(event, activeAccount.privkey);
// publish note
- pool.publish(event, MESSAGE_RELAYS);
+ pool.publish(event, WRITEONLY_RELAYS);
}, [activeAccount.pubkey, activeAccount.privkey, id, pool]);
return (
diff --git a/src/components/channels/messages/muteButton.tsx b/src/components/channels/messages/muteButton.tsx
index 398a4c82..55ca330a 100644
--- a/src/components/channels/messages/muteButton.tsx
+++ b/src/components/channels/messages/muteButton.tsx
@@ -2,7 +2,7 @@ import { AccountContext } from '@components/accountProvider';
import { RelayContext } from '@components/relaysProvider';
import Tooltip from '@components/tooltip';
-import { MESSAGE_RELAYS } from '@stores/constants';
+import { WRITEONLY_RELAYS } from '@stores/constants';
import { dateToUnix } from '@utils/getDate';
@@ -26,7 +26,7 @@ export const MuteButton = ({ pubkey }: { pubkey: string }) => {
event.sig = signEvent(event, activeAccount.privkey);
// publish note
- pool.publish(event, MESSAGE_RELAYS);
+ pool.publish(event, WRITEONLY_RELAYS);
};
return (
diff --git a/src/components/eventCollector.tsx b/src/components/eventCollector.tsx
index edd7d06a..f1ff6e81 100644
--- a/src/components/eventCollector.tsx
+++ b/src/components/eventCollector.tsx
@@ -2,11 +2,11 @@ import { AccountContext } from '@components/accountProvider';
import { NetworkStatusIndicator } from '@components/networkStatusIndicator';
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import { hasNewerNoteAtom } from '@stores/note';
import { dateToUnix } from '@utils/getDate';
-import { createChannel, createChat, createNote, updateAccount } from '@utils/storage';
+import { createChat, createNote, updateAccount } from '@utils/storage';
import { getParentID, nip02ToArray } from '@utils/transform';
import { useSetAtom } from 'jotai';
@@ -17,11 +17,10 @@ export default function EventCollector() {
const activeAccount: any = useContext(AccountContext);
const setHasNewerNote = useSetAtom(hasNewerNoteAtom);
- const follows = activeAccount.follows ? JSON.parse(activeAccount.follows) : [];
-
const now = useRef(new Date());
const subscribe = useCallback(async () => {
+ const follows = activeAccount.follows ? JSON.parse(activeAccount.follows) : [];
const unsubscribe = pool.subscribe(
[
{
@@ -38,12 +37,8 @@ export default function EventCollector() {
'#p': [activeAccount.pubkey],
since: dateToUnix(now.current),
},
- {
- kinds: [40],
- since: dateToUnix(now.current),
- },
],
- DEFAULT_RELAYS,
+ READONLY_RELAYS,
(event: { kind: number; tags: string[]; id: string; pubkey: string; content: string; created_at: number }) => {
switch (event.kind) {
// metadata
@@ -91,10 +86,6 @@ export default function EventCollector() {
''
);
break;
- // channel
- case 40:
- createChannel(event.id, event.content, event.created_at);
- break;
default:
break;
}
@@ -104,7 +95,7 @@ export default function EventCollector() {
return () => {
unsubscribe();
};
- }, [activeAccount.id, activeAccount.pubkey, follows, pool, setHasNewerNote]);
+ }, [activeAccount.id, activeAccount.pubkey, activeAccount.follows, pool, setHasNewerNote]);
useEffect(() => {
let ignore = false;
diff --git a/src/components/form/base.tsx b/src/components/form/base.tsx
index 66f24f2e..1ab7cbe8 100644
--- a/src/components/form/base.tsx
+++ b/src/components/form/base.tsx
@@ -2,7 +2,7 @@ import { AccountContext } from '@components/accountProvider';
import { ImagePicker } from '@components/form/imagePicker';
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { WRITEONLY_RELAYS } from '@stores/constants';
import { noteContentAtom } from '@stores/note';
import { dateToUnix } from '@utils/getDate';
@@ -31,7 +31,7 @@ export default function FormBase() {
event.sig = signEvent(event, activeAccount.privkey);
// publish note
- pool.publish(event, DEFAULT_RELAYS);
+ pool.publish(event, WRITEONLY_RELAYS);
// reset form
resetValue();
// send notification
diff --git a/src/components/form/channel.tsx b/src/components/form/channel.tsx
index 54fc86d0..2aba9e4b 100644
--- a/src/components/form/channel.tsx
+++ b/src/components/form/channel.tsx
@@ -4,7 +4,7 @@ import { RelayContext } from '@components/relaysProvider';
import { UserMini } from '@components/user/mini';
import { channelContentAtom, channelReplyAtom } from '@stores/channel';
-import { MESSAGE_RELAYS } from '@stores/constants';
+import { FULL_RELAYS } from '@stores/constants';
import { dateToUnix } from '@utils/getDate';
@@ -48,7 +48,7 @@ export const FormChannel = ({ eventId }: { eventId: string | string[] }) => {
event.sig = signEvent(event, activeAccount.privkey);
// publish note
- pool.publish(event, MESSAGE_RELAYS);
+ pool.publish(event, FULL_RELAYS);
// reset state
resetValue();
// reset channel reply
diff --git a/src/components/form/chat.tsx b/src/components/form/chat.tsx
index 9aeb4fdf..37b5af70 100644
--- a/src/components/form/chat.tsx
+++ b/src/components/form/chat.tsx
@@ -3,7 +3,7 @@ import { ImagePicker } from '@components/form/imagePicker';
import { RelayContext } from '@components/relaysProvider';
import { chatContentAtom } from '@stores/chat';
-import { MESSAGE_RELAYS } from '@stores/constants';
+import { FULL_RELAYS } from '@stores/constants';
import { dateToUnix } from '@utils/getDate';
@@ -39,7 +39,7 @@ export default function FormChat({ receiverPubkey }: { receiverPubkey: string })
event.id = getEventHash(event);
event.sig = signEvent(event, activeAccount.privkey);
// publish note
- pool.publish(event, MESSAGE_RELAYS);
+ pool.publish(event, FULL_RELAYS);
// reset state
resetValue();
})
diff --git a/src/components/form/comment.tsx b/src/components/form/comment.tsx
index fcd36363..af58745f 100644
--- a/src/components/form/comment.tsx
+++ b/src/components/form/comment.tsx
@@ -1,7 +1,7 @@
import { AccountContext } from '@components/accountProvider';
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { WRITEONLY_RELAYS } from '@stores/constants';
import { dateToUnix } from '@utils/getDate';
@@ -28,7 +28,7 @@ export default function FormComment({ eventID }: { eventID: any }) {
event.sig = signEvent(event, activeAccount.privkey);
// publish note
- pool.publish(event, DEFAULT_RELAYS);
+ pool.publish(event, WRITEONLY_RELAYS);
// send notification
// sendNotification('Comment has been published successfully');
};
diff --git a/src/components/note/meta/comment.tsx b/src/components/note/meta/comment.tsx
index 4abfcafc..c8b3db49 100644
--- a/src/components/note/meta/comment.tsx
+++ b/src/components/note/meta/comment.tsx
@@ -2,7 +2,7 @@ import { AccountContext } from '@components/accountProvider';
import { RelayContext } from '@components/relaysProvider';
import { UserExtend } from '@components/user/extend';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { WRITEONLY_RELAYS } from '@stores/constants';
import { dateToUnix } from '@utils/getDate';
@@ -56,7 +56,7 @@ export const NoteComment = ({
event.id = getEventHash(event);
event.sig = signEvent(event, activeAccount.privkey);
- pool.publish(event, DEFAULT_RELAYS);
+ pool.publish(event, WRITEONLY_RELAYS);
setIsOpen(false);
};
diff --git a/src/components/note/meta/reaction.tsx b/src/components/note/meta/reaction.tsx
index aca22eb2..398c9160 100644
--- a/src/components/note/meta/reaction.tsx
+++ b/src/components/note/meta/reaction.tsx
@@ -1,7 +1,7 @@
import { AccountContext } from '@components/accountProvider';
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { WRITEONLY_RELAYS } from '@stores/constants';
import { dateToUnix } from '@utils/getDate';
@@ -43,7 +43,7 @@ export const NoteReaction = ({
event.id = getEventHash(event);
event.sig = signEvent(event, activeAccount.privkey);
// publish event to all relays
- pool.publish(event, DEFAULT_RELAYS);
+ pool.publish(event, WRITEONLY_RELAYS);
// update state to change icon to filled heart
setIsReact(true);
// update counter
diff --git a/src/components/note/metadata.tsx b/src/components/note/metadata.tsx
index 66419c7a..6e03d657 100644
--- a/src/components/note/metadata.tsx
+++ b/src/components/note/metadata.tsx
@@ -3,7 +3,7 @@ import { NoteComment } from '@components/note/meta/comment';
import { NoteReaction } from '@components/note/meta/reaction';
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import { memo, useContext, useEffect, useState } from 'react';
@@ -34,7 +34,7 @@ export const NoteMetadata = memo(function NoteMetadata({
kinds: [1, 7],
},
],
- DEFAULT_RELAYS,
+ READONLY_RELAYS,
(event: any) => {
switch (event.kind) {
case 1:
diff --git a/src/components/note/parent.tsx b/src/components/note/parent.tsx
index 55079d96..486b4c8c 100644
--- a/src/components/note/parent.tsx
+++ b/src/components/note/parent.tsx
@@ -3,7 +3,7 @@ import { NoteMetadata } from '@components/note/metadata';
import { RelayContext } from '@components/relaysProvider';
import { UserExtend } from '@components/user/extend';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import { contentParser } from '@utils/parser';
import { createNote, getNoteByID } from '@utils/storage';
@@ -26,7 +26,7 @@ export const NoteParent = memo(function NoteParent({ id }: { id: string }) {
kinds: [1],
},
],
- DEFAULT_RELAYS,
+ READONLY_RELAYS,
(event: any) => {
// update state
setEvent(event);
diff --git a/src/components/note/quote.tsx b/src/components/note/quote.tsx
index 4f4bde67..ccf080bb 100644
--- a/src/components/note/quote.tsx
+++ b/src/components/note/quote.tsx
@@ -2,7 +2,7 @@ import { AccountContext } from '@components/accountProvider';
import { RelayContext } from '@components/relaysProvider';
import { UserExtend } from '@components/user/extend';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import { contentParser } from '@utils/parser';
import { createNote, getNoteByID } from '@utils/storage';
@@ -25,7 +25,7 @@ export const NoteQuote = memo(function NoteQuote({ id }: { id: string }) {
kinds: [1],
},
],
- DEFAULT_RELAYS,
+ READONLY_RELAYS,
(event: any) => {
// update state
setEvent(event);
diff --git a/src/components/note/rootNote.tsx b/src/components/note/rootNote.tsx
index b73b5728..f43cb3ca 100644
--- a/src/components/note/rootNote.tsx
+++ b/src/components/note/rootNote.tsx
@@ -2,7 +2,7 @@ import { NoteMetadata } from '@components/note/metadata';
import { RelayContext } from '@components/relaysProvider';
import { UserExtend } from '@components/user/extend';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import { contentParser } from '@utils/parser';
@@ -38,7 +38,7 @@ export const RootNote = memo(function RootNote({ event }: { event: any }) {
kinds: [1],
},
],
- DEFAULT_RELAYS,
+ READONLY_RELAYS,
(event: any) => {
setData(event);
setContent(contentParser(event.content, event.tags));
diff --git a/src/components/profile/followers.tsx b/src/components/profile/followers.tsx
index 66c72578..16f1d23e 100644
--- a/src/components/profile/followers.tsx
+++ b/src/components/profile/followers.tsx
@@ -1,7 +1,7 @@
import { RelayContext } from '@components/relaysProvider';
import { UserFollow } from '@components/user/follow';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import destr from 'destr';
import { Author } from 'nostr-relaypool';
@@ -12,7 +12,7 @@ export default function ProfileFollowers({ id }: { id: string }) {
const [followers, setFollowers] = useState(null);
useEffect(() => {
- const user = new Author(pool, DEFAULT_RELAYS, id);
+ const user = new Author(pool, READONLY_RELAYS, id);
user.followers((res) => setFollowers(destr(res.tags)), 0, 100);
}, [id, pool]);
diff --git a/src/components/profile/follows.tsx b/src/components/profile/follows.tsx
index e1aaae25..283178f8 100644
--- a/src/components/profile/follows.tsx
+++ b/src/components/profile/follows.tsx
@@ -1,7 +1,7 @@
import { RelayContext } from '@components/relaysProvider';
import { UserFollow } from '@components/user/follow';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import { Author } from 'nostr-relaypool';
import { useContext, useEffect, useState } from 'react';
@@ -11,7 +11,7 @@ export default function ProfileFollows({ id }: { id: string }) {
const [follows, setFollows] = useState(null);
useEffect(() => {
- const user = new Author(pool, DEFAULT_RELAYS, id);
+ const user = new Author(pool, READONLY_RELAYS, id);
user.follows((res) => setFollows(res), 0);
}, [id, pool]);
diff --git a/src/components/profile/metadata.tsx b/src/components/profile/metadata.tsx
index e69fd256..6c85bf9c 100644
--- a/src/components/profile/metadata.tsx
+++ b/src/components/profile/metadata.tsx
@@ -1,6 +1,6 @@
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_AVATAR, DEFAULT_RELAYS } from '@stores/constants';
+import { DEFAULT_AVATAR, READONLY_RELAYS } from '@stores/constants';
import { shortenKey } from '@utils/shortenKey';
@@ -15,7 +15,7 @@ export default function ProfileMetadata({ id }: { id: string }) {
const [profile, setProfile] = useState(null);
useEffect(() => {
- const user = new Author(pool, DEFAULT_RELAYS, id);
+ const user = new Author(pool, READONLY_RELAYS, id);
user.metaData((res) => setProfile(destr(res.content)), 0);
}, [id, pool]);
diff --git a/src/components/profile/notes.tsx b/src/components/profile/notes.tsx
index 7c208849..961ffef3 100644
--- a/src/components/profile/notes.tsx
+++ b/src/components/profile/notes.tsx
@@ -1,7 +1,7 @@
import { NoteBase } from '@components/note/base';
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import { Author } from 'nostr-relaypool';
import { useContext, useEffect, useState } from 'react';
@@ -11,7 +11,7 @@ export default function ProfileNotes({ id }: { id: string }) {
const [data, setData] = useState([]);
useEffect(() => {
- const user = new Author(pool, DEFAULT_RELAYS, id);
+ const user = new Author(pool, READONLY_RELAYS, id);
user.text((res) => setData((data) => [...data, res]), 100, 0);
}, [id, pool]);
diff --git a/src/components/relaysProvider.tsx b/src/components/relaysProvider.tsx
index 2bb3689e..e8cda102 100644
--- a/src/components/relaysProvider.tsx
+++ b/src/components/relaysProvider.tsx
@@ -1,4 +1,4 @@
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import { RelayPool } from 'nostr-relaypool';
import { createContext, useMemo } from 'react';
@@ -8,7 +8,7 @@ export const RelayContext = createContext({});
export default function RelayProvider({ children }: { children: React.ReactNode }) {
const pool = useMemo(() => {
if (typeof window !== 'undefined') {
- return new RelayPool(DEFAULT_RELAYS, { useEventCache: false, logSubscriptions: false });
+ return new RelayPool(READONLY_RELAYS, { useEventCache: false, logSubscriptions: false });
} else {
return null;
}
diff --git a/src/pages/channel/index.page.tsx b/src/pages/channel/index.page.tsx
index 5fbd9e2a..54675457 100644
--- a/src/pages/channel/index.page.tsx
+++ b/src/pages/channel/index.page.tsx
@@ -4,7 +4,7 @@ import NewsfeedLayout from '@components/layouts/newsfeed';
import { RelayContext } from '@components/relaysProvider';
import { channelMessagesAtom, channelReplyAtom } from '@stores/channel';
-import { MESSAGE_RELAYS } from '@stores/constants';
+import { FULL_RELAYS } from '@stores/constants';
import { dateToUnix, hoursAgo } from '@utils/getDate';
import { usePageContext } from '@utils/hooks/usePageContext';
@@ -59,7 +59,7 @@ export function Page() {
since: dateToUnix(hoursAgo(48, now.current)),
},
],
- MESSAGE_RELAYS,
+ FULL_RELAYS,
(event: { kind: number; tags: string[][]; pubkey: string; id: string }) => {
if (muted.includes(event.pubkey)) {
console.log('muted');
diff --git a/src/pages/chat/index.page.tsx b/src/pages/chat/index.page.tsx
index a87a4759..699275b2 100644
--- a/src/pages/chat/index.page.tsx
+++ b/src/pages/chat/index.page.tsx
@@ -4,7 +4,7 @@ import NewsfeedLayout from '@components/layouts/newsfeed';
import { RelayContext } from '@components/relaysProvider';
import { chatMessagesAtom } from '@stores/chat';
-import { MESSAGE_RELAYS } from '@stores/constants';
+import { FULL_RELAYS } from '@stores/constants';
import { usePageContext } from '@utils/hooks/usePageContext';
@@ -44,7 +44,7 @@ export function Page() {
'#p': [pubkey],
},
],
- MESSAGE_RELAYS,
+ FULL_RELAYS,
(event: any) => {
setChatMessages((prev) => [...prev, event]);
}
diff --git a/src/pages/index.page.tsx b/src/pages/index.page.tsx
index 93465d77..953ed892 100644
--- a/src/pages/index.page.tsx
+++ b/src/pages/index.page.tsx
@@ -1,6 +1,6 @@
import { RelayContext } from '@components/relaysProvider';
-import { MESSAGE_RELAYS } from '@stores/constants';
+import { FULL_RELAYS } from '@stores/constants';
import { dateToUnix, hoursAgo } from '@utils/getDate';
import {
@@ -69,7 +69,7 @@ export function Page() {
// subscribe relays
const unsubscribe = pool.subscribe(
query,
- MESSAGE_RELAYS,
+ FULL_RELAYS,
(event: { kind: number; tags: string[]; id: string; pubkey: string; content: string; created_at: number }) => {
switch (event.kind) {
// short text note
diff --git a/src/pages/onboarding/create/index.page.tsx b/src/pages/onboarding/create/index.page.tsx
index 593a5307..b876bb42 100644
--- a/src/pages/onboarding/create/index.page.tsx
+++ b/src/pages/onboarding/create/index.page.tsx
@@ -1,7 +1,7 @@
import OnboardingLayout from '@components/layouts/onboarding';
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { WRITEONLY_RELAYS } from '@stores/constants';
import { createAccount } from '@utils/storage';
@@ -60,7 +60,7 @@ export function Page() {
// insert to database
createAccount(pubkey, privkey, metadata);
// broadcast
- pool.publish(event, DEFAULT_RELAYS);
+ pool.publish(event, WRITEONLY_RELAYS);
// redirect to next step
navigate(`/onboarding/create/step-2?pubkey=${pubkey}&privkey=${privkey}`, { overwriteLastHistoryEntry: true });
}, [pool, pubkey, privkey, metadata]);
diff --git a/src/pages/onboarding/create/step-2/index.page.tsx b/src/pages/onboarding/create/step-2/index.page.tsx
index bde7f60e..657f3889 100644
--- a/src/pages/onboarding/create/step-2/index.page.tsx
+++ b/src/pages/onboarding/create/step-2/index.page.tsx
@@ -2,7 +2,7 @@ import OnboardingLayout from '@components/layouts/onboarding';
import { RelayContext } from '@components/relaysProvider';
import { UserBase } from '@components/user/base';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { WRITEONLY_RELAYS } from '@stores/constants';
import { usePageContext } from '@utils/hooks/usePageContext';
import { fetchProfileMetadata } from '@utils/hooks/useProfileMetadata';
@@ -100,7 +100,7 @@ export function Page() {
event.id = getEventHash(event);
event.sig = signEvent(event, privkey);
// broadcast
- pool.publish(event, DEFAULT_RELAYS);
+ pool.publish(event, WRITEONLY_RELAYS);
// redirect to splashscreen
navigate('/');
}, [pubkey, privkey, follows, pool]);
diff --git a/src/pages/onboarding/login/step-2/index.page.tsx b/src/pages/onboarding/login/step-2/index.page.tsx
index b1b6d7a2..9a764f04 100644
--- a/src/pages/onboarding/login/step-2/index.page.tsx
+++ b/src/pages/onboarding/login/step-2/index.page.tsx
@@ -1,7 +1,7 @@
import OnboardingLayout from '@components/layouts/onboarding';
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_AVATAR, DEFAULT_RELAYS } from '@stores/constants';
+import { DEFAULT_AVATAR, READONLY_RELAYS } from '@stores/constants';
import { usePageContext } from '@utils/hooks/usePageContext';
import { fetchProfileMetadata } from '@utils/hooks/useProfileMetadata';
@@ -53,7 +53,7 @@ export function Page() {
authors: [pubkey],
},
],
- DEFAULT_RELAYS,
+ READONLY_RELAYS,
(event: any) => {
switch (event.kind) {
case 0:
diff --git a/src/stores/channel.tsx b/src/stores/channel.tsx
index a64063f5..02e6a87b 100644
--- a/src/stores/channel.tsx
+++ b/src/stores/channel.tsx
@@ -1,16 +1,6 @@
-import { DEFAULT_CHANNELS } from '@stores/constants';
-
import { atom } from 'jotai';
import { atomWithReset } from 'jotai/utils';
-// channel list
-export const defaultChannelsAtom = atom(DEFAULT_CHANNELS);
-export const channelsAtom = atom(async (get) => {
- const { getChannels } = await import('@utils/storage');
- const result: any = await getChannels(100, 0);
- return get(defaultChannelsAtom).concat(result);
-});
-
// channel reply id
export const channelReplyAtom = atomWithReset({ id: null, pubkey: null, content: null });
diff --git a/src/stores/constants.tsx b/src/stores/constants.tsx
index 92feef9e..d9dc5ab6 100644
--- a/src/stores/constants.tsx
+++ b/src/stores/constants.tsx
@@ -1,35 +1,22 @@
export const APP_VERSION = '0.2.5';
+
export const DEFAULT_AVATAR = 'https://void.cat/d/KmypFh2fBdYCEvyJrPiN89.webp';
+
export const DEFAULT_CHANNEL_BANNER =
'https://bafybeiacwit7hjmdefqggxqtgh6ht5dhth7ndptwn2msl5kpkodudsr7py.ipfs.w3s.link/banner-1.jpg';
-export const DEFAULT_CHANNELS = [
- {
- event_id: 'e3cadf5beca1b2af1cddaa41a633679bedf263e3de1eb229c6686c50d85df753',
- metadata: {
- name: 'Lume General',
- picture: 'https://void.cat/d/UNyxBmAh1MUx5gQTX95jyf.webp',
- about: 'General discussion about the Lume client',
- },
- created_at: 1681898574,
- },
- {
- event_id: '1abf8948d2fd05dd1836b33b324dca65138b2e80c77b27eeeed4323246efba4d',
- metadata: { picture: 'https://void.cat/d/MsqUKXXC4SxDfmT2KiHovJ.webp', name: 'Arcade Open R&D', about: '' },
- created_at: 1682252461,
- },
- {
- event_id: '25e5c82273a271cb1a840d0060391a0bf4965cafeb029d5ab55350b418953fbb',
- metadata: {
- about: '',
- name: 'Nostr',
- picture: 'https://cloudflare-ipfs.com/ipfs/QmTN4Eas9atUULVbEAbUU8cowhtvK7g3t7jfKztY7wc8eP?.png',
- },
- created_at: 1661333723,
- },
-];
-export const DEFAULT_RELAYS = ['wss://welcome.nostr.wine', 'wss://relay.nostr.band', 'wss://nostr.mutinywallet.com'];
-export const MESSAGE_RELAYS = [
+
+// read-only relay list
+export const READONLY_RELAYS = ['wss://welcome.nostr.wine', 'wss://relay.nostr.band'];
+
+// write-only relay list
+export const WRITEONLY_RELAYS = ['wss://nostr.mutinywallet.com', 'wss://relay.nostr.band'];
+
+// full-relay list, used for inital page and chat/channel messages loading
+export const FULL_RELAYS = [
'wss://relay.damus.io',
+ 'wss://nos.lol',
+ 'wss://nostr.mom',
+ 'wss://relay.plebstr.com',
'wss://nostr-pub.wellorder.net',
'wss://nostr.zebedee.cloud',
'wss://nostr.fmt.wiz.biz',
diff --git a/src/utils/hooks/useChannelMetadata.tsx b/src/utils/hooks/useChannelMetadata.tsx
index 420937e5..79b0ab84 100644
--- a/src/utils/hooks/useChannelMetadata.tsx
+++ b/src/utils/hooks/useChannelMetadata.tsx
@@ -1,6 +1,6 @@
import { RelayContext } from '@components/relaysProvider';
-import { DEFAULT_RELAYS } from '@stores/constants';
+import { READONLY_RELAYS } from '@stores/constants';
import { updateChannelMetadata } from '@utils/storage';
import { getChannel } from '@utils/storage';
@@ -23,7 +23,7 @@ export const useChannelMetadata = (id: string, channelPubkey: string) => {
kinds: [40],
},
],
- DEFAULT_RELAYS,
+ READONLY_RELAYS,
(event: { kind: number; pubkey: string; content: string }) => {
switch (event.kind) {
case 41: