diff --git a/src/app/newsfeed/components/user/default.tsx b/src/app/newsfeed/components/user/default.tsx
index 3cb91cf9..ff3acf65 100644
--- a/src/app/newsfeed/components/user/default.tsx
+++ b/src/app/newsfeed/components/user/default.tsx
@@ -1,4 +1,4 @@
-import { DEFAULT_AVATAR } from '@lume/stores/constants';
+import { DEFAULT_AVATAR, IMGPROXY_URL } from '@lume/stores/constants';
import { useProfile } from '@lume/utils/hooks/useProfile';
import { shortenKey } from '@lume/utils/shortenKey';
@@ -28,7 +28,7 @@ export const NoteDefaultUser = ({ pubkey, time }: { pubkey: string; time: number
<>
- );
-}
diff --git a/src/shared/chats/chatListItem.tsx b/src/shared/chats/chatListItem.tsx
deleted file mode 100644
index 8fc1f4ca..00000000
--- a/src/shared/chats/chatListItem.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { DEFAULT_AVATAR } from '@lume/stores/constants';
-import { usePageContext } from '@lume/utils/hooks/usePageContext';
-import { useProfile } from '@lume/utils/hooks/useProfile';
-import { shortenKey } from '@lume/utils/shortenKey';
-
-import { twMerge } from 'tailwind-merge';
-
-export const ChatListItem = ({ pubkey }: { pubkey: string }) => {
- const profile = useProfile(pubkey);
- const pageContext = usePageContext();
-
- const searchParams: any = pageContext.urlParsed.search;
- const pagePubkey = searchParams.pubkey;
-
- return (
-
-
-

-
-
-
- {profile?.display_name || profile?.name || shortenKey(pubkey)}
-
-
-
- );
-};
diff --git a/src/shared/chats/chatModal.tsx b/src/shared/chats/chatModal.tsx
deleted file mode 100644
index f6c7346e..00000000
--- a/src/shared/chats/chatModal.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { Plus } from 'iconoir-react';
-
-export const ChatModal = () => {
- return (
-
- );
-};
diff --git a/src/shared/chats/chatModalUser.tsx b/src/shared/chats/chatModalUser.tsx
deleted file mode 100644
index 687b176f..00000000
--- a/src/shared/chats/chatModalUser.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { DEFAULT_AVATAR } from '@lume/stores/constants';
-import { shortenKey } from '@lume/utils/shortenKey';
-
-import { navigate } from 'vite-plugin-ssr/client/router';
-
-export const ChatModalUser = ({ data }: { data: any }) => {
- const profile = JSON.parse(data.metadata);
-
- const openNewChat = () => {
- navigate(`/chat?pubkey=${data.pubkey}`);
- };
-
- return (
-
-
-
-

-
-
-
- {profile?.display_name || profile?.name}
-
- {shortenKey(data.pubkey)}
-
-
-
-
-
-
- );
-};
diff --git a/src/shared/chats/messageListItem.tsx b/src/shared/chats/messageListItem.tsx
deleted file mode 100644
index 33a91e3a..00000000
--- a/src/shared/chats/messageListItem.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { MessageUser } from '@lume/shared/chats/messageUser';
-import { useDecryptMessage } from '@lume/utils/hooks/useDecryptMessage';
-
-import { memo } from 'react';
-
-export const MessageListItem = memo(function MessageListItem({
- data,
- userPubkey,
- userPrivkey,
-}: {
- data: any;
- userPubkey: string;
- userPrivkey: string;
-}) {
- const content = useDecryptMessage(userPubkey, userPrivkey, data.pubkey, data.tags, data.content);
-
- return (
-
- );
-});
diff --git a/src/shared/chats/messageUser.tsx b/src/shared/chats/messageUser.tsx
deleted file mode 100644
index 75c7cf31..00000000
--- a/src/shared/chats/messageUser.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { DEFAULT_AVATAR } from '@lume/stores/constants';
-import { useProfile } from '@lume/utils/hooks/useProfile';
-import { shortenKey } from '@lume/utils/shortenKey';
-
-import dayjs from 'dayjs';
-import relativeTime from 'dayjs/plugin/relativeTime';
-
-dayjs.extend(relativeTime);
-
-export const MessageUser = ({ pubkey, time }: { pubkey: string; time: number }) => {
- const profile = useProfile(pubkey);
-
- return (
-
-
-

-
-
-
-
- {profile?.display_name || profile?.name || shortenKey(pubkey)}
-
- ·
- {dayjs().to(dayjs.unix(time))}
-
-
-
- );
-};
diff --git a/src/shared/form/channel.tsx b/src/shared/form/channel.tsx
deleted file mode 100644
index f239c546..00000000
--- a/src/shared/form/channel.tsx
+++ /dev/null
@@ -1,130 +0,0 @@
-import { AccountContext } from '@lume/shared/accountProvider';
-import { ImagePicker } from '@lume/shared/form/imagePicker';
-import { RelayContext } from '@lume/shared/relaysProvider';
-import { UserMini } from '@lume/shared/user/mini';
-import { channelContentAtom, channelReplyAtom } from '@lume/stores/channel';
-import { FULL_RELAYS } from '@lume/stores/constants';
-import { dateToUnix } from '@lume/utils/getDate';
-
-import { Cancel } from 'iconoir-react';
-import { useAtom, useAtomValue } from 'jotai';
-import { useResetAtom } from 'jotai/utils';
-import { getEventHash, signEvent } from 'nostr-tools';
-import { useCallback, useContext } from 'react';
-
-export const FormChannel = ({ eventId }: { eventId: string | string[] }) => {
- const pool: any = useContext(RelayContext);
- const activeAccount: any = useContext(AccountContext);
-
- const [value, setValue] = useAtom(channelContentAtom);
- const resetValue = useResetAtom(channelContentAtom);
-
- const channelReply = useAtomValue(channelReplyAtom);
- const resetChannelReply = useResetAtom(channelReplyAtom);
-
- const submitEvent = useCallback(() => {
- let tags: any[][];
-
- if (channelReply.id !== null) {
- tags = [
- ['e', eventId, '', 'root'],
- ['e', channelReply.id, '', 'reply'],
- ['p', channelReply.pubkey, ''],
- ];
- } else {
- tags = [['e', eventId, '', 'root']];
- }
-
- const event: any = {
- content: value,
- created_at: dateToUnix(),
- kind: 42,
- pubkey: activeAccount.pubkey,
- tags: tags,
- };
- event.id = getEventHash(event);
- event.sig = signEvent(event, activeAccount.privkey);
-
- // publish note
- pool.publish(event, FULL_RELAYS);
- // reset state
- resetValue();
- // reset channel reply
- resetChannelReply();
- }, [
- value,
- channelReply.id,
- channelReply.pubkey,
- activeAccount.pubkey,
- activeAccount.privkey,
- eventId,
- resetChannelReply,
- resetValue,
- pool,
- ]);
-
- const handleEnterPress = (e) => {
- if (e.key === 'Enter' && !e.shiftKey) {
- e.preventDefault();
- submitEvent();
- }
- };
-
- const stopReply = () => {
- resetChannelReply();
- };
-
- return (
-
- {channelReply.id && (
-
-
-
-
-
-
{channelReply.content}
-
-
-
-
-
- )}
-
- );
-};
diff --git a/src/shared/form/comment.tsx b/src/shared/form/comment.tsx
index eac8c87f..59732e8b 100644
--- a/src/shared/form/comment.tsx
+++ b/src/shared/form/comment.tsx
@@ -1,29 +1,29 @@
-import { AccountContext } from '@lume/shared/accountProvider';
-import { RelayContext } from '@lume/shared/relaysProvider';
import { WRITEONLY_RELAYS } from '@lume/stores/constants';
import { dateToUnix } from '@lume/utils/getDate';
+import { useActiveAccount } from '@lume/utils/hooks/useActiveAccount';
+import { RelayPool } from 'nostr-relaypool';
import { getEventHash, signEvent } from 'nostr-tools';
-import { useContext, useState } from 'react';
+import { useState } from 'react';
export default function FormComment({ eventID }: { eventID: any }) {
- const pool: any = useContext(RelayContext);
- const activeAccount: any = useContext(AccountContext);
+ const { account } = useActiveAccount();
const [value, setValue] = useState('');
- const profile = JSON.parse(activeAccount.metadata);
+ const profile = JSON.parse(account.metadata);
const submitEvent = () => {
+ const pool = new RelayPool(WRITEONLY_RELAYS);
const event: any = {
content: value,
created_at: dateToUnix(),
kind: 1,
- pubkey: activeAccount.pubkey,
+ pubkey: account.pubkey,
tags: [['e', eventID]],
};
event.id = getEventHash(event);
- event.sig = signEvent(event, activeAccount.privkey);
+ event.sig = signEvent(event, account.privkey);
// publish note
pool.publish(event, WRITEONLY_RELAYS);
@@ -36,7 +36,7 @@ export default function FormComment({ eventID }: { eventID: any }) {
-

+
diff --git a/src/stores/constants.tsx b/src/stores/constants.tsx
index d9dc5ab6..a3840d86 100644
--- a/src/stores/constants.tsx
+++ b/src/stores/constants.tsx
@@ -5,6 +5,12 @@ export const DEFAULT_AVATAR = 'https://void.cat/d/KmypFh2fBdYCEvyJrPiN89.webp';
export const DEFAULT_CHANNEL_BANNER =
'https://bafybeiacwit7hjmdefqggxqtgh6ht5dhth7ndptwn2msl5kpkodudsr7py.ipfs.w3s.link/banner-1.jpg';
+// img proxy
+export const IMGPROXY_URL = 'https://imgproxy.iris.to/insecure';
+
+// metadata service
+export const METADATA_SERVICE = 'https://us.rbr.bio';
+
// read-only relay list
export const READONLY_RELAYS = ['wss://welcome.nostr.wine', 'wss://relay.nostr.band'];
diff --git a/src/utils/hooks/useProfile.tsx b/src/utils/hooks/useProfile.tsx
index 9bc30bbe..9512e744 100644
--- a/src/utils/hooks/useProfile.tsx
+++ b/src/utils/hooks/useProfile.tsx
@@ -1,9 +1,11 @@
+import { METADATA_SERVICE } from '@lume/stores/constants';
+
import useSWR from 'swr';
const fetcher = (url: string) => fetch(url).then((r: any) => r.json());
export const useProfile = (pubkey: string) => {
- const { data, error, isLoading } = useSWR(`https://us.rbr.bio/${pubkey}/metadata.json`, fetcher);
+ const { data, error, isLoading } = useSWR(`${METADATA_SERVICE}/${pubkey}/metadata.json`, fetcher);
return {
user: data ? JSON.parse(data.content ? data.content : null) : null,