This commit is contained in:
Ren Amamiya
2023-03-21 13:00:32 +07:00
parent c1d818c69d
commit 3ad1fff4f8
5 changed files with 18 additions and 27 deletions

View File

@@ -4,6 +4,6 @@ import { createContext, useMemo } from 'react';
export const RelayContext = createContext({});
export default function RelayProvider({ relays, children }: { relays: any; children: React.ReactNode }) {
const value = useMemo(() => new RelayPool(relays, { useEventCache: true, logSubscriptions: false }), [relays]);
const value = useMemo(() => new RelayPool(relays, { useEventCache: false, logSubscriptions: false }), [relays]);
return <RelayContext.Provider value={value}>{children}</RelayContext.Provider>;
}

View File

@@ -3,7 +3,7 @@ import { RelayContext } from '@components/contexts/relay';
import { Content } from '@components/note/content';
import useLocalStorage from '@rehooks/local-storage';
import { memo, useCallback, useContext, useMemo, useState } from 'react';
import { memo, useCallback, useContext, useEffect, useState } from 'react';
export const RootNote = memo(function RootNote({ id }: { id: string }) {
const { db }: any = useContext(DatabaseContext);
@@ -26,7 +26,7 @@ export const RootNote = memo(function RootNote({ id }: { id: string }) {
const getData = useCallback(async () => {
const result = await db.select(`SELECT * FROM cache_notes WHERE id = "${id}"`);
return result[0];
}, []);
}, [db, id]);
const fetchEvent = useCallback(() => {
relayPool.subscribe(
@@ -53,7 +53,7 @@ export const RootNote = memo(function RootNote({ id }: { id: string }) {
);
}, [id, insertDB, relayPool, relays]);
useMemo(() => {
useEffect(() => {
getData()
.then((res) => {
if (res) {