feat: client tags
This commit is contained in:
@ -150,7 +150,11 @@ export class NostrLink implements ToNostrEventTag {
|
||||
const ifSetCheck = <T>(a: T | undefined, b: T) => {
|
||||
return !Boolean(a) || a === b;
|
||||
};
|
||||
return (EventExt.isReplaceable(ev.kind) || ifSetCheck(this.id, ev.id)) && ifSetCheck(this.author, ev.pubkey) && ifSetCheck(this.kind, ev.kind);
|
||||
return (
|
||||
(EventExt.isReplaceable(ev.kind) || ifSetCheck(this.id, ev.id)) &&
|
||||
ifSetCheck(this.author, ev.pubkey) &&
|
||||
ifSetCheck(this.kind, ev.kind)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -74,13 +74,19 @@ export class UserState<TAppData> extends EventEmitter<UserStateEvents> {
|
||||
this.#stateObj = stateObj;
|
||||
this.#standardLists = pubkey ? new Map() : undefined;
|
||||
|
||||
this.#profile = pubkey ? new JsonEventSync<UserMetadata | undefined>(
|
||||
undefined,
|
||||
new NostrLink(NostrPrefix.Event, pubkey, EventKind.SetMetadata, pubkey),
|
||||
false,
|
||||
) : undefined;
|
||||
this.#contacts = pubkey ? new DiffSyncTags(new NostrLink(NostrPrefix.Event, pubkey, EventKind.ContactList, pubkey), false) : undefined;
|
||||
this.#relays = pubkey ? new DiffSyncTags(new NostrLink(NostrPrefix.Event, pubkey, EventKind.Relays, pubkey), false) : undefined;
|
||||
this.#profile = pubkey
|
||||
? new JsonEventSync<UserMetadata | undefined>(
|
||||
undefined,
|
||||
new NostrLink(NostrPrefix.Event, pubkey, EventKind.SetMetadata, pubkey),
|
||||
false,
|
||||
)
|
||||
: undefined;
|
||||
this.#contacts = pubkey
|
||||
? new DiffSyncTags(new NostrLink(NostrPrefix.Event, pubkey, EventKind.ContactList, pubkey), false)
|
||||
: undefined;
|
||||
this.#relays = pubkey
|
||||
? new DiffSyncTags(new NostrLink(NostrPrefix.Event, pubkey, EventKind.Relays, pubkey), false)
|
||||
: undefined;
|
||||
if (options?.appdataId && options.initAppdata) {
|
||||
const link = new NostrLink(NostrPrefix.Address, options.appdataId, EventKind.AppData, pubkey);
|
||||
this.#appdata = new JsonEventSync<TAppData>(options.initAppdata, link, options.encryptAppdata ?? false);
|
||||
|
Reference in New Issue
Block a user