Skip to content

Commit a8f1770

Browse files
committed
Fix MoveToTop and MoveToBottom not working
1 parent 3b61f17 commit a8f1770

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Files.Uwp/DataModels/SidebarPinnedModel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,12 @@ public bool MoveItem(INavigationControlItem locationItem, int oldIndex, int newI
145145

146146
try
147147
{
148-
(FavoriteItems[oldIndex], FavoriteItems[newIndex]) = (FavoriteItems[newIndex], FavoriteItems[oldIndex]);
148+
FavoriteItems.RemoveAt(oldIndex);
149+
FavoriteItems.Insert(newIndex, locationItem.Path);
149150
lock (favoriteList)
150151
{
151-
(favoriteList[oldIndex], favoriteList[newIndex]) = (favoriteList[newIndex], favoriteList[oldIndex]);
152+
favoriteList.RemoveAt(oldIndex);
153+
favoriteList.Insert(newIndex, locationItem);
152154
}
153155
var e = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, locationItem, newIndex, oldIndex);
154156
controller.DataChanged?.Invoke(SectionType.Favorites, e);

src/Files.Uwp/UserControls/SidebarControl.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ private void MoveItemToTop()
392392
}
393393

394394
int oldIndex = App.SidebarPinnedController.Model.IndexOfItem(rightClickedItem);
395-
App.SidebarPinnedController.Model.MoveItem(rightClickedItem, oldIndex, 1);
395+
App.SidebarPinnedController.Model.MoveItem(rightClickedItem, oldIndex, 0);
396396

397397
if (isSelectedSidebarItem)
398398
{
@@ -455,7 +455,7 @@ private void MoveItemToBottom()
455455
}
456456

457457
int oldIndex = App.SidebarPinnedController.Model.IndexOfItem(rightClickedItem);
458-
App.SidebarPinnedController.Model.MoveItem(rightClickedItem, oldIndex, App.SidebarPinnedController.Model.FavoriteItems.Count);
458+
App.SidebarPinnedController.Model.MoveItem(rightClickedItem, oldIndex, App.SidebarPinnedController.Model.FavoriteItems.Count - 1);
459459

460460
if (isSelectedSidebarItem)
461461
{

0 commit comments

Comments
 (0)