mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Send a message on save to update commands can execute
This commit is contained in:
@@ -41,6 +41,7 @@ namespace ModernKeePass
|
||||
private readonly IDialogService _dialog;
|
||||
private readonly INotificationService _notification;
|
||||
private readonly IFileProxy _file;
|
||||
private readonly IMessenger _messenger;
|
||||
|
||||
public static IServiceProvider Services { get; private set; }
|
||||
|
||||
@@ -67,14 +68,14 @@ namespace ModernKeePass
|
||||
_notification = Services.GetService<INotificationService>();
|
||||
_hockey = Services.GetService<IHockeyClient>();
|
||||
_file = Services.GetService<IFileProxy>();
|
||||
var messenger = Services.GetService<IMessenger>();
|
||||
_messenger = Services.GetService<IMessenger>();
|
||||
|
||||
InitializeComponent();
|
||||
Suspending += OnSuspending;
|
||||
Resuming += OnResuming;
|
||||
UnhandledException += OnUnhandledException;
|
||||
|
||||
messenger.Register<SaveErrorMessage>(this, async message => await HandelSaveError(message.Message));
|
||||
_messenger.Register<SaveErrorMessage>(this, async message => await HandelSaveError(message.Message));
|
||||
}
|
||||
|
||||
private async Task HandelSaveError(string message)
|
||||
@@ -84,7 +85,11 @@ namespace ModernKeePass
|
||||
var file = await _file.CreateFile($"{database.Name} - copy",
|
||||
Domain.Common.Constants.Extensions.Kdbx,
|
||||
_resource.GetResourceValue("MessageDialogSaveErrorFileTypeDesc"), true);
|
||||
if (file != null) await _mediator.Send(new SaveDatabaseCommand { FilePath = file.Id });
|
||||
if (file != null)
|
||||
{
|
||||
await _mediator.Send(new SaveDatabaseCommand { FilePath = file.Id });
|
||||
_messenger.Send(new DatabaseSavedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
#region Event Handlers
|
||||
|
@@ -266,6 +266,8 @@ namespace ModernKeePass.ViewModels
|
||||
DeleteCommand = new RelayCommand(async () => await AskForDelete());
|
||||
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||
GoToParentCommand = new RelayCommand(() => GoToGroup(_parent.Id));
|
||||
|
||||
MessengerInstance.Register<DatabaseSavedMessage>(this, _ => SaveCommand.RaiseCanExecuteChanged());
|
||||
}
|
||||
|
||||
public async Task Initialize(string entryId)
|
||||
|
@@ -126,6 +126,8 @@ namespace ModernKeePass.ViewModels
|
||||
DeleteCommand = new RelayCommand(async () => await AskForDelete(),() => IsNotRoot);
|
||||
GoBackCommand = new RelayCommand(() => _navigation.GoBack());
|
||||
GoToParentCommand= new RelayCommand(() => GoToGroup(_parent.Id), () => _parent != null);
|
||||
|
||||
MessengerInstance.Register<DatabaseSavedMessage>(this, _ => SaveCommand.RaiseCanExecuteChanged());
|
||||
}
|
||||
|
||||
public async Task Initialize(string groupId)
|
||||
|
Reference in New Issue
Block a user