diff options
author | Teddy Wing | 2021-02-21 02:37:11 +0100 |
---|---|---|
committer | Teddy Wing | 2021-02-21 02:37:11 +0100 |
commit | 16c8122254725805be666cf065c590d54d66dfad (patch) | |
tree | c0bfec632feb3be312655d55ad7c9949350cf57a | |
parent | 8af40a7846f2aebba6eedc978f694d57e169af0e (diff) | |
download | extreload-16c8122254725805be666cf065c590d54d66dfad.tar.bz2 |
main: Replace hard-coded call IDs with a new counter
Looks like this was the answer to the problem of the active tab not
reloading consistently.
Previously, if I had two instances of an extension loaded in two
separate Chrome profiles, the following could happen:
1. Neither profile's active tab reloaded
2. Only one profile's active tab reloaded
3. Both profiles' active tabs reloaded
With this change, both profiles' active tabs reload correctly and
consistently.
-rw-r--r-- | l/src/main.lisp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/l/src/main.lisp b/l/src/main.lisp index 9acff14..6f6ed6b 100644 --- a/l/src/main.lisp +++ b/l/src/main.lisp @@ -2,6 +2,7 @@ (defvar *wg* (wait-group:make-wait-group)) (defvar *devtools-root-call-id* (make-instance 'call-id)) +(defvar *devtools-secondary-call-id* (make-instance 'call-id)) (defvar *reloaded-count* 0) (defvar *extension-targets-count* 0) (defvar *last-session-id* "") @@ -109,8 +110,12 @@ ;; Use call ID "1" as this is the first message sent to the attached target. (format t "reloading EXTENSION~%") (setf *last-session-id* session-id) - (websocket-send *client* - (runtime-evaluate-msg 1 session-id "chrome.runtime.reload()")) + (websocket-send + *client* + (runtime-evaluate-msg + (next-call-id *devtools-secondary-call-id*) + session-id + "chrome.runtime.reload()")) (incf *reloaded-count*)) @@ -120,7 +125,10 @@ (format t "reloading NOW~%") (websocket-send *client* - (runtime-evaluate-msg 2 session-id "chrome.tabs.reload()"))) + (runtime-evaluate-msg + (next-call-id *devtools-secondary-call-id*) + session-id + "chrome.tabs.reload()"))) (defun extension-targets (targets) (labels ((extensionp (target) |