@@ -1214,34 +1214,28 @@ private async Task HandleTagItemDragOverAsync(FileTagItem tagItem, ItemDragOverE
1214
1214
1215
1215
args . RawEvent . Handled = true ;
1216
1216
1217
- // Comment out the code for dropping to Tags section as it is currently not supported.
1218
-
1219
- //var storageItems = await Utils.Storage.FilesystemHelpers.GetDraggedStorageItems(args.DroppedItem);
1220
-
1221
- //if (!storageItems.Any())
1222
- //{
1223
- args . RawEvent . AcceptedOperation = DataPackageOperation . None ;
1224
- //}
1225
- //else
1226
- //{
1227
- // args.RawEvent.DragUIOverride.IsCaptionVisible = true;
1228
- // args.RawEvent.DragUIOverride.Caption = string.Format("LinkToFolderCaptionText".GetLocalizedResource(), tagItem.Text);
1229
- // args.RawEvent.AcceptedOperation = DataPackageOperation.Link;
1230
- //}
1231
- }
1217
+ var storageItems = await Utils . Storage . FilesystemHelpers . GetDraggedStorageItems ( args . DroppedItem ) ;
1232
1218
1219
+ if ( ! storageItems . Any ( x => ! string . IsNullOrEmpty ( x . Path ) ) )
1220
+ {
1221
+ args . RawEvent . AcceptedOperation = DataPackageOperation . None ;
1222
+ }
1223
+ else
1224
+ {
1225
+ args . RawEvent . DragUIOverride . IsCaptionVisible = true ;
1226
+ args . RawEvent . DragUIOverride . Caption = string . Format ( "LinkToFolderCaptionText" . GetLocalizedResource ( ) , tagItem . Text ) ;
1227
+ args . RawEvent . AcceptedOperation = DataPackageOperation . Link ;
1228
+ }
1229
+ }
1233
1230
1234
1231
public async Task HandleItemDroppedAsync ( ItemDroppedEventArgs args )
1235
1232
{
1236
1233
if ( args . DropTarget is LocationItem locationItem )
1237
1234
await HandleLocationItemDroppedAsync ( locationItem , args ) ;
1238
1235
else if ( args . DropTarget is DriveItem driveItem )
1239
1236
await HandleDriveItemDroppedAsync ( driveItem , args ) ;
1240
-
1241
- // Comment out the code for dropping to Tags section as it is currently not supported.
1242
-
1243
- //else if (args.DropTarget is FileTagItem fileTagItem)
1244
- // await HandleTagItemDroppedAsync(fileTagItem, args);
1237
+ else if ( args . DropTarget is FileTagItem fileTagItem )
1238
+ await HandleTagItemDroppedAsync ( fileTagItem , args ) ;
1245
1239
}
1246
1240
1247
1241
private async Task HandleLocationItemDroppedAsync ( LocationItem locationItem , ItemDroppedEventArgs args )
@@ -1269,18 +1263,20 @@ private Task<ReturnResult> HandleDriveItemDroppedAsync(DriveItem driveItem, Item
1269
1263
return FilesystemHelpers . PerformOperationTypeAsync ( args . RawEvent . AcceptedOperation , args . RawEvent . DataView , driveItem . Path , false , true ) ;
1270
1264
}
1271
1265
1272
- // TODO: This method effectively does nothing. We need to implement the functionality for dropping to Tags section.
1273
1266
private async Task HandleTagItemDroppedAsync ( FileTagItem fileTagItem , ItemDroppedEventArgs args )
1274
1267
{
1275
1268
var storageItems = await Utils . Storage . FilesystemHelpers . GetDraggedStorageItems ( args . DroppedItem ) ;
1269
+ var dbInstance = FileTagsHelper . GetDbInstance ( ) ;
1276
1270
foreach ( var item in storageItems . Where ( x => ! string . IsNullOrEmpty ( x . Path ) ) )
1277
1271
{
1278
- var listedItem = new ListedItem ( null )
1272
+ var filesTags = FileTagsHelper . ReadFileTag ( item . Path ) ;
1273
+ if ( ! filesTags . Contains ( fileTagItem . FileTag . Uid ) )
1279
1274
{
1280
- ItemPath = item . Path ,
1281
- FileFRN = await FileTagsHelper . GetFileFRN ( item . Item ) ,
1282
- FileTags = [ fileTagItem . FileTag . Uid ]
1283
- } ;
1275
+ filesTags = [ .. filesTags , fileTagItem . FileTag . Uid ] ;
1276
+ var fileFRN = await FileTagsHelper . GetFileFRN ( item . Item ) ;
1277
+ dbInstance . SetTags ( item . Path , fileFRN , filesTags ) ;
1278
+ FileTagsHelper . WriteFileTag ( item . Path , filesTags ) ;
1279
+ }
1284
1280
}
1285
1281
}
1286
1282
0 commit comments