feature/projects-all-the-way-down #3323

Merged
konrad merged 123 commits from feature/projects-all-the-way-down into main 2023-05-30 10:09:40 +00:00
Showing only changes of commit 26bec05174 - Show all commits

View File

@ -450,7 +450,7 @@
</template>
<script lang="ts" setup>
import {ref, reactive, toRef, shallowReactive, computed, watch, nextTick, type PropType} from 'vue'
import {ref, reactive, toRef, shallowReactive, computed, watch, watchEffect, nextTick, type PropType} from 'vue'
import {useRouter, type RouteLocation} from 'vue-router'
import {useI18n} from 'vue-i18n'
import {unrefElement} from '@vueuse/core'
@ -539,16 +539,11 @@ const visible = ref(false)
konrad marked this conversation as resolved Outdated

getProjectById returns undefined if there is no project with that id. So why not use that directly?

`getProjectById` returns `undefined` if there is no project with that id. So why not use that directly?

Done

Done
const taskId = toRef(props, 'taskId')
const project = computed(() => {
if (!task.projectId) {
return {
project: null,
}
}
const project = projectStore.getProjectById(task.projectId)
baseStore.handleSetCurrentProject({project})
return project
const project = computed(() => task.projectId ? projectStore.getProjectById(task.projectId) : null)
watchEffect(() => {
baseStore.handleSetCurrentProject({
project: project.value,
})
})
konrad marked this conversation as resolved Outdated

Very bad pattern.

A side effect of a computed can lead to various weird issues. Instead there should be a watcher! Why not use getProjectById directly?

const project = computed(() => projectStore.getProjectById(task.projectId)})

watchEffect(() => {
	baseStore.handleSetCurrentProject({
    	project: project.value
   	})
})
__Very__ bad pattern. A side effect of a computed can lead to various weird issues. Instead there should be a watcher! Why not use `getProjectById` directly? ```ts const project = computed(() => projectStore.getProjectById(task.projectId)}) watchEffect(() => { baseStore.handleSetCurrentProject({ project: project.value }) }) ```

I don't even know why I moved that into the computed instead of leaving the watcher as it was before. Changed it back now.

I don't even know why I moved that into the computed instead of leaving the watcher as it was before. Changed it back now.
const canWrite = computed(() => (