fix: sync contacts
This commit is contained in:
parent
a17c98ad25
commit
b199d1a366
@ -18,7 +18,7 @@ export class DiffSyncTags extends EventEmitter<SafeSyncEvents> {
|
||||
#changesEncrypted: Array<TagDiff> = [];
|
||||
#decryptedContent?: string;
|
||||
|
||||
constructor(readonly link: NostrLink) {
|
||||
constructor(readonly link: NostrLink, readonly contentEncrypted: boolean) {
|
||||
super();
|
||||
this.#sync = new SafeSync(link);
|
||||
this.#sync.on("change", () => {
|
||||
@ -99,7 +99,7 @@ export class DiffSyncTags extends EventEmitter<SafeSyncEvents> {
|
||||
async sync(signer: EventSigner, system: SystemInterface) {
|
||||
await this.#sync.sync(system);
|
||||
|
||||
if (this.#sync.value?.content) {
|
||||
if (this.#sync.value?.content && this.contentEncrypted) {
|
||||
const decrypted = await signer.nip4Decrypt(this.#sync.value.content, await signer.getPubKey());
|
||||
this.#decryptedContent = decrypted;
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ export class UserState<TAppData> extends EventEmitter<UserStateEvents> {
|
||||
new NostrLink(NostrPrefix.Event, "", EventKind.SetMetadata, pubkey),
|
||||
false,
|
||||
);
|
||||
this.#contacts = new DiffSyncTags(new NostrLink(NostrPrefix.Event, "", EventKind.ContactList, pubkey));
|
||||
this.#relays = new DiffSyncTags(new NostrLink(NostrPrefix.Event, "", EventKind.Relays, pubkey));
|
||||
this.#contacts = new DiffSyncTags(new NostrLink(NostrPrefix.Event, "", EventKind.ContactList, pubkey), false);
|
||||
this.#relays = new DiffSyncTags(new NostrLink(NostrPrefix.Event, "", EventKind.Relays, pubkey), false);
|
||||
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);
|
||||
@ -415,7 +415,7 @@ export class UserState<TAppData> extends EventEmitter<UserStateEvents> {
|
||||
throw new Error("Not a standar list");
|
||||
}
|
||||
if (!this.#standardLists.has(kind)) {
|
||||
const list = new DiffSyncTags(new NostrLink(NostrPrefix.Event, "", kind, this.pubkey));
|
||||
const list = new DiffSyncTags(new NostrLink(NostrPrefix.Event, "", kind, this.pubkey), true);
|
||||
list.on("change", () => this.emit("change", UserStateChangeType.GenericList));
|
||||
this.#standardLists.set(kind, list);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user