mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Added dirty behavior
Removed restore action (-> Move action wip) Added additional check on DB size before auto saving Code cleanup
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Database.Commands.CloseDatabase;
|
||||
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
||||
|
||||
namespace ModernKeePass.Application.Common.Behaviors
|
||||
{
|
||||
public class SetDirtyBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
|
||||
{
|
||||
private readonly List<string> _excludedCommands = new List<string>
|
||||
{nameof(SaveDatabaseCommand), nameof(CloseDatabaseCommand)};
|
||||
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public SetDirtyBehavior(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next)
|
||||
{
|
||||
var response = await next();
|
||||
var queryName = typeof(TRequest).Name;
|
||||
if (queryName.Contains("Command") && !_excludedCommands.Contains(queryName))
|
||||
{
|
||||
_database.IsDirty = true;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -7,7 +7,6 @@ namespace ModernKeePass.Application.Common.Interfaces
|
||||
{
|
||||
public interface IDatabaseProxy
|
||||
{
|
||||
string ZeroId { get; }
|
||||
bool IsOpen { get; }
|
||||
string Name { get; }
|
||||
string RootGroupId { get; }
|
||||
@@ -17,6 +16,8 @@ namespace ModernKeePass.Application.Common.Interfaces
|
||||
string Compression { get; set; }
|
||||
bool IsRecycleBinEnabled { get; set; }
|
||||
string FileAccessToken { get; set; }
|
||||
int Size { get; set; }
|
||||
bool IsDirty { get; set; }
|
||||
|
||||
Task Open(byte[] file, Credentials credentials);
|
||||
Task ReOpen(byte[] file);
|
||||
|
Reference in New Issue
Block a user