From 969cfe8a08a7fe3f2503ad96638496545513d683 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 14 Jun 2017 04:16:58 +0900 Subject: [PATCH] [Client:Desktop] Show a notification when received a new message --- src/web/app/desktop/script.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/web/app/desktop/script.js b/src/web/app/desktop/script.js index f9f0896dd..2e8114794 100644 --- a/src/web/app/desktop/script.js +++ b/src/web/app/desktop/script.js @@ -74,4 +74,18 @@ function registerNotifications(stream) { }); setTimeout(n.close.bind(n), 6000); }); + + stream.on('unread_messaging_message', message => { + const n = new Notification(`${message.user.name}さんからメッセージ:`, { + body: message.text, // TODO: getMessagingMessageSummary(message), + icon: message.user.avatar_url + '?thumbnail&size=64' + }); + n.onclick = () => { + n.close(); + riot.mount(document.body.appendChild(document.createElement('mk-messaging-room-window')), { + user: message.user + }); + }; + setTimeout(n.close.bind(n), 7000); + }); }