Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
SignOut after inactivity hot fix
Browse files Browse the repository at this point in the history
  • Loading branch information
matsakiv committed Mar 17, 2021
1 parent da5e799 commit 3434baa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Atomex.Client.Wpf.Installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<?define Name = "Atomex Client" ?>
<?define Manufacturer = "Atomex.me" ?>
<?define Description = "Multicurrency HD wallet with built-in hybrid exchange based on atomic swap." ?>
<?define Version = "1.0.72" ?>
<?define Version = "1.0.73" ?>
<?define UpgradeCode = "DB7FCF8D-E0C6-4C99-A6B1-3FB6D703F97E" ?>
<?define ExeName = "Atomex.Client.Wpf.exe" ?>

Expand Down
26 changes: 22 additions & 4 deletions Atomex.Client.Wpf/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> 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;
Expand Down Expand Up @@ -290,6 +296,13 @@ private async Task<bool> WhetherToCancelClosingAsync()
}

private void InactivityHandler(object sender, EventArgs args)
{
MainView.StopInactivityControl();

ShowUnlockAfterInactivityDialog();
}

private void ShowUnlockAfterInactivityDialog()
{
if (AtomexApp?.Account == null)
return;
Expand All @@ -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()
Expand Down

0 comments on commit 3434baa

Please sign in to comment.