Skip to content

Commit

Permalink
refactor: extract query replacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Djaler committed May 27, 2022
1 parent f53df1b commit 7ac6957
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/queue-query-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@ export function queueQueryUpdate(
[key]: newValue,
});

return router.replace({
query: newQuery,
})
.then(newRoute => newRoute.query)
.catch(() => previousQuery);
return updateQuery(router, previousQuery, newQuery);
});

void queryReplaceQueue.run(currentQuery);
}

async function updateQuery(router: VueRouter, previousQuery: RouteQuery, query: RouteQuery) {
try {
await router.replace({
query,
});
return query;
} catch (e) {
return previousQuery;
}
}

0 comments on commit 7ac6957

Please sign in to comment.