local function ChargeSquireLoaded(eventCode, addOnName)
	if(addOnName ~= "ChargeSquire") then return end

	local dialog = ESO_Dialogs["CHARGE_ITEM"]

	local hookfunction = dialog.buttons[1].callback
	local charger = SOUL_GEM_ITEM_CHARGER.chargesUnderlayBar
	-- Now we hook the 'item charge' function of the dialog
	dialog.buttons[1].callback =
		function()
    		-- Find out if we're filling the bar completely
    		if charger:GetValue() < charger.max then
    			-- And queue up the same dialog if not
    			-- This used to be just a queued dialog, but if you used up a single
    			-- type of gem, it wouldn't refresh the list properly, so we just delay
    			-- the call
    			local data = ZO_Dialogs_GetDisplayedDialog().data
    			zo_callLater(function() ZO_Dialogs_ShowDialog("CHARGE_ITEM", data) end, 1)
    		end
			hookfunction()
		end

end

EVENT_MANAGER:RegisterForEvent("ChargeSquireLoaded", EVENT_ADD_ON_LOADED, ChargeSquireLoaded)