diff options
author | Teddy Wing | 2021-02-09 01:43:39 +0100 |
---|---|---|
committer | Teddy Wing | 2021-02-09 01:43:39 +0100 |
commit | ed11bce205dfd257a1cdb2ff3c3f96790a16e88b (patch) | |
tree | a1f6802dc929eb91493256a89a22a504fe25b563 | |
parent | 75223cd29aea2e5f35eba715bbd6008e5c8396a7 (diff) | |
download | extreload-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.lisp | 15 |
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") |