From e539c35a5333e4bf8f147f14c850e7e3f9e9cab9 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 17 Aug 2013 18:50:20 +0200 Subject: [PATCH] Show a desktop notification for 5 seconds when someone replies to you. Close #971. --- src/Monitoring/Unread.coffee | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index da1419be5..c04274fbb 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -91,10 +91,24 @@ Unread = addPostQuotingYou: (post) -> return unless QR.db - for quotelink in post.nodes.quotelinks - if QR.db.get Get.postDataFromLink quotelink - Unread.postsQuotingYou.push post - return + for quotelink in post.nodes.quotelinks when QR.db.get Get.postDataFromLink quotelink + Unread.postsQuotingYou.push post + Unread.openNotification post + return + openNotification: (post) -> + return unless d.hidden + name = if Conf['Anonymize'] + 'Anonymous' + else + $('.nameBlock', post.nodes.info).textContent.trim() + notif = new Notification "#{name} replied to you.", + body: post.info.comment + notif.onclick = -> + Header.scrollToPost post.nodes.root + window.focus() + setTimeout -> + notif.close() + , 5 * $.SECOND onUpdate: (e) -> if e.detail[404]