Wait until channels joined to store channels on first login

This commit is contained in:
Andrew Tomaka 2011-05-27 18:53:50 -04:00
parent d5c30070b8
commit 53ca5d2998

View file

@ -17,26 +17,10 @@ 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
for frame = 1,10 do self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','SetupChatSaver');
local frameChannels = { GetChatWindowChannels(frame) };
for i = 1,#frameChannels,2 do
local name,zone = frameChannels[i], frameChannels[i+1]
if(zone == 0) then
if(ChatSaverDB[name] == nil) then
ChatSaverDB[name] = {};
ChatSaverDB[name]['frames'] = {};
ChatSaverDB[name]['index'] = GetChannelName(name);
end
ChatSaverDB[name]['frames'][frame] = true;
end
end
end
end end
end end
@ -44,7 +28,7 @@ function core:SlashCommand()
core:RejoinChannels(); core:RejoinChannels();
end end
function core:RejoinChannels(event,message,...) function core:RejoinChannels(...)
local currentChannels = { GetChannelList() }; local currentChannels = { GetChannelList() };
for channel,information in pairs(ChatSaverDB) do for channel,information in pairs(ChatSaverDB) do
@ -58,6 +42,27 @@ function core:RejoinChannels(event,message,...)
end end
end end
self:UnregisterEvent('CHANNEL_UI_UPDATE');
end
function core:SetupChatSaver(...)
for frame = 1,10 do
local frameChannels = { GetChatWindowChannels(frame) };
for i = 1,#frameChannels,2 do
local name,zone = frameChannels[i], frameChannels[i+1]
if(zone == 0) then
if(ChatSaverDB[name] == nil) then
ChatSaverDB[name] = {};
ChatSaverDB[name]['frames'] = {};
ChatSaverDB[name]['index'] = GetChannelName(name);
end
ChatSaverDB[name]['frames'][frame] = true;
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)