commit b37561900fe1df40facf8810893c9f5cc2723b40
parent b8cd21deef44c51504da28e3321e8b1947c903b2
Author: finwo <finwo@pm.me>
Date: Sun, 14 Sep 2025 01:10:13 +0200
Made account selection chrome-compatible, added back button in account/create screen
Diffstat:
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/packages/app/src/component/screen-account-create.tsx b/packages/app/src/component/screen-account-create.tsx
@@ -5,6 +5,7 @@ import base64url from 'base64url';
import { getDirectoryHandle, getFileHandle } from '../util/opfs';
import {HomeScreen} from './screen-home';
+import {AccountSelectScreen} from './screen-account-select';
type _Vnode = Vnode<{}, typeof AccountCreateScreen>
@@ -19,6 +20,7 @@ export const AccountCreateScreen = {
accountId : '',
accountName: '',
+ hasAccounts: false,
deviceName : '',
seedPhrase : '',
@@ -153,6 +155,9 @@ export const AccountCreateScreen = {
<small>Not public, just for your reference</small>
</p>
<input id="accountName" value={vnode.state.accountName} style="display: block; width: calc(100% - 2rem);" type="text"/>
+ {vnode.state.hasAccounts ? [
+ <a class="btn" href={`#!${AccountSelectScreen.routePath}`}>Back</a>
+ ] : []}
<button onclick={vnode.state.handler.setAccountName(vnode)}>Next</button>
</div>
),
@@ -199,6 +204,19 @@ export const AccountCreateScreen = {
async oninit(vnode: _Vnode) {
vnode.state.seedPhrase = generateMnemonic();
vnode.state.accountId = randomString(16);
+
+ const accountsHandle = await getDirectoryHandle('/local/accounts');
+ for await (const accountId of accountsHandle.keys()) {
+ try {
+ await getFileHandle(`/local/accounts/${accountId}/config.json`, {}, {})
+ vnode.state.hasAccounts = true;
+ break;
+ } catch {
+ // Intentionally empty
+ }
+ }
+ m.redraw();
+
setTimeout(() => {
document.getElementById('accountName')?.focus();
}, 10);
diff --git a/packages/app/src/component/screen-account-select.tsx b/packages/app/src/component/screen-account-select.tsx
@@ -25,7 +25,7 @@ export const AccountSelectScreen = {
for await (const accountId of accountsHandle.keys()) {
try {
const accountConfigHandle = await getFileHandle(`/local/accounts/${accountId}/config.json`)
- const accountConfig = JSON.parse(Buffer.from(await (await accountConfigHandle.getFile()).bytes()));
+ const accountConfig = JSON.parse(Buffer.from(await (await accountConfigHandle.getFile()).arrayBuffer()));
vnode.state.accounts.push({
...accountConfig,
id: accountId,
diff --git a/packages/app/src/global.css b/packages/app/src/global.css
@@ -32,7 +32,7 @@ small {
color: #FFFA;
}
-a[href] {
+a {
color: inherit;
text-decoration: underline;
}
@@ -40,17 +40,20 @@ a[href] {
input:focus,
select:focus,
textarea:focus,
-button:focus {
+button:focus,
+.btn:focus {
outline: none;
}
-button {
+
+.btn, button {
border: 2px solid #FFFFFF;
background: #FFFFFF;
color: #000000;
margin: 1em;
padding: 0.25em 0.5em;
cursor: pointer;
+ text-decoration: none;
&:active {
background: #000000;
color: #FFFFFF;