diff --git a/app/src/main/java/de/jeanlucmakiola/agendula/data/sync/PendingLoginFlowStore.kt b/app/src/main/java/de/jeanlucmakiola/agendula/data/sync/PendingLoginFlowStore.kt index e63bdb1..2f0280d 100644 --- a/app/src/main/java/de/jeanlucmakiola/agendula/data/sync/PendingLoginFlowStore.kt +++ b/app/src/main/java/de/jeanlucmakiola/agendula/data/sync/PendingLoginFlowStore.kt @@ -114,8 +114,9 @@ class PendingLoginFlowStore @Inject constructor( is NextcloudLoginFlow.PollResult.Expired -> forget() - // Still inside the window, or the server had a moment. Either way the - // token is still worth something; the deadline retires it. + // Still inside the window, or the server had a moment. Either way + // the token is still worth something, so it is left for the next + // open; a poll past the deadline answers Expired and clears it. NextcloudLoginFlow.PollResult.Pending, is NextcloudLoginFlow.PollResult.Failed, -> Unit diff --git a/app/src/main/java/de/jeanlucmakiola/agendula/ui/accounts/AddAccountViewModel.kt b/app/src/main/java/de/jeanlucmakiola/agendula/ui/accounts/AddAccountViewModel.kt index 67c89f1..004da5d 100644 --- a/app/src/main/java/de/jeanlucmakiola/agendula/ui/accounts/AddAccountViewModel.kt +++ b/app/src/main/java/de/jeanlucmakiola/agendula/ui/accounts/AddAccountViewModel.kt @@ -269,7 +269,12 @@ class AddAccountViewModel @Inject constructor( // what the flow's own doc asks for: the browser is a separate task, so // dying while the user approves is ordinary, and the poll token is the // only way back to the password the server is about to mint. - pendingFlow.remember(flow) + // + // ⚠️ Guarded: a DataStore write can throw, and this runs in + // viewModelScope, where an escaping exception takes the app down. A + // flow we failed to write down is a reclaim we will not get, not a + // reason to lose the sign-in in front of the user. + runCatching { pendingFlow.remember(flow) } _state.update { it.copy( step = AddAccountStep.WaitingForBrowser(hostMismatch = flow.hostMismatch),