branch: elpa/hyperdrive
commit 0b2b10f165c914fe85f3074267bb3cbcf76cf227
Author: Joseph Turner <[email protected]>
Commit: Joseph Turner <[email protected]>
Add: (h/gateway-needs-upgrade-p) Predicate function
Also use predicate everywhere.
---
hyperdrive-lib.el | 9 ++++++---
hyperdrive-menu.el | 6 +-----
hyperdrive.el | 5 +----
3 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index d7ba802b53..809d062f29 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -198,14 +198,17 @@ make the request."
;; We pass only the `plz-error' struct to the ELSE* function.
(funcall else* (caddr err))))))
+(defun h/gateway-needs-upgrade-p ()
+ "Return non-nil if the gateway is responsive and needs upgraded."
+ (and (h//gateway-ready-p)
+ (not (equal h/gateway-version-expected (h//gateway-version)))))
+
(defun h/check-gateway-version ()
"Warn if gateway is at not at the expected version.
Unconditionally sets `h/gateway-version-checked-p' to t. The
caller should ensure that the gateway is running before calling
this function."
- (unless (equal h/gateway-version-expected
- ;; This will signal an error if the gateway is not responsive.
- (h//gateway-version))
+ (when (h/gateway-needs-upgrade-p)
(display-warning 'hyperdrive "Gateway version not expected; consider
installing the latest version with \\[hyperdrive-install]" :warning))
(setf h/gateway-version-checked-p t))
diff --git a/hyperdrive-menu.el b/hyperdrive-menu.el
index c47b09a539..b21afb56a1 100644
--- a/hyperdrive-menu.el
+++ b/hyperdrive-menu.el
@@ -216,11 +216,7 @@
'face 'transient-value)))
("G i" "Install" h/install
:description
- (lambda () (if (and (h//gateway-ready-p)
- (not (equal h/gateway-version-expected
- (h//gateway-version))))
- "Upgrade"
- "Install"))
+ (lambda () (if (h/gateway-needs-upgrade-p) "Upgrade" "Install"))
:transient t
:if-not (lambda () (or (h/gateway-installing-p) (h/gateway-installed-p))))
("G c" "Cancel install" h/cancel-install
diff --git a/hyperdrive.el b/hyperdrive.el
index 61dee6af4e..0f0305db9f 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -832,10 +832,7 @@ The return value of this function is the retrieval buffer."
["Gateway version" h/gateway-version
:help "Say hyper-gateway-ushin version"]
["Install gateway" h/install
- :label (cond ((and (h//gateway-ready-p)
- (not (equal h/gateway-version-expected
- (h//gateway-version))))
- "Upgrade gateway")
+ :label (cond ((h/gateway-needs-upgrade-p) "Upgrade gateway")
((h/gateway-installed-p) "Reinstall gateway")
(t "Install gateway"))
:visible (not (hyperdrive-gateway-installing-p))