mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Unregister the messenger everywhere on unload/navigate from
This commit is contained in:
@@ -193,5 +193,11 @@ namespace ModernKeePass.ViewModels
|
|||||||
MessengerInstance.Send(new DatabaseClosedMessage { Parameter = message.Parameter });
|
MessengerInstance.Send(new DatabaseClosedMessage { Parameter = message.Parameter });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Cleanup()
|
||||||
|
{
|
||||||
|
MessengerInstance.Unregister(this);
|
||||||
|
base.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,16 +18,10 @@ namespace ModernKeePass.Views
|
|||||||
public MainPage()
|
public MainPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Unloaded += MainPage_Unloaded;
|
|
||||||
ListView = MenuListView;
|
ListView = MenuListView;
|
||||||
ListViewSource = MenuItemsSource;
|
ListViewSource = MenuItemsSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainPage_Unloaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Model.Cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
private new void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private new void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
base.ListView_SelectionChanged(sender, e);
|
base.ListView_SelectionChanged(sender, e);
|
||||||
@@ -47,5 +41,10 @@ namespace ModernKeePass.Views
|
|||||||
file = e.Parameter as FileInfo;
|
file = e.Parameter as FileInfo;
|
||||||
await Model.Initialize(Frame, MenuFrame, file);
|
await Model.Initialize(Frame, MenuFrame, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
|
{
|
||||||
|
Model.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||||
|
|
||||||
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
using ModernKeePass.ViewModels;
|
||||||
|
|
||||||
namespace ModernKeePass.Views
|
namespace ModernKeePass.Views
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -7,9 +10,16 @@ namespace ModernKeePass.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class NewDatabasePage
|
public sealed partial class NewDatabasePage
|
||||||
{
|
{
|
||||||
|
public NewVm Model => (NewVm)DataContext;
|
||||||
|
|
||||||
public NewDatabasePage()
|
public NewDatabasePage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
|
{
|
||||||
|
Model.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238
|
// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238
|
||||||
|
|
||||||
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
using ModernKeePass.ViewModels;
|
||||||
|
|
||||||
namespace ModernKeePass.Views
|
namespace ModernKeePass.Views
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -7,9 +10,16 @@ namespace ModernKeePass.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class RecentDatabasesPage
|
public sealed partial class RecentDatabasesPage
|
||||||
{
|
{
|
||||||
|
public RecentVm Model => (RecentVm)DataContext;
|
||||||
|
|
||||||
public RecentDatabasesPage()
|
public RecentDatabasesPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
|
{
|
||||||
|
Model.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||||
|
|
||||||
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
using ModernKeePass.ViewModels;
|
||||||
|
|
||||||
namespace ModernKeePass.Views
|
namespace ModernKeePass.Views
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -7,9 +10,16 @@ namespace ModernKeePass.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class SaveDatabasePage
|
public sealed partial class SaveDatabasePage
|
||||||
{
|
{
|
||||||
|
public SaveVm Model => (SaveVm)DataContext;
|
||||||
|
|
||||||
public SaveDatabasePage()
|
public SaveDatabasePage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
|
{
|
||||||
|
Model.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||||
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||||
xmlns:converters="using:ModernKeePass.Converters"
|
xmlns:converters="using:ModernKeePass.Converters"
|
||||||
mc:Ignorable="d" >
|
mc:Ignorable="d">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<converters:EmptyStringToVisibilityConverter x:Key="EmptyStringToVisibilityConverter"/>
|
<converters:EmptyStringToVisibilityConverter x:Key="EmptyStringToVisibilityConverter"/>
|
||||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||||
@@ -85,6 +85,9 @@
|
|||||||
<core:DataTriggerBehavior Binding="{Binding IsError}" Value="False">
|
<core:DataTriggerBehavior Binding="{Binding IsError}" Value="False">
|
||||||
<core:GoToStateAction StateName="Initial"/>
|
<core:GoToStateAction StateName="Initial"/>
|
||||||
</core:DataTriggerBehavior>
|
</core:DataTriggerBehavior>
|
||||||
|
<core:EventTriggerBehavior EventName="Unloaded">
|
||||||
|
<core:CallMethodAction TargetObject="{Binding}" MethodName="Cleanup"/>
|
||||||
|
</core:EventTriggerBehavior>
|
||||||
</interactivity:Interaction.Behaviors>
|
</interactivity:Interaction.Behaviors>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@@ -133,6 +133,9 @@
|
|||||||
<core:DataTriggerBehavior Binding="{Binding IsKeyFileValid}" Value="True">
|
<core:DataTriggerBehavior Binding="{Binding IsKeyFileValid}" Value="True">
|
||||||
<core:GoToStateAction StateName="KeyFileValid"/>
|
<core:GoToStateAction StateName="KeyFileValid"/>
|
||||||
</core:DataTriggerBehavior>
|
</core:DataTriggerBehavior>
|
||||||
|
<core:EventTriggerBehavior EventName="Unloaded">
|
||||||
|
<core:CallMethodAction TargetObject="{Binding}" MethodName="Cleanup"/>
|
||||||
|
</core:EventTriggerBehavior>
|
||||||
</interactivity:Interaction.Behaviors>
|
</interactivity:Interaction.Behaviors>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@@ -72,5 +72,11 @@ namespace ModernKeePass.ViewModels
|
|||||||
var database = await _mediator.Send(new GetDatabaseQuery());
|
var database = await _mediator.Send(new GetDatabaseQuery());
|
||||||
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem { Id = database.RootGroupId });
|
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem { Id = database.RootGroupId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Cleanup()
|
||||||
|
{
|
||||||
|
MessengerInstance.Unregister(this);
|
||||||
|
base.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,5 +49,10 @@ namespace ModernKeePass.ViewModels
|
|||||||
_recent.ClearAll();
|
_recent.ClearAll();
|
||||||
RecentItems.Clear();
|
RecentItems.Clear();
|
||||||
}
|
}
|
||||||
|
public override void Cleanup()
|
||||||
|
{
|
||||||
|
MessengerInstance.Unregister(this);
|
||||||
|
base.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,5 +69,11 @@ namespace ModernKeePass.ViewModels
|
|||||||
await _mediator.Send(new CloseDatabaseCommand());
|
await _mediator.Send(new CloseDatabaseCommand());
|
||||||
_navigation.NavigateTo(Constants.Navigation.MainPage);
|
_navigation.NavigateTo(Constants.Navigation.MainPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Cleanup()
|
||||||
|
{
|
||||||
|
MessengerInstance.Unregister(this);
|
||||||
|
base.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -33,5 +33,11 @@ namespace ModernKeePass.ViewModels.Settings
|
|||||||
var database = await _mediator.Send(new GetDatabaseQuery());
|
var database = await _mediator.Send(new GetDatabaseQuery());
|
||||||
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
|
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Cleanup()
|
||||||
|
{
|
||||||
|
MessengerInstance.Unregister(this);
|
||||||
|
base.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -181,5 +181,11 @@ namespace ModernKeePass.ViewModels
|
|||||||
IsOpening = false;
|
IsOpening = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Cleanup()
|
||||||
|
{
|
||||||
|
MessengerInstance.Unregister(this);
|
||||||
|
base.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -150,5 +150,11 @@ namespace ModernKeePass.ViewModels
|
|||||||
KeyFilePath = HasKeyFile ? KeyFilePath : null
|
KeyFilePath = HasKeyFile ? KeyFilePath : null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Cleanup()
|
||||||
|
{
|
||||||
|
MessengerInstance.Unregister(this);
|
||||||
|
base.Cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user