@ -101,11 +101,7 @@ export class DiffSyncTags extends EventEmitter<SafeSyncEvents> {
|
||||
|
||||
async sync(signer: EventSigner | undefined, system: SystemInterface) {
|
||||
await this.#sync.sync(system);
|
||||
|
||||
if (this.#sync.value?.content && this.contentEncrypted && signer) {
|
||||
const decrypted = await signer.nip4Decrypt(this.#sync.value.content, await signer.getPubKey());
|
||||
this.#decryptedContent = decrypted;
|
||||
}
|
||||
await this.#afterSync(signer);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,6 +119,15 @@ export class DiffSyncTags extends EventEmitter<SafeSyncEvents> {
|
||||
next.content = await signer.nip4Encrypt(next.content, await signer.getPubKey());
|
||||
}
|
||||
await this.#sync.update(next, signer, system, !isNew);
|
||||
await this.#afterSync(signer);
|
||||
}
|
||||
|
||||
async #afterSync(signer: EventSigner | undefined) {
|
||||
if (this.#sync.value?.content && this.contentEncrypted && signer) {
|
||||
const decrypted = await signer.nip4Decrypt(this.#sync.value.content, await signer.getPubKey());
|
||||
this.#decryptedContent = decrypted;
|
||||
this.emit("change");
|
||||
}
|
||||
}
|
||||
|
||||
#nextEvent(content?: string): NotSignedNostrEvent {
|
||||
@ -141,6 +146,7 @@ export class DiffSyncTags extends EventEmitter<SafeSyncEvents> {
|
||||
// apply changes onto next
|
||||
next.tags = this.#applyChanges(next.tags, this.#changes);
|
||||
if (this.#changesEncrypted.length > 0 && !content) {
|
||||
debugger;
|
||||
const encryptedTags = this.#applyChanges(isNew ? [] : this.encryptedTags, this.#changesEncrypted);
|
||||
next.content = JSON.stringify(encryptedTags);
|
||||
} else if (content) {
|
||||
|
@ -117,12 +117,13 @@ export class UserState<TAppData> extends EventEmitter<UserStateEvents> {
|
||||
}
|
||||
await Promise.all(tasks);
|
||||
this.#log(
|
||||
"Init results: profile=%O, contacts=%O, relays=%O, appdata=%O, lists=%O",
|
||||
"Init results: signer=%s, profile=%O, contacts=%O, relays=%O, appdata=%O, lists=%O",
|
||||
signer ? "yes" : "no",
|
||||
this.#profile.json,
|
||||
this.#contacts.value,
|
||||
this.#relays.value,
|
||||
this.#appdata?.json,
|
||||
[...this.#standardLists.values()].map(a => a.value),
|
||||
[...this.#standardLists.values()].map(a => [a.value, a.encryptedTags]),
|
||||
);
|
||||
|
||||
// update relay metadata with value from contact list if not found
|
||||
|
Reference in New Issue
Block a user