Skip to content

Commit

Permalink
forge-pull-notification: With a prefix argument pull all
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Oct 3, 2023
1 parent ad5c69d commit 45ca182
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 10 additions & 5 deletions lisp/forge-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lisp/forge-github.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)))
Expand Down

0 comments on commit 45ca182

Please sign in to comment.