Use CHAT_MSG_CHANNEL_NOTICE instead of hooking join and leave slash functions for stored channels
This commit is contained in:
parent
0b51f257ed
commit
aa65c554a3
1 changed files with 27 additions and 26 deletions
|
@ -13,14 +13,10 @@ function core:OnInitialize()
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:OnEnable()
|
function core:OnEnable()
|
||||||
self:RawHook(SlashCmdList,'JOIN','JoinChannel',true);
|
|
||||||
self:RawHook(SlashCmdList,'LEAVE','LeaveChannel',true);
|
|
||||||
self:Hook('ToggleChatChannel','ToggleChatChannel',true);
|
self:Hook('ToggleChatChannel','ToggleChatChannel',true);
|
||||||
|
|
||||||
self:RegisterEvent('CHANNEL_UI_UPDATE','RejoinChannels');
|
self:RegisterEvent('CHANNEL_UI_UPDATE','RejoinChannels');
|
||||||
if(core.firstrun) then
|
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','ProcessChannelChanges');
|
||||||
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','SetupChatSaver');
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:SlashCommand()
|
function core:SlashCommand()
|
||||||
|
@ -28,6 +24,10 @@ function core:SlashCommand()
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:RejoinChannels(...)
|
function core:RejoinChannels(...)
|
||||||
|
if(core.firstrun) then
|
||||||
|
core:SetupChatSaver();
|
||||||
|
end
|
||||||
|
|
||||||
local currentChannels = {};
|
local currentChannels = {};
|
||||||
for i = 1,select('#',GetChannelList()) do
|
for i = 1,select('#',GetChannelList()) do
|
||||||
currentChannels[select(i,GetChannelList())] = true
|
currentChannels[select(i,GetChannelList())] = true
|
||||||
|
@ -45,7 +45,7 @@ function core:RejoinChannels(...)
|
||||||
self:UnregisterEvent('CHANNEL_UI_UPDATE');
|
self:UnregisterEvent('CHANNEL_UI_UPDATE');
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:SetupChatSaver(...)
|
function core:SetupChatSaver()
|
||||||
for frame = 1,NUM_CHAT_WINDOWS do
|
for frame = 1,NUM_CHAT_WINDOWS do
|
||||||
local chatWindowChannels = { GetChatWindowChannels(frame) };
|
local chatWindowChannels = { GetChatWindowChannels(frame) };
|
||||||
for i = 1,#chatWindowChannels,2 do
|
for i = 1,#chatWindowChannels,2 do
|
||||||
|
@ -62,30 +62,31 @@ function core:SetupChatSaver(...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:UnregisterEvent('CHAT_MSG_CHANNEL_NOTICE');
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:JoinChannel(msg)
|
function core:ProcessChannelChanges(_,message,_,_,_,_,_,_,index,name,...)
|
||||||
self.hooks[SlashCmdList].JOIN(msg);
|
if(message == 'YOU_JOINED') then
|
||||||
|
local zone = 1;
|
||||||
|
for frame = 1,NUM_CHAT_WINDOWS do
|
||||||
|
local chatWindowChannels = { GetChatWindowChannels(frame) };
|
||||||
|
for i = 1,#chatWindowChannels,2 do
|
||||||
|
if(chatWindowChannels[i] == name) then
|
||||||
|
print(chatWindowChannels[i],chatWindowChannels[i + 1]);
|
||||||
|
zone = chatWindowChannels[i + 1];
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local name = gsub(msg, "%s*([^%s]+).*", "%1");
|
if(zone == 0) then
|
||||||
|
|
||||||
if(strlen(name) > 0 and string.match(name,"%a+")) then
|
|
||||||
ChatSaverDB[name] = {};
|
ChatSaverDB[name] = {};
|
||||||
ChatSaverDB[name]['frames'] = {};
|
ChatSaverDB[name]['frames'] = {};
|
||||||
ChatSaverDB[name]['index'] = GetChannelName(name);
|
ChatSaverDB[name]['index'] = index;
|
||||||
ChatSaverDB[name]['frames'][DEFAULT_CHAT_FRAME:GetID()] = true;
|
ChatSaverDB[name]['frames'][DEFAULT_CHAT_FRAME:GetID()] = true;
|
||||||
end
|
end
|
||||||
end
|
elseif(message == 'YOU_LEFT') then
|
||||||
|
|
||||||
function core:LeaveChannel(msg)
|
|
||||||
self.hooks[SlashCmdList].LEAVE(msg);
|
|
||||||
|
|
||||||
local number = gsub(msg, "%s*([^%s]+).*", "%1");
|
|
||||||
local _,name = GetChannelName(number);
|
|
||||||
|
|
||||||
ChatSaverDB[name] = nil;
|
ChatSaverDB[name] = nil;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:ToggleChatChannel(checked,channel)
|
function core:ToggleChatChannel(checked,channel)
|
||||||
|
|
Loading…
Reference in a new issue