This commit is contained in:
James Babcock committed 2026-09-22 21:40:55 -07:00
commit 92e8def0f0
3 files changed
+175 -7

No files matched your search

+29 -6
View File
@@ -124,9 +124,16 @@ export class EvenHubStoreLayer implements Layer {
paint(ctx: LayerContext): GrayImage {
if (!this.started) {
this.started = true;
if (this.showingLogin) {
this.openCredentialEditor(ctx);
} else {
// Do NOT open the phone credential editor here. This runs on the first
// paint, which includes the restore of a still-open EvenHub at app
// startup -- so an unfinished sign-in re-opened the form on every launch,
// and the form has no way out: it has no Cancel control, its onCancel is
// dropped before it reaches the controller, and Back leaves the app
// rather than closing it. The login pane already says "Enter your Even
// account email and password in the phone app" and already opens the
// editor on click (handleInput), so the editor is still one tap away for
// someone who actually wants it.
if (!this.showingLogin) {
void this.ensureTabLoaded(ctx, this.activeTab);
}
}
@@ -650,7 +657,11 @@ export class EvenHubStoreLayer implements Layer {
return true;
}
private enterLogin(ctx: LayerContext, status = "Sign in to browse public apps."): void {
private enterLogin(
ctx: LayerContext,
status = "Sign in to browse public apps.",
openEditor = true,
): void {
const wasShowingLogin = this.showingLogin;
this.closePhoneEditor(ctx.actions, "search");
this.showingLogin = true;
@@ -659,7 +670,7 @@ export class EvenHubStoreLayer implements Layer {
for (const tab of TABS) this.tabs[tab.id] = emptyTab();
this.focus = "list";
if (!wasShowingLogin) resetEvenHubLoginForm();
this.openCredentialEditor(ctx);
if (openEditor) this.openCredentialEditor(ctx);
ctx.actions.requestRender();
}
@@ -699,7 +710,19 @@ export class EvenHubStoreLayer implements Layer {
const email = evenHubLoginEmailSetting.get();
const password = evenHubLoginPasswordSetting.get();
if (!email.trim() || !password) {
this.enterLogin(ctx, "Email and password are required.");
// The phone editor has no Cancel control, so submitting an untouched form
// with the keyboard's Done key is the only way someone can back out of
// it. Reopening the editor there makes that a loop with no exit, so a
// wholly empty submission is treated as a cancel and leaves the editor
// closed -- the login pane still says how to get back in, and a click
// reopens the editor. A half-filled form is a real mistake, so that
// still reopens with the message.
const cancelled = !email.trim() && !password;
this.enterLogin(
ctx,
cancelled ? "Sign in to browse public apps." : "Email and password are required.",
!cancelled,
);
return;
}
this.loginBusy = true;
+20 -1
View File
@@ -204,6 +204,14 @@ class DashboardController {
private activeTextSettings: ConfigSettingString[] = [];
private activeTextEditorTitle = "";
private activeTextEditorOnFinish: (() => void) | null = null;
/**
* The caller's cancel callback. LayerActions has always declared this fifth
* parameter, but neither the wiring below nor startTextSettingsEdit accepted
* it, so it was dropped silently -- a 4-parameter function is assignable to a
* 5-parameter type, so nothing failed to compile. A caller that tracks its own
* "editor is open" state therefore had no way to learn the editor closed.
*/
private activeTextEditorOnCancel: (() => void) | null = null;
private activeTextEditorToggle: TextSettingsEditToggle | null = null;
private evenNotificationActive = false;
private evenAppConflictMessage = "";
@@ -320,7 +328,8 @@ class DashboardController {
title: string,
onFinish?: () => void,
toggle?: TextSettingsEditToggle,
) => this.startTextSettingsEdit(settings, title, onFinish, toggle),
onCancel?: () => void,
) => this.startTextSettingsEdit(settings, title, onFinish, toggle, onCancel),
endTextSettingEdit: () => this.endTextSettingEdit(),
startVoiceCapture: (endpointing = false) => this.startVoiceCapture(endpointing),
stopVoiceCapture: () => this.stopVoiceCapture(),
@@ -1881,11 +1890,13 @@ class DashboardController {
title: string,
onFinish?: () => void,
toggle?: TextSettingsEditToggle,
onCancel?: () => void,
): void {
this.activeTextSettings = Array.from(settings.slice(0, 2));
this.activeTextEditorTitle = title;
this.activeTextEditorOnFinish = onFinish ?? null;
this.activeTextEditorToggle = toggle ?? null;
this.activeTextEditorOnCancel = onCancel ?? null;
this.emit();
}
@@ -2002,11 +2013,16 @@ class DashboardController {
private endTextSettingEdit(): void {
const finishedSettings = this.activeTextSettings;
// Closing without the done key is a cancel from the caller's point of view.
// finishTextSettingEdit clears this first, so a completed edit never fires it.
const onCancel = this.activeTextEditorOnCancel;
this.activeTextSettings = [];
this.activeTextEditorTitle = "";
this.activeTextEditorOnFinish = null;
this.activeTextEditorToggle = null;
this.activeTextEditorOnCancel = null;
this.emit();
onCancel?.();
if (finishedSettings.includes(nightscoutSiteUrlSetting) || finishedSettings.includes(nightscoutApiTokenSetting)) {
void this.refreshNightscoutAfterSettingsChange();
}
@@ -2020,6 +2036,9 @@ class DashboardController {
finishActiveTextSettingEdit(): void {
if (!this.activeTextSettings.length) return;
const onFinish = this.activeTextEditorOnFinish;
// Completing is not cancelling: drop the cancel callback before
// endTextSettingEdit, which fires whatever is still set.
this.activeTextEditorOnCancel = null;
const closesGlassesEditor = this.activeTextSettings.length === 1;
this.endTextSettingEdit();
if (closesGlassesEditor && this.textEditorHost?.closeTextEditor()) {