mirror of
https://github.com/bitwarden/mobile
synced 2025-12-15 07:43:37 +00:00
[PM-6506] Fix double execution of command on returnType Go (#3039)
* [PM-6506] Fix double execution of command on returnType Go * [PM-6506] Hide keyboard on environment page close * [PM-6506] Task guard Co-authored-by: Federico Maccaroni <fedemkr@gmail.com> --------- Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Resources.Localization;
|
using Bit.Core.Resources.Localization;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
|
using Microsoft.Maui.Platform;
|
||||||
|
|
||||||
namespace Bit.App.Pages
|
namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
@@ -26,7 +27,7 @@ namespace Bit.App.Pages
|
|||||||
_apiEntry.ReturnCommand = new Command(() => _identityEntry.Focus());
|
_apiEntry.ReturnCommand = new Command(() => _identityEntry.Focus());
|
||||||
_identityEntry.ReturnType = ReturnType.Next;
|
_identityEntry.ReturnType = ReturnType.Next;
|
||||||
_identityEntry.ReturnCommand = new Command(() => _iconsEntry.Focus());
|
_identityEntry.ReturnCommand = new Command(() => _iconsEntry.Focus());
|
||||||
_vm.SubmitSuccessAction = () => MainThread.BeginInvokeOnMainThread(async () => await SubmitSuccessAsync());
|
_vm.SubmitSuccessTask = () => MainThread.InvokeOnMainThreadAsync(SubmitSuccessAsync);
|
||||||
_vm.CloseAction = async () =>
|
_vm.CloseAction = async () =>
|
||||||
{
|
{
|
||||||
await Navigation.PopModalAsync();
|
await Navigation.PopModalAsync();
|
||||||
@@ -37,6 +38,12 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
_platformUtilsService.ShowToast("success", null, AppResources.EnvironmentSaved);
|
_platformUtilsService.ShowToast("success", null, AppResources.EnvironmentSaved);
|
||||||
await Navigation.PopModalAsync();
|
await Navigation.PopModalAsync();
|
||||||
|
#if ANDROID
|
||||||
|
if (Platform.CurrentActivity.CurrentFocus != null)
|
||||||
|
{
|
||||||
|
Platform.CurrentActivity.HideKeyboard(Platform.CurrentActivity.CurrentFocus);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Close_Clicked(object sender, EventArgs e)
|
private void Close_Clicked(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Bit.App.Pages
|
|||||||
public string WebVaultUrl { get; set; }
|
public string WebVaultUrl { get; set; }
|
||||||
public string IconsUrl { get; set; }
|
public string IconsUrl { get; set; }
|
||||||
public string NotificationsUrls { get; set; }
|
public string NotificationsUrls { get; set; }
|
||||||
public Action SubmitSuccessAction { get; set; }
|
public Func<Task> SubmitSuccessTask { get; set; }
|
||||||
public Action CloseAction { get; set; }
|
public Action CloseAction { get; set; }
|
||||||
|
|
||||||
public async Task SubmitAsync()
|
public async Task SubmitAsync()
|
||||||
@@ -73,7 +73,10 @@ namespace Bit.App.Pages
|
|||||||
IconsUrl = resUrls.Icons;
|
IconsUrl = resUrls.Icons;
|
||||||
NotificationsUrls = resUrls.Notifications;
|
NotificationsUrls = resUrls.Notifications;
|
||||||
|
|
||||||
SubmitSuccessAction?.Invoke();
|
if (SubmitSuccessTask != null)
|
||||||
|
{
|
||||||
|
await SubmitSuccessTask();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ValidateUrls()
|
public bool ValidateUrls()
|
||||||
|
|||||||
@@ -452,7 +452,11 @@ namespace Bit.iOS.Autofill
|
|||||||
ThemeManager.ApplyResourcesTo(environmentPage);
|
ThemeManager.ApplyResourcesTo(environmentPage);
|
||||||
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
||||||
{
|
{
|
||||||
vm.SubmitSuccessAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.SubmitSuccessTask = async () =>
|
||||||
|
{
|
||||||
|
await DismissViewControllerAsync(false);
|
||||||
|
await MainThread.InvokeOnMainThreadAsync(() => LaunchHomePage());
|
||||||
|
};
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using Bit.iOS.Core.Views;
|
|||||||
using Bit.iOS.Extension.Models;
|
using Bit.iOS.Extension.Models;
|
||||||
using CoreNFC;
|
using CoreNFC;
|
||||||
using Foundation;
|
using Foundation;
|
||||||
|
using Microsoft.Maui.ApplicationModel;
|
||||||
using Microsoft.Maui.Controls;
|
using Microsoft.Maui.Controls;
|
||||||
using Microsoft.Maui.Platform;
|
using Microsoft.Maui.Platform;
|
||||||
using MobileCoreServices;
|
using MobileCoreServices;
|
||||||
@@ -528,7 +529,11 @@ namespace Bit.iOS.Extension
|
|||||||
ThemeManager.ApplyResourcesTo(environmentPage);
|
ThemeManager.ApplyResourcesTo(environmentPage);
|
||||||
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
||||||
{
|
{
|
||||||
vm.SubmitSuccessAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.SubmitSuccessTask = async () =>
|
||||||
|
{
|
||||||
|
await DismissViewControllerAsync(false);
|
||||||
|
await MainThread.InvokeOnMainThreadAsync(() => LaunchHomePage());
|
||||||
|
};
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ using Bit.iOS.Core.Views;
|
|||||||
using Bit.iOS.ShareExtension.Models;
|
using Bit.iOS.ShareExtension.Models;
|
||||||
using CoreNFC;
|
using CoreNFC;
|
||||||
using Foundation;
|
using Foundation;
|
||||||
|
using Microsoft.Maui.ApplicationModel;
|
||||||
using Microsoft.Maui.Controls;
|
using Microsoft.Maui.Controls;
|
||||||
using Microsoft.Maui.Platform;
|
using Microsoft.Maui.Platform;
|
||||||
using MobileCoreServices;
|
using MobileCoreServices;
|
||||||
@@ -321,7 +322,11 @@ namespace Bit.iOS.ShareExtension
|
|||||||
ThemeManager.ApplyResourcesTo(environmentPage);
|
ThemeManager.ApplyResourcesTo(environmentPage);
|
||||||
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
if (environmentPage.BindingContext is EnvironmentPageViewModel vm)
|
||||||
{
|
{
|
||||||
vm.SubmitSuccessAction = () => DismissAndLaunch(() => LaunchHomePage());
|
vm.SubmitSuccessTask = async () =>
|
||||||
|
{
|
||||||
|
await DismissViewControllerAsync(false);
|
||||||
|
await MainThread.InvokeOnMainThreadAsync(() => LaunchHomePage());
|
||||||
|
};
|
||||||
vm.CloseAction = () => DismissAndLaunch(() => LaunchHomePage());
|
vm.CloseAction = () => DismissAndLaunch(() => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user