Version log and (limited) notifications log (#10178)

This PR will close #1257 and #3418.
This commit is contained in:
zwim
2023-03-05 15:21:56 +01:00
committed by GitHub
parent 9f37863f00
commit efd2df6f05
4 changed files with 87 additions and 2 deletions

View File

@@ -48,6 +48,9 @@ local SOURCE_ALL = SOURCE_BOTTOM_MENU +
SOURCE_DISPATCHER +
SOURCE_OTHER
-- Maximum number of saved message text
local MAX_NB_PAST_MESSAGES = 20
local Notification = InputContainer:extend{
face = Font:getFace("x_smallinfofont"),
text = _("N/A"),
@@ -73,6 +76,7 @@ local Notification = InputContainer:extend{
SOURCE_SOME = SOURCE_SOME,
SOURCE_DEFAULT = SOURCE_DEFAULT,
SOURCE_ALL = SOURCE_ALL,
_past_messages = {}, -- a static class member to store the N last messages text
}
function Notification:init()
@@ -164,6 +168,10 @@ function Notification:notify(arg, source, refresh_after)
return false
end
function Notification:getPastMessages()
return self._past_messages
end
function Notification:_cleanShownStack()
-- Clean stack of shown notifications
if self._shown_idx then
@@ -204,10 +212,15 @@ function Notification:onShow()
if self.timeout then
UIManager:scheduleIn(self.timeout, function() UIManager:close(self) end)
end
if #self._past_messages >= MAX_NB_PAST_MESSAGES then
table.remove(self._past_messages)
end
table.insert(self._past_messages, 1, os.date("%X: ") .. self.text)
return true
end
function Notification:onTapClose()
if self.toast then return end -- should not happen
UIManager:close(self)