fix: mute buttons

closes #748
This commit is contained in:
2024-09-09 14:27:59 +01:00
parent c515e9837d
commit f2319b074f
7 changed files with 47 additions and 27 deletions

View File

@ -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) {

View File

@ -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