PM-3350 Quick workaround to allow 2nd factor auth to not get stuck in iOS in modals.

Updated some older "Device" code to the newer MAUI code.
This commit is contained in:
Dinis Vieira 2023-10-27 15:36:47 +01:00
parent ca57948d9f
commit 53e0e55915
No known key found for this signature in database
GPG key ID: 9389160FF6C295F3
2 changed files with 9 additions and 17 deletions

View file

@ -156,7 +156,7 @@ namespace Bit.App.Pages
try try
{ {
// TODO: [MAUI-Migration] added delay or the modal navigation doesn't happen because of modal-loading is shown // TODO: [MAUI-Migration] added delay or the modal navigation doesn't happen because of modal-loading is shown
await Task.Delay(200); await Task.Delay(1000);
await _deviceActionService.ShowLoadingAsync(AppResources.Loading); await _deviceActionService.ShowLoadingAsync(AppResources.Loading);
await _stateService.SetPreLoginEmailAsync(Email); await _stateService.SetPreLoginEmailAsync(Email);
await AccountSwitchingOverlayViewModel.RefreshAccountViewsAsync(); await AccountSwitchingOverlayViewModel.RefreshAccountViewsAsync();

View file

@ -1,7 +1,4 @@
using System; using Bit.App.Abstractions;
using System.Linq;
using System.Threading.Tasks;
using Bit.App.Abstractions;
using Bit.App.Controls; using Bit.App.Controls;
using Bit.Core.Resources.Localization; using Bit.Core.Resources.Localization;
using Bit.Core.Abstractions; using Bit.Core.Abstractions;
@ -9,8 +6,6 @@ using Bit.Core.Enums;
using Bit.Core.Models.Data; using Bit.Core.Models.Data;
using Bit.Core.Services; using Bit.Core.Services;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Microsoft.Maui.Controls;
using Microsoft.Maui;
namespace Bit.App.Pages namespace Bit.App.Pages
{ {
@ -62,8 +57,7 @@ namespace Bit.App.Pages
_vm.VaultFilterDescription = vaultFilterSelection; _vm.VaultFilterDescription = vaultFilterSelection;
} }
// TODO Xamarin.Forms.Device.RuntimePlatform is no longer supported. Use Microsoft.Maui.Devices.DeviceInfo.Platform instead. For more details see https://learn.microsoft.com/en-us/dotnet/maui/migration/forms-projects#device-changes if (DeviceInfo.Platform == DevicePlatform.iOS)
if (Device.RuntimePlatform == Device.iOS)
{ {
_absLayout.Children.Remove(_fab); _absLayout.Children.Remove(_fab);
ToolbarItems.Add(_addItem); ToolbarItems.Add(_addItem);
@ -85,7 +79,7 @@ namespace Bit.App.Pages
} }
} }
protected async override void OnAppearing() protected override async void OnAppearing()
{ {
base.OnAppearing(); base.OnAppearing();
if (_syncService.SyncInProgress) if (_syncService.SyncInProgress)
@ -105,7 +99,7 @@ namespace Bit.App.Pages
{ {
if (message.Command == "syncStarted") if (message.Command == "syncStarted")
{ {
Device.BeginInvokeOnMainThread(() => IsBusy = true); MainThread.BeginInvokeOnMainThread(() => IsBusy = true);
} }
else if (message.Command == "syncCompleted") else if (message.Command == "syncCompleted")
{ {
@ -114,7 +108,7 @@ namespace Bit.App.Pages
{ {
_vm.AvatarImageSource = await GetAvatarImageSourceAsync(); _vm.AvatarImageSource = await GetAvatarImageSourceAsync();
} }
Device.BeginInvokeOnMainThread(() => MainThread.BeginInvokeOnMainThread(() =>
{ {
IsBusy = false; IsBusy = false;
if (_vm.LoadedOnce) if (_vm.LoadedOnce)
@ -164,8 +158,7 @@ namespace Bit.App.Pages
// Push registration // Push registration
var lastPushRegistration = await _stateService.GetPushLastRegistrationDateAsync(); var lastPushRegistration = await _stateService.GetPushLastRegistrationDateAsync();
lastPushRegistration = lastPushRegistration.GetValueOrDefault(DateTime.MinValue); lastPushRegistration = lastPushRegistration.GetValueOrDefault(DateTime.MinValue);
// TODO Xamarin.Forms.Device.RuntimePlatform is no longer supported. Use Microsoft.Maui.Devices.DeviceInfo.Platform instead. For more details see https://learn.microsoft.com/en-us/dotnet/maui/migration/forms-projects#device-changes if (DeviceInfo.Platform == DevicePlatform.iOS)
if (Device.RuntimePlatform == Device.iOS)
{ {
var pushPromptShow = await _stateService.GetPushInitialPromptShownAsync(); var pushPromptShow = await _stateService.GetPushInitialPromptShownAsync();
if (!pushPromptShow.GetValueOrDefault(false)) if (!pushPromptShow.GetValueOrDefault(false))
@ -180,7 +173,7 @@ namespace Bit.App.Pages
await _pushNotificationService.RegisterAsync(); await _pushNotificationService.RegisterAsync();
} }
} }
else if (Device.RuntimePlatform == Device.Android) else if (DeviceInfo.Platform == DevicePlatform.Android)
{ {
if (DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1)) if (DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1))
{ {
@ -292,8 +285,7 @@ namespace Bit.App.Pages
private async void AddButton_Clicked(object sender, EventArgs e) private async void AddButton_Clicked(object sender, EventArgs e)
{ {
// TODO Xamarin.Forms.Device.RuntimePlatform is no longer supported. Use Microsoft.Maui.Devices.DeviceInfo.Platform instead. For more details see https://learn.microsoft.com/en-us/dotnet/maui/migration/forms-projects#device-changes var skipAction = _accountListOverlay.IsVisible && DeviceInfo.Platform == DevicePlatform.Android;
var skipAction = _accountListOverlay.IsVisible && Device.RuntimePlatform == Device.Android;
await _accountListOverlay.HideAsync(); await _accountListOverlay.HideAsync();
if (skipAction) if (skipAction)
{ {