Skip to content

Commit 9234a99

Browse files
authored
Merge pull request #173 from v0l/main
[pull] master from v0l:main
2 parents 683a56b + e3a8495 commit 9234a99

File tree

19 files changed

+479
-521
lines changed

19 files changed

+479
-521
lines changed

packages/app/config/default.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
},
2222
"signUp": {
2323
"quickStart": false,
24-
"defaultFollows": [
25-
"npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws"
26-
]
24+
"defaultFollows": ["npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws"]
2725
},
2826
"defaultPreferences": {
2927
"hideMutedNotes": false,
@@ -65,4 +63,4 @@
6563
"clientSecret": "GAl1YKLA3FveK1gLBYok"
6664
},
6765
"chatChannels": []
68-
}
66+
}

packages/app/src/Components/Event/Note/Note.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function Note(props: NoteProps) {
3939
const { data: ev, highlight, options: opt, ignoreModeration = false, className, waitUntilInView } = props;
4040
const baseClassName = classNames("note min-h-[110px] flex flex-col gap-4 card", className ?? "");
4141
const { isEventMuted } = useModeration();
42-
const { ref, inView } = useInView({ triggerOnce: true, rootMargin: "2000px" });
42+
const { ref, inView } = useInView({ triggerOnce: true });
4343
const { ref: setSeenAtRef, inView: setSeenAtInView } = useInView({ rootMargin: "0px", threshold: 1 });
4444
const [showTranslation, setShowTranslation] = useState(true);
4545
const [translated, setTranslated] = useState<NoteTranslation | null>(translationCache.get(ev.id));

packages/app/src/Components/SearchBox/SearchBox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "./SearchBox.css";
22

33
import { NostrLink, tryParseNostrLink } from "@snort/system";
4-
import { ChangeEvent, useEffect, useRef, useState } from "react";
4+
import { ChangeEvent, useEffect, useMemo, useRef, useState } from "react";
55
import { FormattedMessage, useIntl } from "react-intl";
66
import { useLocation, useNavigate } from "react-router-dom";
77

@@ -25,7 +25,8 @@ export default function SearchBox() {
2525
const [activeIndex, setActiveIndex] = useState<number>(-1);
2626
const resultListRef = useRef<HTMLDivElement | null>(null);
2727

28-
const results = useProfileSearch(search);
28+
const searchFn = useProfileSearch();
29+
const results = useMemo(() => searchFn(search), [search, searchFn]);
2930

3031
useEffect(() => {
3132
const handleGlobalKeyDown = (e: KeyboardEvent) => {

packages/app/src/Feed/LoginFeed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function useLoginFeed() {
2222
const { publisher, system } = useEventPublisher();
2323

2424
useEffect(() => {
25-
//system.checkSigs = checkSigs;
25+
system.checkSigs = checkSigs;
2626
}, [system, checkSigs]);
2727

2828
useEffect(() => {

packages/app/src/Pages/SearchPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const NOTES = 0;
1515
const PROFILES = 1;
1616

1717
const Profiles = ({ keyword }: { keyword: string }) => {
18-
const results = useProfileSearch(keyword);
18+
const searchFn = useProfileSearch();
19+
const results = useMemo(() => searchFn(keyword), [keyword, searchFn]);
1920
const ids = useMemo(() => results.map(r => r.pubkey), [results]);
2021
const content = keyword ? (
2122
<FollowListBase

packages/app/src/index.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ import "./index.css";
22
import "@szhsin/react-menu/dist/index.css";
33
import "@/assets/fonts/inter.css";
44

5-
import { unixNowMs } from "@snort/shared";
5+
import { unixNow, unixNowMs } from "@snort/shared";
66
import { EventBuilder } from "@snort/system";
77
import { SnortContext } from "@snort/system-react";
88
import { StrictMode } from "react";
99
import * as ReactDOM from "react-dom/client";
1010
import { createBrowserRouter, RouteObject, RouterProvider } from "react-router-dom";
1111

12-
import { preload, UserCache } from "@/Cache";
12+
import { initRelayWorker, preload, Relay, UserCache } from "@/Cache";
1313
import { ThreadRoute } from "@/Components/Event/Thread/ThreadRoute";
1414
import { IntlProvider } from "@/Components/IntlProvider/IntlProvider";
15+
import { db } from "@/Db";
1516
import { addCachedMetadataToFuzzySearch } from "@/Db/FuzzySearch";
1617
import { AboutPage } from "@/Pages/About";
1718
import { DebugPage } from "@/Pages/CacheDebug";
@@ -39,9 +40,11 @@ import { WalletSendPage } from "@/Pages/wallet/send";
3940
import ZapPoolPage from "@/Pages/ZapPool/ZapPool";
4041
import { System } from "@/system";
4142
import { storeRefCode, unwrap } from "@/Utils";
43+
import { hasWasm, wasmInit, WasmPath } from "@/Utils/wasm";
4244
import { Wallets } from "@/Wallet";
4345
import { setupWebLNWalletConfig } from "@/Wallet";
4446

47+
import { Day } from "./Utils/Const";
4548
import { LoginStore } from "./Utils/Login";
4649

4750
async function initSite() {
@@ -51,10 +54,14 @@ async function initSite() {
5154
"31990:84de35e2584d2b144aae823c9ed0b0f3deda09648530b93d1a2a146d1dea9864:app-profile",
5255
];
5356
storeRefCode();
57+
if (hasWasm) {
58+
await wasmInit(WasmPath);
59+
await initRelayWorker();
60+
}
5461

5562
setupWebLNWalletConfig(Wallets);
5663

57-
//db.ready = await db.isAvailable();
64+
db.ready = await db.isAvailable();
5865

5966
const login = LoginStore.snapshot();
6067
preload(login.state.follows).then(async () => {
@@ -77,7 +84,7 @@ async function initSite() {
7784
});
7885

7986
// cleanup
80-
//Relay.delete(["REQ", "cleanup", { kinds: [1, 7, 9735], until: unixNow() - Day * 30 }]);
87+
Relay.delete(["REQ", "cleanup", { kinds: [1, 7, 9735], until: unixNow() - Day * 30 }]);
8188

8289
return null;
8390
}

packages/app/src/system.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
import { removeUndefined, throwIfOffline } from "@snort/shared";
22
import { mapEventToProfile, NostrEvent, NostrSystem } from "@snort/system";
33

4+
import { EventsCache, Relay, RelayMetrics, SystemDb, UserCache, UserFollows, UserRelays } from "@/Cache";
45
import { addEventToFuzzySearch } from "@/Db/FuzzySearch";
56
import { LoginStore } from "@/Utils/Login";
7+
import { hasWasm, WasmOptimizer } from "@/Utils/wasm";
68

79
/**
810
* Singleton nostr system
911
*/
1012
export const System = new NostrSystem({
11-
//relays: UserRelays,
12-
//events: EventsCache,
13-
//profiles: UserCache,
14-
//relayMetrics: RelayMetrics,
15-
//cachingRelay: Relay,
16-
//contactLists: UserFollows,
17-
//optimizer: hasWasm ? WasmOptimizer : undefined,
18-
//db: SystemDb,
13+
relays: UserRelays,
14+
events: EventsCache,
15+
profiles: UserCache,
16+
relayMetrics: RelayMetrics,
17+
cachingRelay: Relay,
18+
contactLists: UserFollows,
19+
optimizer: hasWasm ? WasmOptimizer : undefined,
20+
db: SystemDb,
1921
buildFollowGraph: true,
2022
automaticOutboxModel: true,
21-
checkSigs: false,
2223
});
2324

2425
System.on("auth", async (c, r, cb) => {
@@ -30,8 +31,8 @@ System.on("auth", async (c, r, cb) => {
3031
});
3132

3233
System.on("event", (_, ev) => {
33-
//EventsCache.discover(ev);
34-
//UserCache.discover(ev);
34+
EventsCache.discover(ev);
35+
UserCache.discover(ev);
3536
addEventToFuzzySearch(ev);
3637
});
3738

packages/system-react/src/useReactions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function useReactions(
3131
}
3232
others?.(rb);
3333
return rb;
34-
}, [ids]);
34+
}, [ids, others]);
3535

3636
return useRequestBuilder(sub);
3737
}

0 commit comments

Comments
 (0)