feat: decouple views from projects #2217

Merged
konrad merged 97 commits from feature/decouple-views-from-projects into main 2024-03-19 19:16:14 +00:00
1 changed files with 18 additions and 9 deletions
Showing only changes of commit 974c9cdd21 - Show all commits

View File

@ -25,25 +25,34 @@ const currentView = computed(() => {
return project?.views.find(v => v.id === viewId)
})
watch(
() => viewId,
() => {
if (viewId === 0) {
// Ideally, we would do that in the router redirect, but we the projects (and therefore, the views)
// are not always loaded then.
const viewId = projectStore.projects[projectId].views[0].id
function redirectToFirstViewIfNecessary() {
if (viewId === 0) {
// Ideally, we would do that in the router redirect, but the projects (and therefore, the views)
// are not always loaded then.
const firstViewId = projectStore.projects[projectId]?.views[0].id
if (firstViewId) {
router.replace({
name: 'project.view',
params: {
projectId,
viewId,
viewId: firstViewId,
},
})
}
},
}
}
watch(
() => viewId,
redirectToFirstViewIfNecessary,
{immediate: true},
)
watch(
() => projectStore.projects[projectId],
redirectToFirstViewIfNecessary,
)
const route = useRoute()
</script>