1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-01-15 21:18:41 +00:00
bramw_baserow/web-frontend/modules/dashboard/middleware/dashboardLoading.js
2024-12-25 08:40:24 +00:00

17 lines
552 B
JavaScript

/**
* Middleware that changes the dashboard loading state to true before the route
* changes.
*/
export default async function ({ route, from, store, app }) {
function parseIntOrNull(x) {
return x != null ? parseInt(x) : null
}
const toDashboardId = parseIntOrNull(route?.params?.dashboardId)
const fromDashboardId = parseIntOrNull(from?.params?.dashboardId)
const differentDashboardId = fromDashboardId !== toDashboardId
if (!from || differentDashboardId) {
await store.dispatch('dashboardApplication/setLoading', true)
}
}