Skip to content

Commit

Permalink
fix(route-view): outdated user preference
Browse files Browse the repository at this point in the history
Signed-off-by: schogges <[email protected]>
  • Loading branch information
schogges committed Jan 27, 2025
1 parent 557cba7 commit 478afd0
Showing 1 changed file with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,9 @@ const routeView = {
}
const routeParams = reactive<Params>({} as Params)
onBeforeRouteUpdate((to, from) => {
if(route.name === props.name) {
// Check for certain query search params to be stored as global user preference
for (const key of ['size', 'format']) {
const fromValue = from.query[key]
const toValue = to.query[key]
if(fromValue !== toValue) {
submit.value({ params: { [key]: toValue }, global: true })
}
}
}
})
onBeforeRouteUpdate(async () => {
// Make sure that the me resource is always up to date
const { value: refreshMe } = refresh
if(route.name === props.name) {
refreshMe()
}
onBeforeRouteUpdate(() => {
// Make sure to always update the me storage
refresh.value()
})
// when any URL params change, normalize/validate/default and reset our actual application params
Expand Down Expand Up @@ -271,6 +254,13 @@ const routeUpdate = (params: Partial<PrimitiveParams>): void => {
...newParams,
...params,
}
for (const key of ['size', 'format']) {
if(newParams[key]) {
submit.value({ params: { [key]: newParams[key] }, global: true })
}
}
routerPush(newParams)
}
Expand Down

0 comments on commit 478afd0

Please sign in to comment.