File tree Expand file tree Collapse file tree 1 file changed +44
-4
lines changed
src/Files.App/Data/Models Expand file tree Collapse file tree 1 file changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -699,11 +699,51 @@ void ClearDisplay()
699
699
// run safely without needs of dispatching to UI thread
700
700
void ApplyChanges ( )
701
701
{
702
- if ( addFilesCTS . IsCancellationRequested )
703
- return ;
702
+ var startIndex = - 1 ;
703
+ var tempList = new List < ListedItem > ( ) ;
704
704
705
- FilesAndFolders . Clear ( ) ;
706
- FilesAndFolders . AddRange ( filesAndFoldersLocal ) ;
705
+ void ApplyBulkInsertEntries ( )
706
+ {
707
+ if ( startIndex != - 1 )
708
+ {
709
+ FilesAndFolders . ReplaceRange ( startIndex , tempList ) ;
710
+ startIndex = - 1 ;
711
+ tempList . Clear ( ) ;
712
+ }
713
+ }
714
+
715
+ for ( var i = 0 ; i < filesAndFoldersLocal . Count ; i ++ )
716
+ {
717
+ if ( addFilesCTS . IsCancellationRequested )
718
+ return ;
719
+
720
+ if ( i < FilesAndFolders . Count )
721
+ {
722
+ if ( FilesAndFolders [ i ] != filesAndFoldersLocal [ i ] )
723
+ {
724
+ if ( startIndex == - 1 )
725
+ startIndex = i ;
726
+
727
+ tempList . Add ( filesAndFoldersLocal [ i ] ) ;
728
+ }
729
+ else
730
+ {
731
+ ApplyBulkInsertEntries ( ) ;
732
+ }
733
+ }
734
+ else
735
+ {
736
+ ApplyBulkInsertEntries ( ) ;
737
+ FilesAndFolders . InsertRange ( i , filesAndFoldersLocal . Skip ( i ) ) ;
738
+
739
+ break ;
740
+ }
741
+ }
742
+
743
+ ApplyBulkInsertEntries ( ) ;
744
+
745
+ if ( FilesAndFolders . Count > filesAndFoldersLocal . Count )
746
+ FilesAndFolders . RemoveRange ( filesAndFoldersLocal . Count , FilesAndFolders . Count - filesAndFoldersLocal . Count ) ;
707
747
708
748
if ( folderSettings . DirectoryGroupOption != GroupOption . None )
709
749
OrderGroups ( ) ;
You can’t perform that action at this time.
0 commit comments