From 3b5eb514c53bc1ca7428abfd9340426d2c836343 Mon Sep 17 00:00:00 2001 From: Craig Harshbarger Date: Wed, 15 Nov 2023 12:20:48 -0600 Subject: [PATCH 1/2] Apply operations and then clear them --- src/useRouteQuery/useRouteQuery.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/useRouteQuery/useRouteQuery.ts b/src/useRouteQuery/useRouteQuery.ts index 3c376c0d..634927fe 100644 --- a/src/useRouteQuery/useRouteQuery.ts +++ b/src/useRouteQuery/useRouteQuery.ts @@ -24,10 +24,12 @@ function factory(): () => UseRouteQuery { let interval: ReturnType const update = async (): Promise => { - const operationsToApply = operations.splice(0) + const operationsToApply = operations.slice(0) const query = applyQueryOperations(route.query, operationsToApply) await router.push({ query }) + + operations.splice(0) } watch(operations, () => { From 81cf0108e4d308b2911e21c5c2e4b48682ef6542 Mon Sep 17 00:00:00 2001 From: Craig Harshbarger Date: Wed, 15 Nov 2023 12:31:02 -0600 Subject: [PATCH 2/2] No need to slice off operations --- src/useRouteQuery/useRouteQuery.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/useRouteQuery/useRouteQuery.ts b/src/useRouteQuery/useRouteQuery.ts index 634927fe..4924b78d 100644 --- a/src/useRouteQuery/useRouteQuery.ts +++ b/src/useRouteQuery/useRouteQuery.ts @@ -24,8 +24,7 @@ function factory(): () => UseRouteQuery { let interval: ReturnType const update = async (): Promise => { - const operationsToApply = operations.slice(0) - const query = applyQueryOperations(route.query, operationsToApply) + const query = applyQueryOperations(route.query, operations) await router.push({ query })