Handle characters that aren't fully loaded yet in UpdateName

This commit is contained in:
2023-03-18 16:35:02 +01:00
parent 7d1e3b933d
commit f14ffbe0bd

View File

@@ -446,7 +446,10 @@ end
function UnitFrame:UpdateName() function UnitFrame:UpdateName()
if UnitIsPlayer(self.unit) then if UnitIsPlayer(self.unit) then
local _, class = UnitClass(self.unit) local _, class = UnitClass(self.unit)
local color = RAID_CLASS_COLORS[class] -- TODO: UnitClass can return Unknown and the color can be nil. Having
-- the unit exist but not fully loaded is possibly a state we want to
-- handle more generally
local color = RAID_CLASS_COLORS[class] or {r=1, g=1, b=1}
self.name:SetTextColor(color.r, color.g, color.b) self.name:SetTextColor(color.r, color.g, color.b)
else else
self.name:SetTextColor(1, 1, 1) self.name:SetTextColor(1, 1, 1)