clean up and fix errors
This commit is contained in:
@@ -15,15 +15,15 @@ export default function ChatList() {
|
||||
|
||||
const [list, setList] = useState([]);
|
||||
const [activeAccount]: any = useLocalStorage('account', {});
|
||||
const profile = activeAccount.metadata ? JSON.parse(activeAccount.metadata) : null;
|
||||
const profile = JSON.parse(activeAccount.metadata);
|
||||
|
||||
const openSelfChat = () => {
|
||||
router.push(`/chats/${activeAccount.pubkey}`);
|
||||
router.push(`/nostr/chats/${activeAccount.pubkey}`);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getChats(activeAccount.id)
|
||||
.then((res) => setList(res))
|
||||
.then((res: any) => setList(res))
|
||||
.catch(console.error);
|
||||
}, [activeAccount.id]);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ export default function EventCollector() {
|
||||
const [activeAccount]: any = useLocalStorage('account', {});
|
||||
|
||||
const setHasNewerNote = useSetAtom(hasNewerNoteAtom);
|
||||
const follows = JSON.parse(activeAccount.follows);
|
||||
|
||||
const now = useRef(new Date());
|
||||
const unsubscribe = useRef(null);
|
||||
@@ -29,11 +30,11 @@ export default function EventCollector() {
|
||||
[
|
||||
{
|
||||
kinds: [1, 6],
|
||||
authors: activeAccount.follows,
|
||||
authors: follows,
|
||||
since: dateToUnix(now.current),
|
||||
},
|
||||
{
|
||||
kinds: [3],
|
||||
kinds: [0, 3],
|
||||
authors: [activeAccount.pubkey],
|
||||
},
|
||||
{
|
||||
@@ -47,8 +48,12 @@ export default function EventCollector() {
|
||||
},
|
||||
],
|
||||
relays,
|
||||
(event) => {
|
||||
(event: { kind: number; tags: string[]; id: string; pubkey: string; content: string; created_at: number }) => {
|
||||
switch (event.kind) {
|
||||
// metadata
|
||||
case 0:
|
||||
updateAccount('metadata', event.content, event.pubkey);
|
||||
break;
|
||||
// short text note
|
||||
case 1:
|
||||
const parentID = getParentID(event.tags, event.id);
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function MultiAccounts() {
|
||||
|
||||
useEffect(() => {
|
||||
getAccounts()
|
||||
.then((res) => setUsers(res))
|
||||
.then((res: any) => setUsers(res))
|
||||
.catch(console.error);
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { RootNote } from '@components/note/rootNote';
|
||||
import { UserQuoteRepost } from '@components/user/quoteRepost';
|
||||
|
||||
import destr from 'destr';
|
||||
import { memo } from 'react';
|
||||
|
||||
export const NoteQuoteRepost = memo(function NoteQuoteRepost({ event }: { event: any }) {
|
||||
@@ -8,7 +9,10 @@ export const NoteQuoteRepost = memo(function NoteQuoteRepost({ event }: { event:
|
||||
let note = null;
|
||||
|
||||
if (event.content.length > 0) {
|
||||
note = <RootNote event={JSON.parse(event.content)} />;
|
||||
const content = destr(event.content);
|
||||
if (content) {
|
||||
note = <RootNote event={content} />;
|
||||
}
|
||||
} else {
|
||||
note = <RootNote event={event.tags[0][1]} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user