From ed11bce205dfd257a1cdb2ff3c3f96790a16e88b Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 9 Feb 2021 01:43:39 +0100 Subject: 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. --- l/src/main.lisp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'l/src') 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") -- cgit v1.2.3