Skip to content

Code Quality: Deleted ItemViewModel.ApplySingleFileChangeAsync #14575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
28 changes: 3 additions & 25 deletions src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ private async void RecycleBinItemDeletedAsync(object sender, FileSystemEventArgs
var removedItem = await RemoveFileOrFolderAsync(e.FullPath);

if (removedItem is not null)
await ApplySingleFileChangeAsync(removedItem);
await ApplyFilesAndFoldersChangesAsync();
}

private async void RecycleBinItemCreatedAsync(object sender, FileSystemEventArgs e)
Expand All @@ -534,7 +534,7 @@ private async void RecycleBinItemCreatedAsync(object sender, FileSystemEventArgs

await AddFileOrFolderAsync(newListedItem);
await OrderFilesAndFoldersAsync();
await ApplySingleFileChangeAsync(newListedItem);
await ApplyFilesAndFoldersChangesAsync();
}

private async void FolderSizeProvider_SizeChanged(object? sender, SizeChangedEventArgs e)
Expand Down Expand Up @@ -651,28 +651,6 @@ public void CancelExtendedPropertiesLoadingForItem(ListedItem item)
itemLoadQueue.TryUpdate(item.ItemPath, true, false);
}

public async Task ApplySingleFileChangeAsync(ListedItem item)
{
var newIndex = filesAndFolders.IndexOf(item);
await dispatcherQueue.EnqueueOrInvokeAsync(() =>
{
FilesAndFolders.Remove(item);
if (newIndex != -1)
FilesAndFolders.Insert(Math.Min(newIndex, FilesAndFolders.Count), item);

if (folderSettings.DirectoryGroupOption != GroupOption.None)
{
var key = FilesAndFolders.ItemGroupKeySelector?.Invoke(item);
var group = FilesAndFolders.GroupedCollection?.FirstOrDefault(x => x.Model.Key == key);
group?.OrderOne(list => SortingHelper.OrderFileList(list, folderSettings.DirectorySortOption, folderSettings.DirectorySortDirection,
folderSettings.SortDirectoriesAlongsideFiles, folderSettings.SortFilesFirst), item);
}

UpdateEmptyTextType();
DirectoryInfoUpdated?.Invoke(this, EventArgs.Empty);
});
}

private bool IsSearchResults { get; set; }

public void UpdateEmptyTextType()
Expand Down Expand Up @@ -1102,7 +1080,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
if (folderSettings.DirectorySortOption == SortOption.Name && !isLoadingItems)
{
await OrderFilesAndFoldersAsync();
await ApplySingleFileChangeAsync(item);
await ApplyFilesAndFoldersChangesAsync();
}
}

Expand Down