From 0a7a42fb6560e525f2ebdca596db6eaced665aa6 Mon Sep 17 00:00:00 2001 From: Dejan Simic Date: Sat, 27 Apr 2024 08:17:25 +0200 Subject: [PATCH 1/2] Implement lock-on feature --- extension/src/App.vue | 17 +++++++++++------ extension/src/components/Toolbar.vue | 4 ++++ extension/src/stores/events.js | 7 +++++-- extension/src/stores/settings.js | 8 +++++++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/extension/src/App.vue b/extension/src/App.vue index ee7b41d..de4151a 100644 --- a/extension/src/App.vue +++ b/extension/src/App.vue @@ -6,16 +6,18 @@ import Requests from './components/Requests.vue' import { fakeEvents } from './fixtures/fakeEvents' import { useEventsStore } from './stores/events'; +import { useSettingsStore } from './stores/settings'; import { onMounted, onUnmounted, nextTick } from 'vue' -const store = useEventsStore() +const eventsStore = useEventsStore(); +const settingsStore = useSettingsStore(); -onUnmounted(() => store.clear()) +onUnmounted(() => eventsStore.clear()); onMounted(() => { if (typeof chrome.devtools == 'undefined') { - console.log("STANDALONE mode... mocking requests") - fakeEvents.forEach((data) => store.pushEvents(data.request_id, data.events)); + console.log("STANDALONE mode... mocking requests"); + fakeEvents.forEach((data) => eventsStore.pushEvents(data.request_id, data.events)); } else { chrome.devtools.network.onRequestFinished.addListener(function(request) { var headers = request.response.headers; @@ -28,9 +30,12 @@ onMounted(() => { url.search = ""; console.log(url) chrome.runtime.sendMessage({action:'getJSON',url:url}, (data) => { - store.pushEvents(requestId, data); + const autoReselect = !settingsStore.lockOn; + eventsStore.pushEvents(requestId, data, autoReselect); nextTick(() => { - document.querySelectorAll('[data-pc-section="wrapper"]')[0].scrollTop = 1000000 + if (autoReselect) { + document.querySelectorAll('[data-pc-section="wrapper"]')[0].scrollTop = 1000000; + } }) }); }; diff --git a/extension/src/components/Toolbar.vue b/extension/src/components/Toolbar.vue index f948934..f3f55ce 100644 --- a/extension/src/components/Toolbar.vue +++ b/extension/src/components/Toolbar.vue @@ -1,6 +1,7 @@