Container refresh, delete multiple, preview fix
This commit is contained in:
@@ -7,13 +7,20 @@ namespace FileTime.Core.Command.CreateContainer;
|
||||
|
||||
public class CreateContainerCommand : CreateItemBase
|
||||
{
|
||||
public CreateContainerCommand(ITimelessContentProvider timelessContentProvider, IContentAccessorFactory contentAccessorFactory)
|
||||
private readonly ICommandSchedulerNotifier _commandSchedulerNotifier;
|
||||
|
||||
public CreateContainerCommand(
|
||||
ITimelessContentProvider timelessContentProvider,
|
||||
IContentAccessorFactory contentAccessorFactory,
|
||||
ICommandSchedulerNotifier commandSchedulerNotifier)
|
||||
: base(timelessContentProvider, contentAccessorFactory)
|
||||
{
|
||||
_commandSchedulerNotifier = commandSchedulerNotifier;
|
||||
}
|
||||
|
||||
protected override async Task CreateItem(IItemCreator itemCreator, IItem resolvedParent)
|
||||
{
|
||||
await itemCreator.CreateContainerAsync(resolvedParent.Provider, Parent!.GetChild(NewItemName!));
|
||||
await _commandSchedulerNotifier.RefreshContainer(Parent);
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,20 @@ namespace FileTime.Core.Command.CreateElement;
|
||||
|
||||
public class CreateElementCommand : CreateItemBase
|
||||
{
|
||||
public CreateElementCommand(ITimelessContentProvider timelessContentProvider, IContentAccessorFactory contentAccessorFactory)
|
||||
private readonly ICommandSchedulerNotifier _commandSchedulerNotifier;
|
||||
|
||||
public CreateElementCommand(
|
||||
ITimelessContentProvider timelessContentProvider,
|
||||
IContentAccessorFactory contentAccessorFactory,
|
||||
ICommandSchedulerNotifier commandSchedulerNotifier)
|
||||
: base(timelessContentProvider, contentAccessorFactory)
|
||||
{
|
||||
_commandSchedulerNotifier = commandSchedulerNotifier;
|
||||
}
|
||||
|
||||
protected override async Task CreateItem(IItemCreator itemCreator, IItem resolvedParent)
|
||||
{
|
||||
await itemCreator.CreateElementAsync(resolvedParent.Provider, Parent!.GetChild(NewItemName!));
|
||||
await _commandSchedulerNotifier.RefreshContainer(Parent);
|
||||
}
|
||||
}
|
||||
@@ -8,16 +8,19 @@ public class DeleteCommand : CommandBase, IExecutableCommand
|
||||
{
|
||||
private readonly IContentAccessorFactory _contentAccessorFactory;
|
||||
private readonly ITimelessContentProvider _timelessContentProvider;
|
||||
private readonly ICommandSchedulerNotifier _commandSchedulerNotifier;
|
||||
public bool HardDelete { get; set; }
|
||||
public List<FullName> ItemsToDelete { get; } = new();
|
||||
|
||||
public DeleteCommand(
|
||||
IContentAccessorFactory contentAccessorFactory,
|
||||
ITimelessContentProvider timelessContentProvider)
|
||||
ITimelessContentProvider timelessContentProvider,
|
||||
ICommandSchedulerNotifier commandSchedulerNotifier)
|
||||
: base("Delete")
|
||||
{
|
||||
_contentAccessorFactory = contentAccessorFactory;
|
||||
_timelessContentProvider = timelessContentProvider;
|
||||
_commandSchedulerNotifier = commandSchedulerNotifier;
|
||||
}
|
||||
|
||||
public override Task<CanCommandRun> CanRun(PointInTime currentTime)
|
||||
@@ -74,6 +77,11 @@ public class DeleteCommand : CommandBase, IExecutableCommand
|
||||
itemDeleters,
|
||||
deleteStrategy
|
||||
);
|
||||
|
||||
if (container.FullName is not null)
|
||||
{
|
||||
await _commandSchedulerNotifier.RefreshContainer(container.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
await itemDeleter.DeleteAsync(itemToDelete.Provider, itemToDelete.FullName!);
|
||||
|
||||
@@ -67,6 +67,9 @@ public class MoveCommand : CommandBase, IExecutableCommand
|
||||
var sourceItem = await _timelessContentProvider.GetItemByFullNameAsync(itemToMove.Source, PointInTime.Present);
|
||||
|
||||
var itemMover = GetOrAddItemMover(sourceItem.Provider);
|
||||
// Note: this is currently used for rename, so Target will be always the source container too
|
||||
// If this will be used for move between different containers, ContentProvider should be checked
|
||||
// And it should fall back to a copy+delete if the content providers are different
|
||||
await itemMover.RenameAsync(sourceItem.Provider, itemToMove.Source, itemToMove.Target);
|
||||
|
||||
if (itemToMove.Source.GetParent() is { } parent)
|
||||
|
||||
Reference in New Issue
Block a user