mirror of
https://github.com/bitwarden/mobile
synced 2025-12-16 08:13:20 +00:00
PM-6798 Fix account switch on iOS Autofill extension and also changed to Try... actions for TaskCompletionSource to avoid exceptions on some occasions. (#3121)
Co-authored-by: Álison Fernandes <vvolkgang@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
310d8b363f
commit
8fd9e0203d
@@ -339,7 +339,7 @@ namespace Bit.iOS.Autofill
|
||||
{
|
||||
try
|
||||
{
|
||||
PerformSegue(SegueConstants.LOGIN_LIST, this);
|
||||
DismissViewController(false, () => PerformSegue(SegueConstants.LOGIN_LIST, this));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -352,26 +352,22 @@ namespace Bit.iOS.Autofill
|
||||
{
|
||||
if (_context.IsCreatingPasskey)
|
||||
{
|
||||
if (!await IsAuthed()
|
||||
||
|
||||
await _vaultTimeoutService.Value.IsLoggedOutByTimeoutAsync()
|
||||
||
|
||||
await _vaultTimeoutService.Value.ShouldLogOutByTimeoutAsync())
|
||||
{
|
||||
await NavigateAndWaitForUnlockAsync(Bit.Core.Enums.NavigationTarget.HomeLogin);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await IsLocked())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_context.UnlockVaultTcs?.SetCanceled();
|
||||
_context.UnlockVaultTcs = new TaskCompletionSource<bool>();
|
||||
MainThread.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
PerformSegue(SegueConstants.LOCK, this);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelper.LogEvenIfCantBeResolved(ex);
|
||||
}
|
||||
});
|
||||
|
||||
await _context.UnlockVaultTcs.Task;
|
||||
await NavigateAndWaitForUnlockAsync(Bit.Core.Enums.NavigationTarget.Lock);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -381,5 +377,17 @@ namespace Bit.iOS.Autofill
|
||||
throw new InvalidOperationNeedsUIException("Not authed or locked");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task NavigateAndWaitForUnlockAsync(Bit.Core.Enums.NavigationTarget navTarget)
|
||||
{
|
||||
_context.UnlockVaultTcs?.TrySetCanceled();
|
||||
_context.UnlockVaultTcs = new TaskCompletionSource<bool>();
|
||||
await MainThread.InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
DoNavigate(navTarget);
|
||||
});
|
||||
|
||||
await _context.UnlockVaultTcs.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user