Wait until channels joined to store channels on first login
This commit is contained in:
parent
d5c30070b8
commit
53ca5d2998
1 changed files with 26 additions and 21 deletions
|
@ -17,10 +17,35 @@ function core:OnInitialize()
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:OnEnable()
|
function core:OnEnable()
|
||||||
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','RejoinChannels');
|
self:RegisterEvent('CHANNEL_UI_UPDATE','RejoinChannels');
|
||||||
|
|
||||||
--store curret channels if this is our first run
|
|
||||||
if(core.firstrun) then
|
if(core.firstrun) then
|
||||||
|
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','SetupChatSaver');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:SlashCommand()
|
||||||
|
core:RejoinChannels();
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:RejoinChannels(...)
|
||||||
|
local currentChannels = { GetChannelList() };
|
||||||
|
|
||||||
|
for channel,information in pairs(ChatSaverDB) do
|
||||||
|
if(currentChannels[channel] == nil) then
|
||||||
|
JoinPermanentChannel(channel);
|
||||||
|
for index,shown in pairs(ChatSaverDB[channel].frames) do
|
||||||
|
if(shown) then
|
||||||
|
ChatFrame_AddChannel(_G['ChatFrame'..index],channel);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self:UnregisterEvent('CHANNEL_UI_UPDATE');
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:SetupChatSaver(...)
|
||||||
for frame = 1,10 do
|
for frame = 1,10 do
|
||||||
local frameChannels = { GetChatWindowChannels(frame) };
|
local frameChannels = { GetChatWindowChannels(frame) };
|
||||||
for i = 1,#frameChannels,2 do
|
for i = 1,#frameChannels,2 do
|
||||||
|
@ -37,26 +62,6 @@ function core:OnEnable()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function core:SlashCommand()
|
|
||||||
core:RejoinChannels();
|
|
||||||
end
|
|
||||||
|
|
||||||
function core:RejoinChannels(event,message,...)
|
|
||||||
local currentChannels = { GetChannelList() };
|
|
||||||
|
|
||||||
for channel,information in pairs(ChatSaverDB) do
|
|
||||||
if(currentChannels[channel] == nil) then
|
|
||||||
JoinPermanentChannel(channel);
|
|
||||||
for index,shown in pairs(ChatSaverDB[channel].frames) do
|
|
||||||
if(shown) then
|
|
||||||
ChatFrame_AddChannel(_G['ChatFrame'..index],channel);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:UnregisterEvent('CHAT_MSG_CHANNEL_NOTICE');
|
self:UnregisterEvent('CHAT_MSG_CHANNEL_NOTICE');
|
||||||
end
|
end
|
||||||
|
@ -80,7 +85,7 @@ function core:LeaveChannel(msg)
|
||||||
local number = gsub(msg, "%s*([^%s]+).*", "%1");
|
local number = gsub(msg, "%s*([^%s]+).*", "%1");
|
||||||
local _,name = GetChannelName(number);
|
local _,name = GetChannelName(number);
|
||||||
|
|
||||||
--ChatSaverDB[name] = nil;
|
ChatSaverDB[name] = nil;
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:ToggleChatChannel(checked,channel)
|
function core:ToggleChatChannel(checked,channel)
|
||||||
|
|
Loading…
Reference in a new issue