From 3434baab809f2c7b77fa004414258a71e871b00e Mon Sep 17 00:00:00 2001 From: Igor Matsak Date: Wed, 17 Mar 2021 18:55:52 +0300 Subject: [PATCH] SignOut after inactivity hot fix --- Atomex.Client.Wpf.Installer/Product.wxs | 2 +- Atomex.Client.Wpf/ViewModels/MainViewModel.cs | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Atomex.Client.Wpf.Installer/Product.wxs b/Atomex.Client.Wpf.Installer/Product.wxs index 6d07e4f..7290ede 100644 --- a/Atomex.Client.Wpf.Installer/Product.wxs +++ b/Atomex.Client.Wpf.Installer/Product.wxs @@ -3,7 +3,7 @@ - + diff --git a/Atomex.Client.Wpf/ViewModels/MainViewModel.cs b/Atomex.Client.Wpf/ViewModels/MainViewModel.cs index 3345b58..ec69464 100644 --- a/Atomex.Client.Wpf/ViewModels/MainViewModel.cs +++ b/Atomex.Client.Wpf/ViewModels/MainViewModel.cs @@ -214,25 +214,31 @@ private void OnUpdateClick() } private ICommand _signOutCommand; - public ICommand SignOutCommand => _signOutCommand ??= new Command(SignOut); + public ICommand SignOutCommand => _signOutCommand ??= new Command(() => { + _ = SignOutAsync(); + }); - private async void SignOut() + private async Task SignOutAsync() { try { if (await WhetherToCancelClosingAsync()) - return; + return false; DialogViewer.HideAllDialogs(); AtomexApp.UseTerminal(null); DialogViewer.ShowDialog(Dialogs.Start, new StartViewModel(AtomexApp, DialogViewer)); + + return true; } catch (Exception e) { Log.Error(e, "Sign Out error"); } + + return false; } private bool _forcedClose; @@ -290,6 +296,13 @@ private async Task WhetherToCancelClosingAsync() } private void InactivityHandler(object sender, EventArgs args) + { + MainView.StopInactivityControl(); + + ShowUnlockAfterInactivityDialog(); + } + + private void ShowUnlockAfterInactivityDialog() { if (AtomexApp?.Account == null) return; @@ -313,10 +326,15 @@ private void InactivityHandler(object sender, EventArgs args) unlockViewModel.Unlocked += (s, a) => { + MainView.StartInactivityControl(TimeSpan.FromMinutes(AtomexApp.Account.UserSettings.PeriodOfInactivityInMin)); DialogViewer?.HideDialog(Dialogs.Unlock); }; - DialogViewer?.ShowDialog(Dialogs.Unlock, unlockViewModel, canceled: () => SignOut()); + DialogViewer?.ShowDialog(Dialogs.Unlock, unlockViewModel, canceled: async () => + { + if (!await SignOutAsync()) + ShowUnlockAfterInactivityDialog(); + }); } private void DesignerMode()