mirror of https://github.com/Hilbis/Hilbish
feat: show amount of unread notifs in default config, add unreadCount function
parent
cc25effe04
commit
f02d4784fb
|
@ -24,14 +24,9 @@ bait.catch('hilbish.vimMode', function(mode)
|
|||
end
|
||||
end)
|
||||
|
||||
--[[
|
||||
hilbish.timeout(function()
|
||||
hilbish.messages.send {title = 'greetings!', text = 'hello world :D'}
|
||||
end, 2000)
|
||||
]]--
|
||||
|
||||
bait.catch('hilbish.notification', function()
|
||||
hilbish.prompt(lunacolors.blue('• 1 new notification'), 'right')
|
||||
local notif = string.format('• %s unread notification%s', hilbish.messages.unreadCount(), hilbish.messages.unreadCount() > 1 and 's' or '')
|
||||
hilbish.prompt(lunacolors.blue(notif), 'right')
|
||||
|
||||
hilbish.timeout(function()
|
||||
hilbish.prompt('', 'right')
|
||||
|
|
|
@ -4,6 +4,7 @@ local lunacolors = require 'lunacolors'
|
|||
|
||||
local M = {}
|
||||
local counter = 0
|
||||
local unread = 0
|
||||
M._messages = {}
|
||||
M.icons = {
|
||||
INFO = '',
|
||||
|
@ -35,6 +36,7 @@ function hilbish.messages.send(message)
|
|||
expect(message, 'text')
|
||||
expect(message, 'title')
|
||||
counter = counter + 1
|
||||
unread = unread + 1
|
||||
message.index = counter
|
||||
message.read = false
|
||||
|
||||
|
@ -46,6 +48,7 @@ function hilbish.messages.read(idx)
|
|||
local msg = M._messages[idx]
|
||||
if msg then
|
||||
M._messages[idx].read = true
|
||||
unread = unread - 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -55,6 +58,10 @@ function hilbish.messages.readAll(idx)
|
|||
end
|
||||
end
|
||||
|
||||
function hilbish.messages.unreadCount()
|
||||
return unread
|
||||
end
|
||||
|
||||
function hilbish.messages.delete(idx)
|
||||
local msg = M._messages[idx]
|
||||
if not msg then
|
||||
|
|
Loading…
Reference in New Issue