refactor: upgrade nip17
This commit is contained in:
@ -27,4 +27,8 @@ export class ChatCache extends FeedCache<NostrEvent> {
|
||||
takeSnapshot(): Array<NostrEvent> {
|
||||
return [...this.cache.values()];
|
||||
}
|
||||
|
||||
async search() {
|
||||
return <Array<NostrEvent>>[];
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,17 @@ export class EventCacheWorker extends EventEmitter<CacheEvents> implements Cache
|
||||
this.#keys = new Set<string>(ids as unknown as Array<string>);
|
||||
}
|
||||
|
||||
async search(q: string) {
|
||||
const results = await this.#relay.query([
|
||||
"REQ",
|
||||
"events-search",
|
||||
{
|
||||
search: q
|
||||
},
|
||||
]);
|
||||
return results;
|
||||
}
|
||||
|
||||
keysOnTable(): string[] {
|
||||
return [...this.#keys];
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
import { EventKind, EventPublisher, RequestBuilder, TaggedNostrEvent } from "@snort/system";
|
||||
import { EventKind, EventPublisher, TaggedNostrEvent } from "@snort/system";
|
||||
|
||||
import { db, UnwrappedGift } from "@/Db";
|
||||
import { findTag, unwrap } from "@/Utils";
|
||||
import { LoginSession, LoginSessionType } from "@/Utils/Login";
|
||||
|
||||
import { RefreshFeedCache } from "./RefreshFeedCache";
|
||||
import { RefreshFeedCache, TWithCreated } from "./RefreshFeedCache";
|
||||
|
||||
export class GiftWrapCache extends RefreshFeedCache<UnwrappedGift> {
|
||||
constructor() {
|
||||
@ -15,11 +14,8 @@ export class GiftWrapCache extends RefreshFeedCache<UnwrappedGift> {
|
||||
return of.id;
|
||||
}
|
||||
|
||||
buildSub(session: LoginSession, rb: RequestBuilder): void {
|
||||
const pubkey = session.publicKey;
|
||||
if (pubkey && session.type === LoginSessionType.PrivateKey) {
|
||||
rb.withFilter().kinds([EventKind.GiftWrap]).tag("p", [pubkey]).since(this.newest());
|
||||
}
|
||||
buildSub(): void {
|
||||
// not used
|
||||
}
|
||||
|
||||
takeSnapshot(): Array<UnwrappedGift> {
|
||||
@ -57,4 +53,8 @@ export class GiftWrapCache extends RefreshFeedCache<UnwrappedGift> {
|
||||
}
|
||||
await this.bulkSet(unwrapped);
|
||||
}
|
||||
|
||||
search(): Promise<TWithCreated<UnwrappedGift>[]> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,18 @@ export class ProfileCacheRelayWorker extends EventEmitter<CacheEvents> implement
|
||||
this.#log(`Loaded %d/%d in %d ms`, this.#cache.size, this.#keys.size, (unixNowMs() - start).toLocaleString());
|
||||
}
|
||||
|
||||
async search(q: string) {
|
||||
const profiles = await this.#relay.query([
|
||||
"REQ",
|
||||
"profiles-search",
|
||||
{
|
||||
kinds: [0],
|
||||
search: q
|
||||
},
|
||||
]);
|
||||
return removeUndefined(profiles.map(mapEventToProfile));
|
||||
}
|
||||
|
||||
keysOnTable(): string[] {
|
||||
return [...this.#keys];
|
||||
}
|
||||
|
@ -29,6 +29,18 @@ export class UserFollowsWorker extends EventEmitter<CacheEvents> implements Cach
|
||||
this.#log(`Loaded %d/%d in %d ms`, this.#cache.size, this.#keys.size, (unixNowMs() - start).toLocaleString());
|
||||
}
|
||||
|
||||
async search(q: string) {
|
||||
const results = await this.#relay.query([
|
||||
"REQ",
|
||||
"contacts-search",
|
||||
{
|
||||
kinds: [3],
|
||||
search: q
|
||||
},
|
||||
]);
|
||||
return removeUndefined(results.map(mapEventToUserFollows));
|
||||
}
|
||||
|
||||
keysOnTable(): string[] {
|
||||
return [...this.#keys];
|
||||
}
|
||||
|
Reference in New Issue
Block a user