aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-02-09 01:43:39 +0100
committerTeddy Wing2021-02-09 01:43:39 +0100
commited11bce205dfd257a1cdb2ff3c3f96790a16e88b (patch)
treea1f6802dc929eb91493256a89a22a504fe25b563
parent75223cd29aea2e5f35eba715bbd6008e5c8396a7 (diff)
downloadextreload-ed11bce205dfd257a1cdb2ff3c3f96790a16e88b.tar.bz2
Use proper extension target count for active tab reload condition
Didn't reload the active tab in my test. But the previous way doesn't work when multiple copies of the same extension appear in the list of targets. Think we might want to always reload the current tab after reloading an extension because the extension targets could be in different Chrome profiles. Thus, you couldn't be sure which tab would be reloaded.
-rw-r--r--l/src/main.lisp15
1 files changed, 8 insertions, 7 deletions
diff --git a/l/src/main.lisp b/l/src/main.lisp
index ab765fb..c2177e5 100644
--- a/l/src/main.lisp
+++ b/l/src/main.lisp
@@ -3,6 +3,7 @@
(defvar *wg* (wait-group:make-wait-group))
(defvar *devtools-root-call-id* (make-instance 'call-id))
(defvar *reloaded-count* 0)
+(defvar *extension-targets-count* 0)
(defvar *last-session-id* "")
(opts:define-opts
@@ -54,10 +55,11 @@
(defun ws-on-message (message extension-ids reload-current-tab)
(let* ((response (jsown:parse message))
(targets (parse-get-targets-response response)))
- (if targets
- (reload-extensions
- (extension-targets targets)
- extension-ids))
+ (when targets
+ (let ((targets (extension-targets targets)))
+ (setf *extension-targets-count* (length targets))
+
+ (reload-extensions targets extension-ids)))
;; TODO: How to know it's the last message so we only reload the current tab once?
@@ -77,9 +79,8 @@
; (when (and (= (or (json-obj-get response "id") -1) 1)
(when (and
(= *reloaded-count*
- ;; TODO: Might not work because there could be multiple instances of a single extension ID I think
- ;; Yes, extension-ids could be less than *reloaded-count*. But we could use the count of extension-targets
- (length extension-ids))
+ ;; TODO: Probably want to reload on all extension reload calls
+ *extension-targets-count*)
(string= (json-obj-get
(json-obj-get response "result")