@@ -17,27 +17,25 @@ public async Task<IEnumerable<ShellFileItem>> GetPinnedFoldersAsync()
1717 return result ;
1818 }
1919
20- public Task PinToSidebarAsync ( string folderPath )
21- {
22- return PinToSidebarAsync ( new [ ] { folderPath } ) ;
23- }
24-
25- public async Task PinToSidebarAsync ( string [ ] folderPaths )
20+ public Task PinToSidebarAsync ( string folderPath ) => PinToSidebarAsync ( new [ ] { folderPath } ) ;
21+
22+ public Task PinToSidebarAsync ( string [ ] folderPaths ) => PinToSidebarAsync ( folderPaths , true ) ;
23+
24+ private async Task PinToSidebarAsync ( string [ ] folderPaths , bool doUpdateQuickAccessWidget )
2625 {
2726 foreach ( string folderPath in folderPaths )
2827 await ContextMenu . InvokeVerb ( "pintohome" , new [ ] { folderPath } ) ;
2928
3029 await App . QuickAccessManager . Model . LoadAsync ( ) ;
31-
32- App . QuickAccessManager . UpdateQuickAccessWidget ? . Invoke ( this , new ModifyQuickAccessEventArgs ( folderPaths , true ) ) ;
30+ if ( doUpdateQuickAccessWidget )
31+ App . QuickAccessManager . UpdateQuickAccessWidget ? . Invoke ( this , new ModifyQuickAccessEventArgs ( folderPaths , true ) ) ;
3332 }
3433
35- public Task UnpinFromSidebarAsync ( string folderPath )
36- {
37- return UnpinFromSidebarAsync ( new [ ] { folderPath } ) ;
38- }
39-
40- public async Task UnpinFromSidebarAsync ( string [ ] folderPaths )
34+ public Task UnpinFromSidebarAsync ( string folderPath ) => UnpinFromSidebarAsync ( new [ ] { folderPath } ) ;
35+
36+ public Task UnpinFromSidebarAsync ( string [ ] folderPaths ) => UnpinFromSidebarAsync ( folderPaths , true ) ;
37+
38+ private async Task UnpinFromSidebarAsync ( string [ ] folderPaths , bool doUpdateQuickAccessWidget )
4139 {
4240 Type ? shellAppType = Type . GetTypeFromProgID ( "Shell.Application" ) ;
4341 object ? shell = Activator . CreateInstance ( shellAppType ) ;
@@ -76,8 +74,8 @@ await SafetyExtensions.IgnoreExceptions(async () =>
7674 }
7775
7876 await App . QuickAccessManager . Model . LoadAsync ( ) ;
79-
80- App . QuickAccessManager . UpdateQuickAccessWidget ? . Invoke ( this , new ModifyQuickAccessEventArgs ( folderPaths , false ) ) ;
77+ if ( doUpdateQuickAccessWidget )
78+ App . QuickAccessManager . UpdateQuickAccessWidget ? . Invoke ( this , new ModifyQuickAccessEventArgs ( folderPaths , false ) ) ;
8179 }
8280
8381 public bool IsItemPinned ( string folderPath )
@@ -93,11 +91,15 @@ public async Task SaveAsync(string[] items)
9391 App . QuickAccessManager . PinnedItemsWatcher . EnableRaisingEvents = false ;
9492
9593 // Unpin every item that is below this index and then pin them all in order
96- await UnpinFromSidebarAsync ( Array . Empty < string > ( ) ) ;
94+ await UnpinFromSidebarAsync ( Array . Empty < string > ( ) , false ) ;
9795
98- await PinToSidebarAsync ( items ) ;
96+ await PinToSidebarAsync ( items , false ) ;
9997 App . QuickAccessManager . PinnedItemsWatcher . EnableRaisingEvents = true ;
100- await App . QuickAccessManager . Model . LoadAsync ( ) ;
98+
99+ App . QuickAccessManager . UpdateQuickAccessWidget ? . Invoke ( this , new ModifyQuickAccessEventArgs ( items , true )
100+ {
101+ Reorder = true
102+ } ) ;
101103 }
102104 }
103105}
0 commit comments