diff --git a/entry/src/main/ets/ui/ConnectionsPage.ets b/entry/src/main/ets/ui/ConnectionsPage.ets index b688f6a..cd49b06 100644 --- a/entry/src/main/ets/ui/ConnectionsPage.ets +++ b/entry/src/main/ets/ui/ConnectionsPage.ets @@ -124,6 +124,25 @@ export struct ConnectionsPage { } private connectHost(host: HostProfile): void { + this.launchFromDb(host.id, host); + } + + /** + * Re-fetch the host from the DB before connecting so a password persisted + * by an earlier session (persistPassword writes the DB, not this page's + * in-memory list) is picked up without requiring a page reload. + */ + private async launchFromDb(id: number, fallback: HostProfile): Promise { + let host: HostProfile = fallback; + try { + const repo: HostRepository = await this.ensureRepo(); + const fresh: HostProfile | null = await repo.getById(id); + if (fresh !== null) { + host = fresh; + } + } catch (e) { + // Fall back to the in-memory copy on any DB hiccup. + } this.launch(specFromHost(host)); }