LegionInvasionTimer

LegionInvasionTimer

1M Downloads

LDB source not registered in ElvUI

esvarc opened this issue ยท 8 comments

commented

LDB plugin library is not included in package and not listed in embeds.xml, in code is library required by:

local ls = LibStub("LibDataBroker-1.1", true)

This library is dynamicaly registered only after bar starts, but it need to be inicialized at load or it will not be recognized by addons supporting LDB like ElvUI, because list of available LDB sources is checked on application load. This change in code fix it and register as source. In fact there is no reason why not have support for LDB on even if candybar is primary target.

	local ls = LibStub("LibDataBroker-1.1", true)
	local obj = ls:NewDataObject("LegionInvasionTimer", {type = "data source", icon = 132177, text = "..."})
       	function obj.OnTooltipShow(tooltip)
       		if not tooltip or not tooltip.AddLine or not tooltip.AddDoubleLine then return end
       		ShowTip(tooltip)
       	end
	local prevTime, label, repeater = 0, "", false
	local function update()
		prevTime = prevTime - 60
		obj.text = label..": ".. SecondsToTime(prevTime, true)
	end
	startBroker = function(text, timeLeft, icon)
		if obj then
			obj.icon = icon
			obj.text = text..": ".. SecondsToTime(timeLeft, true)
			prevTime = timeLeft
			label = text
			if repeater then repeater:Cancel() end
			repeater = C_Timer.NewTicker(60, update)
		end
	end
end
commented

Let me know if it's still an issue in v7.2.8

commented

LDB is not embedded in LIT by default, it assumes the display addon will embed it.

I'm going to assume ElvUI does not embed it either, in which case this might be a situation where you have no instances of the library loaded.

edit: No, I'm wrong. ElvUI does embed LDB, so I'm not sure where your problem lies.
I recommend you install BugSack as you may be encountering an error somewhere.

commented

I do have it embed in another addons. Until I did move registraction LDB to this part of inicialization in static do end cycle. ElvUI never did offer LegionTimer as source for datatext under bars. But usually all addons offering DLB have it embeded. ElvUI won't embed library because ElvUI is target for LDB plugins.

commented

ElvUI already is embedding LDB.

Anyway, I've embedded it into LIT, not that I think this will solve whatever issue you're having.

commented

Yes it still not registered as LDB source. See attached picture. When I do move LDB creation into do end cycle in static intialization it works.
not-registered

commented

This original code don't register LDB for ElvUI use:

	local obj
	local prevTime, label, repeater = 0, "", false
	local function update()
		prevTime = prevTime - 60
		obj.text = label..": ".. SecondsToTime(prevTime, true)
	end
	startBroker = function(text, timeLeft, icon)
		if not obj then
			obj = LibStub("LibDataBroker-1.1"):NewDataObject("LegionInvasionTimer", {type = "data source", icon = icon, text = text..": ".. SecondsToTime(timeLeft, true)})
			function obj.OnTooltipShow(tooltip)
				if not tooltip or not tooltip.AddLine or not tooltip.AddDoubleLine then return end
				ShowTip(tooltip)
			end
		end
		if obj then

And this modified does.

	local obj = LibStub("LibDataBroker-1.1"):NewDataObject("LegionInvasionTimer", {type = "data source", icon = icon, text = "..."})
       	function obj.OnTooltipShow(tooltip)
       		if not tooltip or not tooltip.AddLine or not tooltip.AddDoubleLine then return end
       		ShowTip(tooltip)
       	end
	local prevTime, label, repeater = 0, "", false
	local function update()
		prevTime = prevTime - 60
		obj.text = label..": ".. SecondsToTime(prevTime, true)
	end
	startBroker = function(text, timeLeft, icon)
		if obj then
commented

here is picture after code modification:
ok-registered

As I did just say, primary problem wasn't ebending library for LDB, but time when new LDB is registered. Your way register LDB after addons starts. ElvUI scan LDB plugins as sources only on start not later when you register new LDB object.

commented

ElvUI is obviously not listening to the correct event: LibDataBroker_DataObjectCreated

This is an ElvUI problem, report it to them, closing.