From 9fe777abd9d3522e85b0b185a2ac90c25d05b2df Mon Sep 17 00:00:00 2001 From: Danny Morabito Date: Wed, 2 Apr 2025 11:51:45 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Improve=20initial=20setup=20screen:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ๐Ÿ“Š Add relay log visibility during startup ๐Ÿ’ผ Implement automatic wallet configuration ๐Ÿงญ Add progress indicator showing current setup step ๐Ÿงน Fix minor linting issues throughout codebase --- package.json | 2 +- src/components/General/Button.ts | 1 + src/components/InitialSetup.ts | 123 +++++++++++++++---------------- src/components/ProgressSteps.ts | 114 ++++++++++++++++++++++++++++ src/electron/relayManager.ts | 39 +++++++++- src/routes/Settings.ts | 8 +- src/utils/formatDateTime.ts | 2 +- 7 files changed, 217 insertions(+), 72 deletions(-) create mode 100644 src/components/ProgressSteps.ts diff --git a/package.json b/package.json index b9705eb..3ae3477 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "email": "developers@arx-ccn.com" }, "scripts": { - "build": "tsc && electron-vite build", + "build": "electron-vite build", "build:mac": "npm run build && ./node_modules/.bin/electron-rebuild -p darwin -a x64 && electron-builder --mac", "build:linux": "bun run build && electron-builder --linux", "start": "electron-vite preview", diff --git a/src/components/General/Button.ts b/src/components/General/Button.ts index a1a5a64..86c4487 100644 --- a/src/components/General/Button.ts +++ b/src/components/General/Button.ts @@ -211,6 +211,7 @@ export class StyledButton extends LitElement { composed: true, }), ); + return; } private _handleKeyDown(e: KeyboardEvent) { diff --git a/src/components/InitialSetup.ts b/src/components/InitialSetup.ts index 06210c9..76dfd1e 100644 --- a/src/components/InitialSetup.ts +++ b/src/components/InitialSetup.ts @@ -10,11 +10,13 @@ import * as nostrTools from '@nostr/tools/pure'; import { encodeBase64 } from '@std/encoding/base64'; import { LitElement, css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; +import { when } from 'lit/directives/when.js'; import '@components/General/Button'; import '@components/General/Fieldset'; import '@components/General/Input'; import '@components/LoadingView'; +import '@components/ProgressSteps'; @customElement('arx-initial-setup') export class InitialSetup extends LitElement { @@ -24,6 +26,13 @@ export class InitialSetup extends LitElement { @state() private userName = ''; @state() private profileImage = ''; @state() private lightningAddress = ''; + @state() private relayStatus: { running: boolean; pid: number | null; logs: string[] } = { + running: false, + pid: null, + logs: [], + }; + + private readonly pageLabels = ['Welcome', 'Seed Phrase', 'Relay Setup', 'Profile', 'Complete']; get encryptionPassphrase() { let encryptionPassphrase = localStorage.getItem('encryption_key'); @@ -85,6 +94,7 @@ export class InitialSetup extends LitElement { oklch(from var(--color-accent) l calc(c * 1.2) h) ); -webkit-background-clip: text; + background-clip: text; color: transparent; margin-bottom: calc(var(--spacing-unit) * 8); } @@ -139,7 +149,6 @@ export class InitialSetup extends LitElement { } pre { - white-space: normal; background-color: var(--color-base-200); padding: calc(var(--spacing-unit) * 4); border-radius: var(--radius-field); @@ -220,6 +229,10 @@ export class InitialSetup extends LitElement { private renderPageOne() { return html`
+

Welcome to Eve

Your Private Community Network

@@ -270,6 +283,10 @@ export class InitialSetup extends LitElement { private renderPageTwo() { return html`
+

Getting Started

Creating a Community

@@ -338,11 +355,21 @@ export class InitialSetup extends LitElement { private async startRelay() { await window.relay.writeSeed(this.seedPhrase); await window.relay.start(this.encryptionPassphrase); + this.updateRelayStatus(); + } + + private async updateRelayStatus() { + this.relayStatus = await window.relay.getStatus(); + if (this.relayStatus.running) setTimeout(() => this.updateRelayStatus(), 2000); } private renderPageThree() { return html`
+

Configure Eve Relay

@@ -352,11 +379,25 @@ export class InitialSetup extends LitElement {

Please press the button below to start the relay.

this.startRelay()} > - Start Relay + ${when( + this.relayStatus.running, + () => html``, + )} + ${when( + this.relayStatus.running, + () => html` +

+ + Relay is running with PID: ${this.relayStatus.pid} +

+
${this.relayStatus.logs.slice(-5).join('\n')}
+ `, + )}

Having trouble? Our team is here to help if you encounter any issues. @@ -374,6 +415,7 @@ export class InitialSetup extends LitElement { this.handleNavigation(4)} variant="primary" + ?disabled=${!this.relayStatus.running} label="Continue" > @@ -390,13 +432,13 @@ export class InitialSetup extends LitElement { this.profileImage = e.detail.value; } - private onLightningAddressInput(e: CustomEvent<{ value: string }>) { - this.lightningAddress = e.detail.value; - } - private renderPageFour() { return html`

+

Complete Your Profile

Great progress! Let's set up your community profile.

@@ -437,9 +479,9 @@ export class InitialSetup extends LitElement { > this.handleNavigation(5)} + @click=${() => this.goToFinalStep()} variant="primary" - label="Final Step" + label="Next" > @@ -447,53 +489,12 @@ export class InitialSetup extends LitElement { `; } - private renderPageFive() { - return html` -
-
-

Payment Setup

-

Almost done! Let's set up your payment options.

-

- Enter your existing Lightning address below for payments within the - community. If you don't have one, leave this field blank and we'll - automatically generate one for you through - npub.cash. -

- - - Your Lightning address enables secure, instant payments within the - community. - -
- - -
- `; - } - private async goToFinalStep() { const randomPrivateKey = nostrTools.generateSecretKey(); const encryptedNsec = nip49.encrypt(randomPrivateKey, this.encryptionPassphrase); const npub = nip19.npubEncode(nostrTools.getPublicKey(randomPrivateKey)); - if (!this.lightningAddress) this.lightningAddress = `${npub}@npub.cash`; + this.lightningAddress = `${npub}@npub.cash`; localStorage.setItem('ncryptsec', encryptedNsec); @@ -510,12 +511,16 @@ export class InitialSetup extends LitElement { await event.sign(); await event.publish(); - this.handleNavigation(6); + this.handleNavigation(5); } - private renderPageSix() { + private renderPageFive() { return html`
+

Done!

@@ -528,19 +533,13 @@ export class InitialSetup extends LitElement { required to invite new members to the community.

Your username is: ${this.userName}

- ${ - this.profileImage - ? html`

- Your profile image is: -

` - : '' - } + ${when(this.profileImage, () => html`

Your profile image is:

`)}

Your lightning address is: ${this.lightningAddress}