From 6454090cfd85b2d5a61100ce3c52671ad670e845 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 21 Aug 2013 16:24:48 +0200 Subject: [PATCH] Warn with a desktop notification when we're running low on cached captchas. Close #1253. Also increase delay to close the notifications from 5 to 7 seconds. #1252 --- CHANGELOG.md | 2 ++ src/Monitoring/Unread.coffee | 2 +- src/Posting/QR.coffee | 13 +++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a9b09c5d..973ad4b42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ - **New feature**: `Linkify` and `Clean Links`, enabled by default - Linkify will turn text URLs into working links. - Clean Links will get rid of spoiler and code tags in linkified URLs used to bypass spam blocks. +- New desktop notification: + - The QR will now warn you when you are running low on cached captchas while auto-posting. ## 3.9.0 - *2013-08-18* diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 9c31a2dd2..fdcbc7f16 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -106,7 +106,7 @@ Unread = window.focus() setTimeout -> notif.close() - , 5 * $.SECOND + , 7 * $.SECOND onUpdate: (e) -> if e.detail[404] diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index f3526edf1..5a5d62219 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -125,7 +125,7 @@ QR = setTimeout -> notif.onclose = null notif.close() - , 5 * $.SECOND + , 7 * $.SECOND <% } %> notifications: [] cleanNotifications: -> @@ -1101,7 +1101,16 @@ QR = } # Enable auto-posting if we have stuff to post, disable it otherwise. - QR.cooldown.auto = QR.posts.length > 1 and isReply + postsCount = QR.posts.length + QR.cooldown.auto = postsCount > 1 and isReply + if QR.cooldown.auto and QR.captcha.isEnabled and (captchasCount = QR.captcha.captchas.length) < 3 and captchasCount < postsCount + notif = new Notification 'Quick reply warning', + body: "You are running low on cached captchas. Cache count: #{captchasCount}." + icon: Favicon.logo + notif.onclick = -> window.focus() + setTimeout -> + notif.close() + , 7 * $.SECOND unless Conf['Persistent QR'] or QR.cooldown.auto QR.close()