1
0

fix: set and use correct type for destructured props

This commit is contained in:
kolaente
2023-06-20 15:24:02 +02:00
parent b6cd424aa3
commit dbe1ad9353
3 changed files with 11 additions and 10 deletions

View File

@ -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<IProject>) {
export function useProjectBackground(project: ShallowReactive<IProject>) {
const background = ref<string | null>(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<IProject>) {
})
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])