From 45ca1825b6a8f88c75dc3b493e621a6435ae657c Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Mon, 2 Oct 2023 17:40:28 +0200 Subject: [PATCH] forge-pull-notification: With a prefix argument pull all --- lisp/forge-commands.el | 15 ++++++++++----- lisp/forge-github.el | 5 +++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lisp/forge-commands.el b/lisp/forge-commands.el index d772677b..4ef884c6 100644 --- a/lisp/forge-commands.el +++ b/lisp/forge-commands.el @@ -219,16 +219,21 @@ If pulling is too slow, then also consider setting the Git variable (magit-git-fetch (oref repo remote) (magit-fetch-arguments))))) ;;;###autoload -(defun forge-pull-notifications () - "Fetch notifications for all repositories from the current forge." - (interactive) +(defun forge-pull-notifications (all) + "Fetch notifications for all repositories from the current forge. + +With a prefix argument fetch all notifications, not just those +that Github considers as updates since the last pull. This is +useful after you have marked a notification as unread, using the +web interface, because Github doesn't consider that an update." + (interactive "P") (if-let ((repo (forge-get-repository 'maybe))) (let ((class (eieio-object-class repo))) (if (eq class 'forge-github-repository) - (forge--pull-notifications class (oref repo githost)) + (forge--pull-notifications class (oref repo githost) nil all) (user-error "Fetching notifications not supported for forge %S" (oref repo forge)))) - (forge--pull-notifications 'forge-github-repository "github.com"))) + (forge--pull-notifications 'forge-github-repository "github.com" nil all))) ;;;###autoload (defun forge-pull-topic (topic) diff --git a/lisp/forge-github.el b/lisp/forge-github.el index 745d144a..c8116c09 100644 --- a/lisp/forge-github.el +++ b/lisp/forge-github.el @@ -329,7 +329,7 @@ ;;;; Notifications (cl-defmethod forge--pull-notifications - ((_class (subclass forge-github-repository)) githost &optional callback) + ((_class (subclass forge-github-repository)) githost &optional callback all) ;; The GraphQL API doesn't support notifications and also likes to ;; timeout for handcrafted requests, forcing us to perform a major ;; rain dance. @@ -348,7 +348,8 @@ (with-demoted-errors "forge--pull-notifications: %S" (forge--ghub-massage-notification data githost))) (forge--ghub-get nil "/notifications" - (if-let ((since (forge--ghub-notifications-until))) + (if-let ((since (and (not all) + (forge--ghub-notifications-until)))) `((all . t) (since . ,since)) '((all . t))) :host apihost :unpaginate t)))