From e317ac422c43b2ee72df880fe95dad80d32a3d61 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Wed, 30 May 2018 05:12:44 +0300 Subject: [PATCH] Auto-truncating of new messages header --- Applications/IRC/Main.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Applications/IRC/Main.lua b/Applications/IRC/Main.lua index b4903806..a2bea05b 100644 --- a/Applications/IRC/Main.lua +++ b/Applications/IRC/Main.lua @@ -803,15 +803,22 @@ window.close = function(...) overrideWindowClose(...) for key in pairs(history) do - for i = 1, #history[key] do + local i = 1 + while i <= #history[key] do if history[key][i].text then history[key][i].text = history[key][i].text:gsub("\\", "\\\\") history[key][i].text = history[key][i].text:gsub("\"", "\\\"") history[key][i].text = history[key][i].text:gsub("\'", "\\\'") end + + if history[key][i].newMessages then + table.remove(history[key], i) + else + i = i + 1 + end end - if #history[key] > 0 and not history[key][#history[key]].newMessages then + if #history[key] > 0 then table.insert(history[key], {newMessages = true}) end end