From 7892099ef038f67fee757aff77be38c5b1be30fb Mon Sep 17 00:00:00 2001 From: atomaka Date: Thu, 2 Jun 2011 04:53:40 -0400 Subject: [PATCH] Sort saved channels by index before joining --- ChatSaver.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ChatSaver.lua b/ChatSaver.lua index 958fa62..56afa42 100644 --- a/ChatSaver.lua +++ b/ChatSaver.lua @@ -33,7 +33,14 @@ function core:RejoinChannels(...) currentChannels[select(i,GetChannelList())] = true end + local sortedChannels = {}; for channel,_ in pairs(ChatSaverDB) do + table.insert(sortedChannels,channel); + end + + table.sort(sortedChannels,function(a,b) return ChatSaverDB[a].index < ChatSaverDB[b].index end); + + for _,channel in pairs(sortedChannels) do if(currentChannels[channel] == nil) then JoinPermanentChannel(channel); -- does not place in chat frame properly for index,_ in pairs(ChatSaverDB[channel].frames) do @@ -85,7 +92,7 @@ function core:LeaveChannel(msg) local number = gsub(msg, "%s*([^%s]+).*", "%1"); local _,name = GetChannelName(number); - ChatSaverDB[name] = nil; + --ChatSaverDB[name] = nil; end function core:ToggleChatChannel(checked,channel)