Skip to content

Commit

Permalink
fix: queue index is now stable after an item addition
Browse files Browse the repository at this point in the history
  • Loading branch information
zznty committed Oct 7, 2024
1 parent 4f474b8 commit 1c8ace3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions MusicX/Patches/ItemContainerGeneratorIndexHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,22 @@ public static void Apply()
var itemRemovedMethod = typeof(ItemContainerGenerator).GetMethod("OnItemRemoved",
BindingFlags.Instance | BindingFlags.NonPublic)!;

var itemAddedMethod = typeof(ItemContainerGenerator).GetMethod("OnItemAdded",
BindingFlags.Instance | BindingFlags.NonPublic)!;

Hooks.Add(new ILHook(generateNextMethod, GenerateNextManipulator));
Hooks.Add(new ILHook(unlinkContainerFromItemMethod, UnlinkContainerFromItemManipulator));
Hooks.Add(new ILHook(itemReplacedMethod, ItemReplacedManipulator));
Hooks.Add(new Hook(itemMovedMethod, ItemMovedHook));
Hooks.Add(new ILHook(itemMovedMethod, ItemMovedManipulator));
Hooks.Add(new Hook(itemRemovedMethod, ItemRemovedHook));
Hooks.Add(new Hook(itemAddedMethod, ItemAddedHook));
}

private static void ItemAddedHook(Action<ItemContainerGenerator, object, int> original, ItemContainerGenerator self, object item, int itemIndex)
{
original(self, item, itemIndex);
UpdateContainerIndices(self, itemIndex);
}

private static void ItemRemovedHook(Action<ItemContainerGenerator, object, int> original,
Expand Down

0 comments on commit 1c8ace3

Please sign in to comment.