fix: search box

This commit is contained in:
kieran 2025-01-20 14:25:55 +00:00
parent 723abea3d9
commit 68790a4fbb
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
5 changed files with 17 additions and 23 deletions

View File

@ -21,9 +21,7 @@
}, },
"signUp": { "signUp": {
"quickStart": false, "quickStart": false,
"defaultFollows": [ "defaultFollows": ["npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws"]
"npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws"
]
}, },
"defaultPreferences": { "defaultPreferences": {
"hideMutedNotes": false, "hideMutedNotes": false,
@ -65,4 +63,4 @@
"clientSecret": "GAl1YKLA3FveK1gLBYok" "clientSecret": "GAl1YKLA3FveK1gLBYok"
}, },
"chatChannels": [] "chatChannels": []
} }

View File

@ -1,7 +1,7 @@
import "./SearchBox.css"; import "./SearchBox.css";
import { NostrLink, tryParseNostrLink } from "@snort/system"; import { NostrLink, tryParseNostrLink } from "@snort/system";
import { ChangeEvent, useEffect, useRef, useState } from "react"; import { ChangeEvent, useEffect, useMemo, useRef, useState } from "react";
import { FormattedMessage, useIntl } from "react-intl"; import { FormattedMessage, useIntl } from "react-intl";
import { useLocation, useNavigate } from "react-router-dom"; import { useLocation, useNavigate } from "react-router-dom";
@ -25,7 +25,8 @@ export default function SearchBox() {
const [activeIndex, setActiveIndex] = useState<number>(-1); const [activeIndex, setActiveIndex] = useState<number>(-1);
const resultListRef = useRef<HTMLDivElement | null>(null); const resultListRef = useRef<HTMLDivElement | null>(null);
const results = useProfileSearch(search); const searchFn = useProfileSearch();
const results = useMemo(() => searchFn(search), [search, searchFn]);
useEffect(() => { useEffect(() => {
const handleGlobalKeyDown = (e: KeyboardEvent) => { const handleGlobalKeyDown = (e: KeyboardEvent) => {

View File

@ -15,7 +15,8 @@ const NOTES = 0;
const PROFILES = 1; const PROFILES = 1;
const Profiles = ({ keyword }: { keyword: string }) => { const Profiles = ({ keyword }: { keyword: string }) => {
const results = useProfileSearch(keyword); const searchFn = useProfileSearch();
const results = useMemo(() => searchFn(keyword), [keyword, searchFn]);
const ids = useMemo(() => results.map(r => r.pubkey), [results]); const ids = useMemo(() => results.map(r => r.pubkey), [results]);
const content = keyword ? ( const content = keyword ? (
<FollowListBase <FollowListBase

View File

@ -7,8 +7,8 @@ export class UserProfileCache extends FeedCache<CachedMetadata> {
constructor(table?: DexieTableLike<CachedMetadata>) { constructor(table?: DexieTableLike<CachedMetadata>) {
super("UserCache", table); super("UserCache", table);
this.#processZapperQueue(); //this.#processZapperQueue();
this.#processNip5Queue(); //this.#processNip5Queue();
} }
key(of: CachedMetadata): string { key(of: CachedMetadata): string {

View File

@ -132,10 +132,11 @@ export class SqliteRelay extends EventEmitter<RelayHandlerEvents> implements Rel
// Handle legacy and standard replaceable events (kinds 0, 3, 41, 10000-19999) // Handle legacy and standard replaceable events (kinds 0, 3, 41, 10000-19999)
if (legacyReplaceableKinds.includes(ev.kind) || (ev.kind >= 10_000 && ev.kind < 20_000)) { if (legacyReplaceableKinds.includes(ev.kind) || (ev.kind >= 10_000 && ev.kind < 20_000)) {
const oldEvents = db.selectValues( const oldEvents = db.selectValues(`SELECT id FROM events WHERE kind = ? AND pubkey = ? AND created <= ?`, [
`SELECT id FROM events WHERE kind = ? AND pubkey = ? AND created <= ?`, ev.kind,
[ev.kind, ev.pubkey, ev.created_at] ev.pubkey,
) as Array<string>; ev.created_at,
]) as Array<string>;
if (oldEvents.includes(ev.id)) { if (oldEvents.includes(ev.id)) {
// Already have this event // Already have this event
@ -156,7 +157,7 @@ export class SqliteRelay extends EventEmitter<RelayHandlerEvents> implements Rel
FROM events e FROM events e
JOIN tags t ON e.id = t.event_id JOIN tags t ON e.id = t.event_id
WHERE e.kind = ? AND e.pubkey = ? AND t.key = ? AND t.value = ? AND created <= ?`, WHERE e.kind = ? AND e.pubkey = ? AND t.key = ? AND t.value = ? AND created <= ?`,
[ev.kind, ev.pubkey, "d", dTag, ev.created_at] [ev.kind, ev.pubkey, "d", dTag, ev.created_at],
) as Array<string>; ) as Array<string>;
if (oldEvents.includes(ev.id)) { if (oldEvents.includes(ev.id)) {
@ -177,15 +178,8 @@ export class SqliteRelay extends EventEmitter<RelayHandlerEvents> implements Rel
`INSERT OR IGNORE INTO events(id, pubkey, created, kind, json, relays) `INSERT OR IGNORE INTO events(id, pubkey, created, kind, json, relays)
VALUES(?,?,?,?,?,?)`, VALUES(?,?,?,?,?,?)`,
{ {
bind: [ bind: [ev.id, ev.pubkey, ev.created_at, ev.kind, JSON.stringify(evInsert), (ev.relays ?? []).join(",")],
ev.id, },
ev.pubkey,
ev.created_at,
ev.kind,
JSON.stringify(evInsert),
(ev.relays ?? []).join(","),
],
}
); );
const insertedEvents = db.changes(); const insertedEvents = db.changes();