@@ -17,27 +17,25 @@ public async Task<IEnumerable<ShellFileItem>> GetPinnedFoldersAsync()
17
17
return result ;
18
18
}
19
19
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 )
26
25
{
27
26
foreach ( string folderPath in folderPaths )
28
27
await ContextMenu . InvokeVerb ( "pintohome" , new [ ] { folderPath } ) ;
29
28
30
29
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 ) ) ;
33
32
}
34
33
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 )
41
39
{
42
40
Type ? shellAppType = Type . GetTypeFromProgID ( "Shell.Application" ) ;
43
41
object ? shell = Activator . CreateInstance ( shellAppType ) ;
@@ -76,8 +74,8 @@ await SafetyExtensions.IgnoreExceptions(async () =>
76
74
}
77
75
78
76
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 ) ) ;
81
79
}
82
80
83
81
public bool IsItemPinned ( string folderPath )
@@ -93,11 +91,15 @@ public async Task SaveAsync(string[] items)
93
91
App . QuickAccessManager . PinnedItemsWatcher . EnableRaisingEvents = false ;
94
92
95
93
// 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 ) ;
97
95
98
- await PinToSidebarAsync ( items ) ;
96
+ await PinToSidebarAsync ( items , false ) ;
99
97
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
+ } ) ;
101
103
}
102
104
}
103
105
}
0 commit comments