fix: follow graph / readonly login

This commit is contained in:
2024-05-01 10:34:28 +01:00
parent 778ce1a24f
commit 6398e470ef
11 changed files with 36 additions and 24 deletions

View File

@ -99,10 +99,10 @@ export class DiffSyncTags extends EventEmitter<SafeSyncEvents> {
this.emit("change");
}
async sync(signer: EventSigner, system: SystemInterface) {
async sync(signer: EventSigner | undefined, system: SystemInterface) {
await this.#sync.sync(system);
if (this.#sync.value?.content && this.contentEncrypted) {
if (this.#sync.value?.content && this.contentEncrypted && signer) {
const decrypted = await signer.nip4Decrypt(this.#sync.value.content, await signer.getPubKey());
this.#decryptedContent = decrypted;
}

View File

@ -25,11 +25,12 @@ export class JsonEventSync<T> extends EventEmitter<SafeSyncEvents> {
return Object.freeze(ret);
}
async sync(signer: EventSigner, system: SystemInterface) {
async sync(signer: EventSigner | undefined, system: SystemInterface) {
const res = await this.#sync.sync(system);
this.#log("Sync result %O", res);
if (res) {
if (this.encrypt) {
if (!signer) return;
this.#json = JSON.parse(await signer.nip4Decrypt(res.content, await signer.getPubKey())) as T;
} else {
this.#json = JSON.parse(res.content) as T;