Container refresh, delete multiple, preview fix
This commit is contained in:
@@ -434,6 +434,10 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
shouldDelete = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldDelete = true;
|
||||
}
|
||||
|
||||
if (itemsToDelete.Count == 0) return;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public partial class ElementPreviewViewModel : IItemPreviewViewModel, IAsyncInit
|
||||
|
||||
TextContent = content is null
|
||||
? "Could not read any data from file " + element.Name
|
||||
: Encoding.UTF8.GetString(content);
|
||||
: GetNormalizedText(Encoding.UTF8.GetString(content));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -35,5 +35,15 @@ public partial class ElementPreviewViewModel : IItemPreviewViewModel, IAsyncInit
|
||||
0 => ItemPreviewMode.Empty,
|
||||
_ => ItemPreviewMode.Text
|
||||
};
|
||||
|
||||
string GetNormalizedText(string text)
|
||||
{
|
||||
foreach (var c in text)
|
||||
{
|
||||
if (c < 32 && c != 9 && c != 10 && c != 13) return $"Binary data, contains '{(int) c}'";
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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