switchTo method
- UserId id
Switches to the account with the given id
.
Implementation
Future<void> switchTo(UserId id) async {
try {
router.nowhere();
final bool succeeded = await _authService.switchAccount(id);
if (succeeded) {
await Future.delayed(500.milliseconds);
router.tab = HomeTab.chats;
router.home();
} else {
await Future.delayed(500.milliseconds);
router.home();
await Future.delayed(500.milliseconds);
MessagePopup.error('err_account_unavailable'.l10n);
}
} catch (e) {
await Future.delayed(500.milliseconds);
router.home();
await Future.delayed(500.milliseconds);
MessagePopup.error(e);
}
}