Merge branch '2337-dont-show-offline-screen-after-pairing' into 'master'

Ignore offline event in Paired state (when success screen is shown)

Closes #2337

See merge request briar/briar!1672
This commit is contained in:
akwizgran
2022-06-17 13:16:28 +00:00

View File

@@ -135,12 +135,23 @@ class MailboxViewModel extends DbViewModel
} else if (e instanceof TransportInactiveEvent) {
TransportId id = ((TransportInactiveEvent) e).getTransportId();
if (!TorConstants.ID.equals(id)) return;
MailboxState lastState = pairingState.getLastValue();
if (lastState instanceof MailboxState.IsPaired) {
pairingState.setEvent(new MailboxState.IsPaired(false));
} else if (lastState != null) {
onTorInactive();
}
}
@UiThread
private void onTorInactive() {
MailboxState lastState = pairingState.getLastValue();
if (lastState instanceof MailboxState.IsPaired) {
// we are already paired, so use IsPaired state
pairingState.setEvent(new MailboxState.IsPaired(false));
} else if (lastState instanceof MailboxState.Pairing) {
MailboxState.Pairing p = (MailboxState.Pairing) lastState;
// check that we not just finished pairing (showing success screen)
if (!(p.pairingState instanceof MailboxPairingState.Paired)) {
pairingState.setEvent(new MailboxState.OfflineWhenPairing());
}
// else ignore offline event as user will be leaving UI flow anyway
}
}