Skip to content

Commit

Permalink
Use Magit's refresh cache for the duration of a menu refresh
Browse files Browse the repository at this point in the history
We could additionally call `forge-current-{topic,issue,pullreq}' up
front and `cl-letf' functions that return these predetermined values,
but that is riskier and would preform unnecessary work for menus whose
suffixes don't actually call any of these functions, so we'll leave that
for another day.

Closes #712.
  • Loading branch information
tarsius committed Oct 18, 2024
1 parent c819271 commit 9f2efc3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lisp/forge-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Takes the pull-request as only argument and must return a directory."
"Dispatch a forge command."
:transient-non-suffix #'transient--do-call
:refresh-suffixes t
:environment #'forge--menu-environment
:column-widths forge--topic-menus-column-widths
[forge--topic-menus-group
["Fetch"
Expand Down Expand Up @@ -116,6 +117,7 @@ Takes the pull-request as only argument and must return a directory."
"Configure current repository and global settings."
:transient-non-suffix #'transient--do-call
:refresh-suffixes t
:environment #'forge--menu-environment
:column-widths forge--topic-menus-column-widths
[forge--topic-menus-group
["Configure"
Expand Down
1 change: 1 addition & 0 deletions lisp/forge-notify.el
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ signal an error."
:transient-non-suffix #'transient--do-call
:transient-switch-frame nil
:refresh-suffixes t
:environment #'forge--menu-environment
:column-widths forge--topic-menus-column-widths
[:hide always ("q" forge-menu-quit-list)]
[forge--topic-menus-group
Expand Down
1 change: 1 addition & 0 deletions lisp/forge-repos.el
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Must be set before `forge-list' is loaded.")
:transient-non-suffix #'transient--do-call
:transient-switch-frame nil
:refresh-suffixes t
:environment #'forge--menu-environment
:column-widths forge--topic-menus-column-widths
[:hide always ("q" forge-menu-quit-list)]
[forge--topic-menus-group
Expand Down
7 changes: 7 additions & 0 deletions lisp/forge-topic.el
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,7 @@ This mode itself is never used directly."
:transient-non-suffix #'transient--do-call
:transient-switch-frame nil
:refresh-suffixes t
:environment #'forge--menu-environment
:column-widths forge--topic-menus-column-widths
[:hide always ("q" forge-menu-quit-list)]
[forge--topic-menus-group
Expand Down Expand Up @@ -1348,13 +1349,19 @@ This mode itself is never used directly."
;;;###autoload(autoload 'forge-topic-state-menu "forge-topic" nil t)
(transient-define-prefix forge-topic-state-menu ()
"Set state of the current topic."
:environment #'forge--menu-environment
[forge--topic-set-state-group])

;;;###autoload(autoload 'forge-topic-status-menu "forge-topic" nil t)
(transient-define-prefix forge-topic-status-menu ()
"Set status of the current topic."
:environment #'forge--menu-environment
[forge--topic-set-status-group])

(defun forge--menu-environment (fn)
(let ((magit--refresh-cache (list (cons 0 0))))
(funcall fn)))

;;;; State

(defclass forge--topic-set-state-command (transient-suffix)
Expand Down
1 change: 1 addition & 0 deletions lisp/forge-topics.el
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ Must be set before `forge-topics' is loaded.")
:transient-non-suffix #'transient--do-call
:transient-switch-frame nil
:refresh-suffixes t
:environment #'forge--menu-environment
:column-widths forge--topic-menus-column-widths
[:hide always ("q" forge-menu-quit-list)]
[forge--topic-menus-group
Expand Down

0 comments on commit 9f2efc3

Please sign in to comment.