naighty: Fix to use the same object using `naugthy.notify{replace_id}`

Fix #2678
This commit is contained in:
Emmanuel Lepage Vallee 2019-03-02 12:53:25 -05:00
parent 9954e43521
commit 4930978424
2 changed files with 26 additions and 1 deletions

View File

@ -553,6 +553,17 @@ function naughty.notify(args)
--TODO v6 remove this hack
nnotif = nnotif or require("naughty.notification")
-- The existing notification object, if any.
local n = args and args.replaces_id and
naughty.get_by_id(args.replaces_id) or nil
-- It was possible to update the notification content using `replaces_id`.
-- This is a concept that come from the dbus API and leaked into the public
-- API. It has all kind of issues and brokenness, but it being used.
if n then
return gtable.crush(n, args)
end
return nnotif(args)
end

View File

@ -789,7 +789,21 @@ table.insert(steps, function()
naughty.suspended = false
-- The old notify function and "text" instead of "message"
naughty.notify { text = "foo" }
n = naughty.notify { text = "foo" }
assert(n.message == "foo")
assert(n.text == "foo")
-- Calling `naughty.notify` with replace_id.
n2 = naughty.notify {
replaces_id = n.id,
message = "bar",
title = "foo",
}
assert(n == n2 )
assert(n.message == "bar")
assert(n.text == "bar")
assert(n.title == "foo")
-- Finish by testing disconnect_signal
naughty.disconnect_signal("destroyed", destroyed_callback)