fix: search box
This commit is contained in:
parent
723abea3d9
commit
68790a4fbb
@ -21,9 +21,7 @@
|
||||
},
|
||||
"signUp": {
|
||||
"quickStart": false,
|
||||
"defaultFollows": [
|
||||
"npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws"
|
||||
]
|
||||
"defaultFollows": ["npub1sn0rtcjcf543gj4wsg7fa59s700d5ztys5ctj0g69g2x6802npjqhjjtws"]
|
||||
},
|
||||
"defaultPreferences": {
|
||||
"hideMutedNotes": false,
|
||||
@ -65,4 +63,4 @@
|
||||
"clientSecret": "GAl1YKLA3FveK1gLBYok"
|
||||
},
|
||||
"chatChannels": []
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import "./SearchBox.css";
|
||||
|
||||
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 { useLocation, useNavigate } from "react-router-dom";
|
||||
|
||||
@ -25,7 +25,8 @@ export default function SearchBox() {
|
||||
const [activeIndex, setActiveIndex] = useState<number>(-1);
|
||||
const resultListRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
const results = useProfileSearch(search);
|
||||
const searchFn = useProfileSearch();
|
||||
const results = useMemo(() => searchFn(search), [search, searchFn]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleGlobalKeyDown = (e: KeyboardEvent) => {
|
||||
|
@ -15,7 +15,8 @@ const NOTES = 0;
|
||||
const PROFILES = 1;
|
||||
|
||||
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 content = keyword ? (
|
||||
<FollowListBase
|
||||
|
4
packages/system/src/cache/user-metadata.ts
vendored
4
packages/system/src/cache/user-metadata.ts
vendored
@ -7,8 +7,8 @@ export class UserProfileCache extends FeedCache<CachedMetadata> {
|
||||
|
||||
constructor(table?: DexieTableLike<CachedMetadata>) {
|
||||
super("UserCache", table);
|
||||
this.#processZapperQueue();
|
||||
this.#processNip5Queue();
|
||||
//this.#processZapperQueue();
|
||||
//this.#processNip5Queue();
|
||||
}
|
||||
|
||||
key(of: CachedMetadata): string {
|
||||
|
@ -132,10 +132,11 @@ export class SqliteRelay extends EventEmitter<RelayHandlerEvents> implements Rel
|
||||
|
||||
// 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)) {
|
||||
const oldEvents = db.selectValues(
|
||||
`SELECT id FROM events WHERE kind = ? AND pubkey = ? AND created <= ?`,
|
||||
[ev.kind, ev.pubkey, ev.created_at]
|
||||
) as Array<string>;
|
||||
const oldEvents = db.selectValues(`SELECT id FROM events WHERE kind = ? AND pubkey = ? AND created <= ?`, [
|
||||
ev.kind,
|
||||
ev.pubkey,
|
||||
ev.created_at,
|
||||
]) as Array<string>;
|
||||
|
||||
if (oldEvents.includes(ev.id)) {
|
||||
// Already have this event
|
||||
@ -156,7 +157,7 @@ export class SqliteRelay extends EventEmitter<RelayHandlerEvents> implements Rel
|
||||
FROM events e
|
||||
JOIN tags t ON e.id = t.event_id
|
||||
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>;
|
||||
|
||||
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)
|
||||
VALUES(?,?,?,?,?,?)`,
|
||||
{
|
||||
bind: [
|
||||
ev.id,
|
||||
ev.pubkey,
|
||||
ev.created_at,
|
||||
ev.kind,
|
||||
JSON.stringify(evInsert),
|
||||
(ev.relays ?? []).join(","),
|
||||
],
|
||||
}
|
||||
bind: [ev.id, ev.pubkey, ev.created_at, ev.kind, JSON.stringify(evInsert), (ev.relays ?? []).join(",")],
|
||||
},
|
||||
);
|
||||
|
||||
const insertedEvents = db.changes();
|
||||
|
Loading…
x
Reference in New Issue
Block a user