fix: circular watcher dependencies on invite.vue causing infinite loop (#2871)

This commit is contained in:
Akash K
2022-12-07 02:29:38 +05:30
committed by GitHub
parent b04b12c7a0
commit e7e8c397ef

View File

@@ -9,6 +9,7 @@ import {
watchEffect, watchEffect,
WatchStopHandle, WatchStopHandle,
watchSyncEffect, watchSyncEffect,
watch,
} from "vue" } from "vue"
import { import {
client, client,
@@ -60,9 +61,6 @@ export const useGQLQuery = <DocType, DocVarType, DocErrorType extends string>(
const source: Ref<Source<OperationResult> | undefined> = ref() const source: Ref<Source<OperationResult> | undefined> = ref()
// A ref used to force re-execution of the query
const updateTicker: Ref<boolean> = ref(true)
// Toggles between true and false to cause the polling operation to tick // Toggles between true and false to cause the polling operation to tick
const pollerTick: Ref<boolean> = ref(true) const pollerTick: Ref<boolean> = ref(true)
@@ -96,24 +94,23 @@ export const useGQLQuery = <DocType, DocVarType, DocErrorType extends string>(
) )
) )
const rerunQuery = () => {
source.value = !isPaused.value
? client.value.executeQuery<DocType, DocVarType>(request.value, {
requestPolicy: "network-only",
})
: undefined
}
stops.push( stops.push(
watchEffect( watch(
pollerTick,
() => { () => {
// Just listen to the polling ticks rerunQuery()
// eslint-disable-next-line no-unused-expressions
pollerTick.value
// Just keep track of update ticking, but don't do anything
// eslint-disable-next-line no-unused-expressions
updateTicker.value
source.value = !isPaused.value
? client.value.executeQuery<DocType, DocVarType>(request.value, {
requestPolicy: "network-only",
})
: undefined
}, },
{ flush: "pre" } {
flush: "pre",
}
) )
) )
@@ -192,7 +189,7 @@ export const useGQLQuery = <DocType, DocVarType, DocErrorType extends string>(
} }
isPaused.value = false isPaused.value = false
updateTicker.value = !updateTicker.value rerunQuery()
} }
const pause = () => { const pause = () => {