diff --git a/MusicX/Patches/ItemContainerGeneratorIndexHook.cs b/MusicX/Patches/ItemContainerGeneratorIndexHook.cs index 9a6eb72b..e1a377fe 100644 --- a/MusicX/Patches/ItemContainerGeneratorIndexHook.cs +++ b/MusicX/Patches/ItemContainerGeneratorIndexHook.cs @@ -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 original, ItemContainerGenerator self, object item, int itemIndex) + { + original(self, item, itemIndex); + UpdateContainerIndices(self, itemIndex); } private static void ItemRemovedHook(Action original,