Skip to content

Commit a8df20a

Browse files
committed
(fix/Transmission): prevent missing controlledChildren when importing newer groups without their original parent
1 parent 77f7371 commit a8df20a

File tree

3 files changed

+45
-30
lines changed

3 files changed

+45
-30
lines changed

WeakAuras/Transmission.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ function WeakAuras.Import(inData, target, callbackFunc, linkedAuras)
541541
return nil, "Invalid import data."
542542
end
543543

544-
local highestVersion = data.internalVersion or 0
544+
-- Let people install auras that are newer than their version of WeakAuras, even tho it is bad
545+
--[[local highestVersion = data.internalVersion or 0
545546
if children then
546547
for _, child in ipairs(children) do
547548
highestVersion = max(highestVersion, child.internalVersion or 0)
@@ -551,7 +552,7 @@ function WeakAuras.Import(inData, target, callbackFunc, linkedAuras)
551552
-- Do not run PreAdd but still show Import Window
552553
tooltipLoading = nil;
553554
return ImportNow(data, children, target, linkedAuras, nil, callbackFunc)
554-
end
555+
end]]
555556

556557
if version < 2000 then
557558
if children then

WeakAurasOptions/OptionsFrames/ImportExport.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ local function ConstructImportExport(frame)
6262
elseif(mode == "table") then
6363
displayStr = OptionsPrivate.Private.DataToString(id, true);
6464
end
65-
input.editBox:SetMaxBytes(nil); -- Dragonflight doesn't accept nil
65+
--input.editBox:SetMaxBytes(nil); Dragonflight doesn't accept nil
6666
input.editBox:SetScript("OnEscapePressed", function()
6767
group:Close();
6868
end);

WeakAurasOptions/OptionsFrames/Update.lua

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -290,26 +290,39 @@ end
290290
local function BuildUidMap(data, children, type)
291291
children = children or {}
292292
-- The eventual result
293+
294+
--- @class UidMapData
295+
--- @field originalName auraId The original id of the aura
296+
--- @field id auraId The current id of the aura, might have changed due to ids being unique
297+
--- @field data auraData The raw data, is non-authoritative on e.g. id, controlledChildren, parent, sortHybridTable
298+
--- @field controlledChildren? uid[] A array of child uids
299+
--- @field parent? uid The parent uid
300+
--- @field sortHybrid boolean? optional bool !! the parent's sortHybridTable is split up and recorded per aura:
301+
--- nil, if the parent is not a dynamic group
302+
--- false/true based on the sortHybridTable of the dynamic group
303+
--- @field anchorFrameFrame uid? uid of the anchor iff the aura is anchored to another aura that is part of the same
304+
--- import, otherwise nil
305+
--- @field matchedUid uid? for "update", the matched uid. Is from a different domain!
306+
--- @field diff any for "update", the diff and the categories of that diff between the aura and its match
307+
--- @field categories? table the categories
308+
--- @field index? number helpers that transport data between phase 1 and 2
309+
--- @field total? number helpers that transport data between phase 1 and 2
310+
--- @field parentIsDynamicGroup? boolean helpers that transport data between phase 1 and 2
311+
312+
--- @class UidMap
313+
--- @field map table<uid, UidMapData>
314+
--- @field type "new"|"old"
315+
--- @field root uid uid of the root
316+
--- @field totalCount number
317+
--- @field idToUid table<auraId, uid> maps from id to uid
293318
local uidMap = {
294-
map = { -- per uid
295-
-- originalName: The original id of the aura
296-
-- id: The current id of the aura, might have changed due to ids being unique
297-
-- data: The raw data, contains non-authoritative information on e.g. id, controlledChildren, parent, sortHybridTable
298-
-- controlledChildren: A array of child uids
299-
-- parent: The parent uid
300-
-- sortHybrid: optional bool !! the parent's sortHybridTable is split up and recorded per aura:
301-
-- nil, if the parent is not a dynamic group
302-
-- false/true based on the sortHybridTable of the dynamic group
303-
304-
-- matchedUid: for "update", the matched uid. Is from a different domain!
305-
-- diff, categories: for "update", the diff and the categories of that diff between the aura and its match
306-
307-
-- index, total, parentIsDynamicGroup: helpers that transport data between phase 1 and 2
319+
--- @type table<uid, UidMapData>
320+
map = {
308321
},
309322
type = type, -- Either old or new, only used for error checking
310-
root = data.uid, -- root: uid of the root
311-
totalCount = #children + 1, -- totalCount: count of members
312-
idToUid = {} -- idToUid maps from id to uid
323+
root = data.uid,
324+
totalCount = #children + 1,
325+
idToUid = {}
313326
}
314327

315328
-- Build helper map from id to uid
@@ -348,17 +361,16 @@ local function BuildUidMap(data, children, type)
348361

349362
-- Handle anchorFrameFrame
350363
if data.anchorFrameType == "SELECTFRAME"
351-
and data.anchorFrameFrame
352-
and data.anchorFrameFrame:sub(1, 10) == "WeakAuras:"
353-
then
354-
local target = data.anchorFrameFrame:sub(11)
355-
if idToUid[target] then
356-
uidMap.map[data.uid].anchorFrameFrame = idToUid[target]
364+
and data.anchorFrameFrame
365+
and data.anchorFrameFrame:sub(1, 10) == "WeakAuras:"
366+
then
367+
local target = data.anchorFrameFrame:sub(11)
368+
if idToUid[target] then
369+
uidMap.map[data.uid].anchorFrameFrame = idToUid[target]
370+
end
357371
end
358372
end
359373

360-
end
361-
362374
local function handleSortHybridTable(data)
363375
if data.regionType == "dynamicgroup" then
364376
local sortHybridTableByUid = {}
@@ -1380,7 +1392,7 @@ local methods = {
13801392
self:ReleaseChildren()
13811393
self:AddBasicInformationWidgets(data, sender)
13821394

1383-
--[[
1395+
--[[ Let people install auras that are newer than their version of WeakAuras, even tho it is bad
13841396
do
13851397
local highestVersion = data.internalVersion or 0
13861398
if children then
@@ -1546,7 +1558,7 @@ local methods = {
15461558
self:AddChild(linkedAurasText)
15471559
end
15481560

1549-
-- Let people install auras that are newer than their version of WeakAuras
1561+
-- Let people install auras that are newer than their version of WeakAuras, even tho it is bad
15501562
local highestVersion = data.internalVersion or 0
15511563
if children then
15521564
for _, child in ipairs(children) do
@@ -1670,6 +1682,7 @@ local methods = {
16701682
self:AddBasicInformationWidgets(pendingData.data, pendingData.sender)
16711683
self:AddProgressWidgets()
16721684

1685+
---@type {uid: uid, data: auraData, source: string}[]
16731686
local copies = {}
16741687
local pendingPickData
16751688

@@ -2234,6 +2247,7 @@ local methods = {
22342247

22352248
local updateFrame
22362249
local function ConstructUpdateFrame(frame)
2250+
---@class GroupUpdateFrame: AceGUIFrame
22372251
local group = AceGUI:Create("ScrollFrame");
22382252
group.frame:SetParent(frame);
22392253
group.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 16, -63);

0 commit comments

Comments
 (0)