From bc6d83aaed081fb623dd1512025cdb20e208f52e Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Mon, 18 Apr 2022 14:00:36 +1000 Subject: [PATCH] merge watchers --- packages/app/src/runner/unifiedRunner.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/app/src/runner/unifiedRunner.ts b/packages/app/src/runner/unifiedRunner.ts index 42afdcfba34f..6af292459705 100644 --- a/packages/app/src/runner/unifiedRunner.ts +++ b/packages/app/src/runner/unifiedRunner.ts @@ -1,4 +1,4 @@ -import { Ref, onMounted, ref, watch, watchEffect, onBeforeUnmount, readonly } from 'vue' +import { Ref, onMounted, ref, watchEffect, onBeforeUnmount, readonly } from 'vue' import { getAutIframeModel, UnifiedRunnerAPI } from '../runner' import { useSpecStore } from '../store' import { useSelectorPlaygroundStore } from '../store/selector-playground-store' @@ -24,6 +24,14 @@ export function useUnifiedRunner (specs: Ref>) { const selectorPlaygroundStore = useSelectorPlaygroundStore() watchEffect(() => { + if (selectorPlaygroundStore.show) { + const autIframe = getAutIframeModel() + + autIframe.toggleSelectorPlayground(false) + selectorPlaygroundStore.setEnabled(false) + selectorPlaygroundStore.setShow(false) + } + const queryFile = getPathForPlatform(route.query.file as string) if (!queryFile) { @@ -41,16 +49,6 @@ export function useUnifiedRunner (specs: Ref>) { } }) - watch(() => getPathForPlatform(route.query.file as string), (newQueryFile) => { - if (selectorPlaygroundStore.show) { - const autIframe = getAutIframeModel() - - autIframe.toggleSelectorPlayground(false) - selectorPlaygroundStore.setEnabled(false) - selectorPlaygroundStore.setShow(false) - } - }, { flush: 'post' }) - return { initialized: readonly(initialized), }