Merge pull request 'Fix: No feed when nos2x-fox gives an empty relay list' (#548) from vivganes/snort:patch-547 into main

Reviewed-on: #548
This commit is contained in:
Kieran 2023-04-27 14:04:49 +00:00
commit 48852f3099
1 changed files with 8 additions and 1 deletions

View File

@ -88,7 +88,7 @@ export class MultiAccountStore extends ExternalStore<LoginSession> {
if (this.#accounts.has(key)) {
throw new Error("Already logged in with this pubkey");
}
const initRelays = relays ?? Object.fromEntries(DefaultRelays.entries());
const initRelays = this.decideInitRelays(relays);
const newSession = {
...LoggedOut,
publicKey: key,
@ -105,6 +105,13 @@ export class MultiAccountStore extends ExternalStore<LoginSession> {
return newSession;
}
decideInitRelays(relays: Record<string, RelaySettings> | undefined): Record<string, RelaySettings> {
if (relays && Object.keys(relays).length > 0) {
return relays;
}
return Object.fromEntries(DefaultRelays.entries());
}
loginWithPrivateKey(key: HexKey, entropy?: string, relays?: Record<string, RelaySettings>) {
const pubKey = secp.utils.bytesToHex(secp.schnorr.getPublicKey(key));
if (this.#accounts.has(pubKey)) {