LibSort Update

CrazyDutchGuy [06-28-14 - 17:24]
LibSort Update
Filename
libs/LibSort-1.0/LibSort-1.0.lua
diff --git a/libs/LibSort-1.0/LibSort-1.0.lua b/libs/LibSort-1.0/LibSort-1.0.lua
index 9fdeede..cb5bd4c 100644
--- a/libs/LibSort-1.0/LibSort-1.0.lua
+++ b/libs/LibSort-1.0/LibSort-1.0.lua
@@ -1,4 +1,4 @@
-local MAJOR, MINOR = "LibSort-1.0", 3
+local MAJOR, MINOR = "LibSort-1.0", 4
 local LibSort, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 if not LibSort then return end	--the same or newer version of this lib is already loaded into memory

@@ -118,8 +118,17 @@ function LibSort:ProcessInventory(inventoryType)
 	end
 end

-ZO_PreHook(PLAYER_INVENTORY, "ApplySort", function(self, inventoryType) LibSort:ProcessInventory(inventoryType) end)
-LibSort:SetupArrows()
+function LibSort:Loaded(event, name)
+   	if name ~= "ZO_Ingame" then return end
+
+	ZO_PreHook(PLAYER_INVENTORY, "ApplySort", function(self, inventoryType) LibSort:ProcessInventory(inventoryType) end)
+	LibSort:SetupArrows()
+
+	EVENT_MANAGER:UnregisterForEvent("LibSortLoaded", EVENT_ADD_ON_LOADED)
+end
+
+EVENT_MANAGER:RegisterForEvent("LibSortLoaded", EVENT_ADD_ON_LOADED, function(...) LibSort:Loaded(...) end)
+
 --------- API ---------

 function LibSort:Unregister(addonName, name)