Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 22 additions & 26 deletions src/Files.App/ViewModels/UserControls/SidebarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1214,34 +1214,28 @@ private async Task HandleTagItemDragOverAsync(FileTagItem tagItem, ItemDragOverE

args.RawEvent.Handled = true;

// Comment out the code for dropping to Tags section as it is currently not supported.

//var storageItems = await Utils.Storage.FilesystemHelpers.GetDraggedStorageItems(args.DroppedItem);

//if (!storageItems.Any())
//{
args.RawEvent.AcceptedOperation = DataPackageOperation.None;
//}
//else
//{
// args.RawEvent.DragUIOverride.IsCaptionVisible = true;
// args.RawEvent.DragUIOverride.Caption = string.Format("LinkToFolderCaptionText".GetLocalizedResource(), tagItem.Text);
// args.RawEvent.AcceptedOperation = DataPackageOperation.Link;
//}
}
var storageItems = await Utils.Storage.FilesystemHelpers.GetDraggedStorageItems(args.DroppedItem);

if (!storageItems.Any(x => !string.IsNullOrEmpty(x.Path)))
{
args.RawEvent.AcceptedOperation = DataPackageOperation.None;
}
else
{
args.RawEvent.DragUIOverride.IsCaptionVisible = true;
args.RawEvent.DragUIOverride.Caption = string.Format("LinkToFolderCaptionText".GetLocalizedResource(), tagItem.Text);
args.RawEvent.AcceptedOperation = DataPackageOperation.Link;
}
}

public async Task HandleItemDroppedAsync(ItemDroppedEventArgs args)
{
if (args.DropTarget is LocationItem locationItem)
await HandleLocationItemDroppedAsync(locationItem, args);
else if (args.DropTarget is DriveItem driveItem)
await HandleDriveItemDroppedAsync(driveItem, args);

// Comment out the code for dropping to Tags section as it is currently not supported.

//else if (args.DropTarget is FileTagItem fileTagItem)
// await HandleTagItemDroppedAsync(fileTagItem, args);
else if (args.DropTarget is FileTagItem fileTagItem)
await HandleTagItemDroppedAsync(fileTagItem, args);
}

private async Task HandleLocationItemDroppedAsync(LocationItem locationItem, ItemDroppedEventArgs args)
Expand Down Expand Up @@ -1269,18 +1263,20 @@ private Task<ReturnResult> HandleDriveItemDroppedAsync(DriveItem driveItem, Item
return FilesystemHelpers.PerformOperationTypeAsync(args.RawEvent.AcceptedOperation, args.RawEvent.DataView, driveItem.Path, false, true);
}

// TODO: This method effectively does nothing. We need to implement the functionality for dropping to Tags section.
private async Task HandleTagItemDroppedAsync(FileTagItem fileTagItem, ItemDroppedEventArgs args)
{
var storageItems = await Utils.Storage.FilesystemHelpers.GetDraggedStorageItems(args.DroppedItem);
var dbInstance = FileTagsHelper.GetDbInstance();
foreach (var item in storageItems.Where(x => !string.IsNullOrEmpty(x.Path)))
{
var listedItem = new ListedItem(null)
var filesTags = FileTagsHelper.ReadFileTag(item.Path);
if (!filesTags.Contains(fileTagItem.FileTag.Uid))
{
ItemPath = item.Path,
FileFRN = await FileTagsHelper.GetFileFRN(item.Item),
FileTags = [fileTagItem.FileTag.Uid]
};
filesTags = [.. filesTags, fileTagItem.FileTag.Uid];
var fileFRN = await FileTagsHelper.GetFileFRN(item.Item);
dbInstance.SetTags(item.Path, fileFRN, filesTags);
FileTagsHelper.WriteFileTag(item.Path, filesTags);
}
}
}

Expand Down