Skip to content

Commit

Permalink
Set default relays on [].
Browse files Browse the repository at this point in the history
  • Loading branch information
chmac committed May 26, 2024
1 parent e680889 commit 9eea113
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/nostr/relays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,15 @@ export const _subscribe = async ({
return subscriptions;
};

export const getDefaultRelays = () => {
const relays = isDev() ? DEV_RELAYS : DEFAULT_RELAYS;
return relays;
};

export const createRelays = async () => {
const relaysInstalled = await hasRelays();
if (!relaysInstalled) {
const relays = isDev() ? DEV_RELAYS : DEFAULT_RELAYS;
await setRelays({ relays });
const relays = getDefaultRelays();
setRelays({ relays });
}
};
3 changes: 1 addition & 2 deletions src/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export const startUserOnboarding = async () => {

await setPrivateKey({ privateKey: newKey });

const trustrootsUsername = getTrustrootsUsernameFromLocation();
await setProfile({ name: "", about: "", trustrootsUsername });
await setProfile({ name: "", about: "", trustrootsUsername: username });

await alert(
`Nice job. You're ready to create points now. Right click again to get started.`
Expand Down
3 changes: 2 additions & 1 deletion src/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "./nostr/keys";
import { startUserOnboarding } from "./onboarding";
import { startWelcomeSequence } from "./welcome";
import { getDefaultRelays } from "./nostr/relays";

// This is supported by parcel, our build system, but not recognised by
// typescript, so we declare it here so that we can use it below.
Expand Down Expand Up @@ -82,7 +83,7 @@ export const startup = async () => {
return;
}
const relays =
relaysFromJson.length === 0 ? DEFAULT_RELAYS : relaysFromJson;
relaysFromJson.length === 0 ? getDefaultRelays() : relaysFromJson;
await setRelays({ relays });
globalThis.alert("Relays saved.");
globalThis.document.location.reload();
Expand Down

0 comments on commit 9eea113

Please sign in to comment.