Fix the EvenHub sign-in form reopening every launch and never closing

Open EvenHub once without finishing sign in and the phone side form comes back
on every app start, with no way to close it. Back exits the app rather than
closing the form.

Three things combine:

- EvenHubStoreLayer.paint() opened the credential editor on its first paint
  when no credentials were stored. First paint includes the restore of a
  still-open EvenHub at startup, so an unfinished sign in put the form back
  every time. handleInput already opens it on a click, so the auto open only
  removed the choice of when.

- LayerActions.startTextSettingsEdit declares a fifth onCancel parameter, but
  the DashboardController wiring forwarded four and the method accepted four.
  Nothing failed to compile, because a 4-parameter function is assignable to a
  5-parameter function type. That callback resets openCredentialEditor's
  phoneEditor guard, so with it dropped the guard latched at "credentials":
  the screen timeout hid the panel without resetting the state behind it, and
  the form could then be neither closed nor reopened. ios-preview-controller.ts
  already forwards all five, so this was the G2 path only.

- The panel has no Cancel control, so the keyboard's Done key on the password
  field is the only way to end the edit. On an untouched form that reached
  submitCredentials, which called enterLogin("Email and password are
  required."), which reopens the editor. A loop with no exit.

The auto open is removed; onCancel is forwarded, stored and fired from
endTextSettingEdit, with finishTextSettingEdit clearing it first so a completed
edit does not also report a cancel; and a wholly empty submission is treated as
a cancel. A half-filled form is a real mistake and still reopens with the
message.

tests/evenhub-signin.test.cjs covers the open and close contract through the
existing load-typescript.cjs loader. Two of its five tests fail against the
current store-layer.ts and pass with this change.
This commit is contained in:
JMO committed 2026-09-22 19:07:22 -07:00
1 parent 313ccd86d9
commit 662cbd75dc
3 files changed
+175 -7

No files matched your search

+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 = "";
@@ -321,7 +329,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(),
@@ -1884,11 +1893,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();
}
@@ -2005,11 +2016,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();
}
@@ -2023,6 +2039,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()) {