@@ -259,19 +259,20 @@ public async Task AddItemToSidebarAsync(string path)
259
259
{
260
260
var item = await FilesystemTasks . Wrap ( ( ) => DrivesManager . GetRootFromPathAsync ( path ) ) ;
261
261
var res = await FilesystemTasks . Wrap ( ( ) => StorageFileExtensions . DangerousGetFolderFromPathAsync ( path , item ) ) ;
262
- if ( res || ( FilesystemResult ) FolderHelpers . CheckFolderAccessWithWin32 ( path ) )
262
+ var lastItem = favoriteSection . ChildItems . LastOrDefault ( x => x . ItemType == NavigationControlItemType . Location && ! x . Path . Equals ( CommonPaths . RecycleBinPath ) ) ;
263
+ int insertIndex = lastItem != null ? favoriteSection . ChildItems . IndexOf ( lastItem ) + 1 : 0 ;
264
+ var locationItem = new LocationItem
263
265
{
264
- var lastItem = favoriteSection . ChildItems . LastOrDefault ( x => x . ItemType == NavigationControlItemType . Location && ! x . Path . Equals ( CommonPaths . RecycleBinPath ) ) ;
265
- int insertIndex = lastItem != null ? favoriteSection . ChildItems . IndexOf ( lastItem ) + 1 : 0 ;
266
- var locationItem = new LocationItem
267
- {
268
- Font = MainViewModel . FontName ,
269
- Path = path ,
270
- Section = SectionType . Favorites ,
271
- IsDefaultLocation = false ,
272
- Text = res . Result ? . DisplayName ?? Path . GetFileName ( path . TrimEnd ( '\\ ' ) )
273
- } ;
266
+ Font = MainViewModel . FontName ,
267
+ Path = path ,
268
+ Section = SectionType . Favorites ,
269
+ IsDefaultLocation = false ,
270
+ Text = res . Result ? . DisplayName ?? Path . GetFileName ( path . TrimEnd ( '\\ ' ) )
271
+ } ;
274
272
273
+ if ( res || ( FilesystemResult ) FolderHelpers . CheckFolderAccessWithWin32 ( path ) )
274
+ {
275
+ locationItem . IsInvalid = false ;
275
276
if ( res )
276
277
{
277
278
var iconData = await FileThumbnailHelper . LoadIconFromStorageItemAsync ( res . Result , 24u , Windows . Storage . FileProperties . ThumbnailMode . ListView ) ;
@@ -290,16 +291,17 @@ public async Task AddItemToSidebarAsync(string path)
290
291
locationItem . Icon = await CoreApplication . MainView . DispatcherQueue . EnqueueAsync ( ( ) => locationItem . IconData . ToBitmapAsync ( ) ) ;
291
292
}
292
293
}
293
-
294
- if ( ! favoriteSection . ChildItems . Any ( x => x . Path == locationItem . Path ) )
295
- {
296
- await CoreApplication . MainView . DispatcherQueue . EnqueueAsync ( ( ) => favoriteSection . ChildItems . Insert ( insertIndex , locationItem ) ) ;
297
- }
298
294
}
299
295
else
300
296
{
301
- Debug . WriteLine ( $ "Pinned item was invalid and will be removed from the file lines list soon: { res . ErrorCode } ") ;
302
- RemoveItem ( path ) ;
297
+ locationItem . Icon = await CoreApplication . MainView . DispatcherQueue . EnqueueAsync ( ( ) => UIHelpers . GetIconResource ( Constants . ImageRes . Folder ) ) ;
298
+ locationItem . IsInvalid = true ;
299
+ Debug . WriteLine ( $ "Pinned item was invalid { res . ErrorCode } , item: { path } ") ;
300
+ }
301
+
302
+ if ( ! favoriteSection . ChildItems . Any ( x => x . Path == locationItem . Path ) )
303
+ {
304
+ await CoreApplication . MainView . DispatcherQueue . EnqueueAsync ( ( ) => favoriteSection . ChildItems . Insert ( insertIndex , locationItem ) ) ;
303
305
}
304
306
}
305
307
0 commit comments