branch: elpa/mastodon
commit 4657bb80d8b3ad14dd74139bdaae8698192302e4
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>

    don't try to update notifs buffer, if no alert, just message. #249.
---
 lisp/mastodon-notifications.el | 36 ++++++++++++++++++++++--------------
 lisp/mastodon.el               |  3 +--
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index c2810d776d..8ea7397e17 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -34,7 +34,6 @@
 (require 'cl-lib)
 (require 'mastodon-widget)
 (require 'map)
-(require 'alert)
 
 (autoload 'mastodon-http--api "mastodon-http")
 (autoload 'mastodon-http--get-params-async-json "mastodon-http")
@@ -1044,12 +1043,14 @@ When FORCE, skip all checks and show an alert (for 
debugging)."
     (when (or force
               (and (> count 0)
                    (not mastodon-notifications-notify-shown)))
-      (alert (format "New notifications: <b>%s</b>" count)
-             :title "mastodon.el"
-             ;; adding an alert.el rule as per above doesn't always work
-             ;; if a non-mastodon.el buffer is active (despite the 'buried
-             ;; status setting), so let's just give it a masto buffer:
-             :buffer (car (mastodon-live-buffers)))
+      (if (not (require 'alert :noerror))
+          (message "mastodon.el: new notifications %s" count)
+        (alert (format "New notifications: <b>%s</b>" count)
+               :title "mastodon.el"
+               ;; adding an alert.el rule as per above doesn't always work
+               ;; if a non-mastodon.el buffer is active (despite the 'buried
+               ;; status setting), so let's just give it a masto buffer:
+               :buffer (car (mastodon-live-buffers))))
       (unless force
         ;; we nil this in `mastodon-notifications-get':
         (setq mastodon-notifications-notify-shown t)))))
@@ -1108,15 +1109,22 @@ Callback is `mastodon-notifications--update-check-cb'."
   "Callback functions for handling unread notifs count response RESP."
   (let ((count (alist-get 'count resp)))
     (when (> count 0)
-      (if (not (mastodon-tl--buffer-type-eq 'notifications))
+      ;; (message "%s" (current-buffer)) ;; => *mastodon-home* / *messages*
+
+      ;; FIXME: unsure how to check if notifications buffer is active
+      ;; here, as (current-buffer) returns different things if this is
+      ;; triggered with notifs buffer active! so let's skip it for now,
+      ;; and only ever notify, not update.
+
+      ;; (if ;;(not (mastodon-tl--buffer-type-eq 'notifications))
+          ;; (not mastodon-notifications-update-when-unread)
           (mastodon-notifications-notify count)
-        ;; (message "New mastodon.el notificatigon(s): %s" count))
         ;; run updates if in notifs buffer:
-        (message "Updating mastodon.el notifications...")
-        (undo-boundary)
-        (mastodon-tl-update)
-        (undo-boundary)
-        (message "Updating mastodon.el notifications... Done.")))
+        ;; (message "Updating mastodon.el notifications...")
+        ;; (undo-boundary)
+        ;; (mastodon-tl-update)
+        ;; (undo-boundary)
+        ;; (message "Updating mastodon.el notifications... Done.")))
     ;; cancel and set new timer:
     (mastodon-notifications-cancel-timer)
     (mastodon-notifications--update-with-timer)))
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 652cedd9d5..73b8a8642f 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -621,8 +621,7 @@ Calls `mastodon-tl--get-buffer-type', which see."
               (append thing-at-point-provider-alist
                       '((url . mastodon--url-at-point))))
   ;; notifs timer
-  (when (and mastodon-notifications-alerts
-             (require 'alert nil :noerror))
+  (when mastodon-notifications-alerts
     (mastodon-notifications--update-with-timer)))
 
 ;;;###autoload

Reply via email to