From dbe1ad9353e165fd1e314cc72c7a4dece1c47d38 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 20 Jun 2023 15:24:02 +0200 Subject: [PATCH] fix: set and use correct type for destructured props --- .../project/partials/useProjectBackground.ts | 12 ++++++------ .../tasks/partials/singleTaskInProject.vue | 2 +- src/composables/useTaskList.ts | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/project/partials/useProjectBackground.ts b/src/components/project/partials/useProjectBackground.ts index ce1539838..cbe7d473b 100644 --- a/src/components/project/partials/useProjectBackground.ts +++ b/src/components/project/partials/useProjectBackground.ts @@ -1,19 +1,19 @@ -import {ref, watch, type Ref} from 'vue' +import {ref, watch, type ShallowReactive} from 'vue' import ProjectService from '@/services/project' import type {IProject} from '@/modelTypes/IProject' import {getBlobFromBlurHash} from '@/helpers/getBlobFromBlurHash' -export function useProjectBackground(project: Ref) { +export function useProjectBackground(project: ShallowReactive) { const background = ref(null) const backgroundLoading = ref(false) const blurHashUrl = ref('') watch( - () => [project.value.id, project.value.backgroundBlurHash] as [IProject['id'], IProject['backgroundBlurHash']], + () => [project.id, project.backgroundBlurHash] as [IProject['id'], IProject['backgroundBlurHash']], async ([projectId, blurHash], oldValue) => { if ( - project.value === null || - !project.value.backgroundInformation || + project === null || + !project.backgroundInformation || backgroundLoading.value ) { return @@ -36,7 +36,7 @@ export function useProjectBackground(project: Ref) { }) const projectService = new ProjectService() - const backgroundPromise = projectService.background(project.value).then((result) => { + const backgroundPromise = projectService.background(project).then((result) => { background.value = result }) await Promise.all([blurHashPromise, backgroundPromise]) diff --git a/src/components/tasks/partials/singleTaskInProject.vue b/src/components/tasks/partials/singleTaskInProject.vue index f58737965..52d644f20 100644 --- a/src/components/tasks/partials/singleTaskInProject.vue +++ b/src/components/tasks/partials/singleTaskInProject.vue @@ -185,7 +185,7 @@ watch( ) onMounted(() => { - task.value = theTask.value + task.value = theTask document.addEventListener('click', hideDeferDueDatePopup) }) diff --git a/src/composables/useTaskList.ts b/src/composables/useTaskList.ts index 12604be35..92d7a9ced 100644 --- a/src/composables/useTaskList.ts +++ b/src/composables/useTaskList.ts @@ -1,9 +1,10 @@ -import {ref, shallowReactive, watch, computed} from 'vue' +import {ref, shallowReactive, watch, computed, type ShallowReactive} from 'vue' import {useRoute} from 'vue-router' import TaskCollectionService from '@/services/taskCollection' import type {ITask} from '@/modelTypes/ITask' import {error} from '@/message' +import type {IProject} from '@/modelTypes/IProject' export type Order = 'asc' | 'desc' | 'none' @@ -60,7 +61,7 @@ const SORT_BY_DEFAULT: SortBy = { /** * This mixin provides a base set of methods and properties to get tasks. */ -export function useTaskList(projectId, sortByDefault: SortBy = SORT_BY_DEFAULT) { +export function useTaskList(projectId: ShallowReactive, sortByDefault: SortBy = SORT_BY_DEFAULT) { const params = ref({...getDefaultParams()}) const search = ref('') @@ -80,7 +81,7 @@ export function useTaskList(projectId, sortByDefault: SortBy = SORT_BY_DEFAULT) loadParams = formatSortOrder(sortBy.value, loadParams) return [ - {projectId: projectId.value}, + {projectId: projectId}, loadParams, page.value || 1, ]