fix: follow graph / readonly login
This commit is contained in:
@ -10,7 +10,7 @@ declare interface Nip44Window {
|
||||
encrypt(recipientHexPubKey: string, value: string): Promise<string>;
|
||||
decrypt(senderHexPubKey: string, value: string): Promise<string>;
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export class Nip7Signer implements EventSigner {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -94,7 +94,7 @@ export class UserState<TAppData> extends EventEmitter<UserStateEvents> {
|
||||
this.#relays.on("change", () => this.emit("change", UserStateChangeType.Relays));
|
||||
}
|
||||
|
||||
async init(signer: EventSigner, system: SystemInterface) {
|
||||
async init(signer: EventSigner | undefined, system: SystemInterface) {
|
||||
if (this.#didInit) {
|
||||
return;
|
||||
}
|
||||
@ -124,7 +124,7 @@ export class UserState<TAppData> extends EventEmitter<UserStateEvents> {
|
||||
);
|
||||
|
||||
// update relay metadata with value from contact list if not found
|
||||
if (this.#relays.value === undefined && this.#contacts.value?.content !== undefined) {
|
||||
if (this.#relays.value === undefined && this.#contacts.value?.content !== undefined && signer) {
|
||||
this.#log("Saving relays to NIP-65 relay list using %O", this.relays);
|
||||
for (const r of this.relays ?? []) {
|
||||
await this.addRelay(r.url, r.settings, false);
|
||||
@ -135,7 +135,7 @@ export class UserState<TAppData> extends EventEmitter<UserStateEvents> {
|
||||
|
||||
// migrate mutes into blocks
|
||||
const muteList = this.#standardLists.get(EventKind.MuteList);
|
||||
if (muteList && muteList.tags.length > 0) {
|
||||
if (muteList && muteList.tags.length > 0 && signer) {
|
||||
this.#log("Migrating mutes into blocks mutes=%i, blocks=%i", muteList.tags.length, muteList.encryptedTags.length);
|
||||
muteList.replace([], false);
|
||||
muteList.add(muteList!.tags, true);
|
||||
|
Reference in New Issue
Block a user