Merge remote-tracking branch 'refs/remotes/origin/builder-store-conversions-pc' into builder-store-conversions-pc
This commit is contained in:
commit
f05de89eba
|
@ -151,6 +151,35 @@ export const initialise = (context: StoreContext) => {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function sortHasChanged(
|
||||||
|
newSort: {
|
||||||
|
column: string | null | undefined
|
||||||
|
order: SortOrder
|
||||||
|
},
|
||||||
|
existingSort?: {
|
||||||
|
field: string
|
||||||
|
order?: SortOrder
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
const newColumn = newSort.column ?? null
|
||||||
|
const existingColumn = existingSort?.field ?? null
|
||||||
|
if (newColumn !== existingColumn) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!newColumn) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const newOrder = newSort.order ?? null
|
||||||
|
const existingOrder = existingSort?.order ?? null
|
||||||
|
if (newOrder !== existingOrder) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// When sorting changes, ensure view definition is kept up to date
|
// When sorting changes, ensure view definition is kept up to date
|
||||||
unsubscribers.push(
|
unsubscribers.push(
|
||||||
sort.subscribe(async $sort => {
|
sort.subscribe(async $sort => {
|
||||||
|
@ -161,10 +190,7 @@ export const initialise = (context: StoreContext) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if nothing actually changed
|
// Skip if nothing actually changed
|
||||||
if (
|
if (!sortHasChanged($sort, $view.sort)) {
|
||||||
$sort?.column === $view.sort?.field &&
|
|
||||||
$sort?.order === $view.sort?.order
|
|
||||||
) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue