Skip to content

Commit

Permalink
fixed task toggle on load
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-Web3 committed May 2, 2023
1 parent fa1945c commit 32c63e1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/components/shared/ViewTask.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useId, useState } from 'react'
import React, { useEffect, useId, useRef, useState } from 'react'
import { nanoid } from 'nanoid'
import { AnimatePresence, motion } from 'framer-motion'

Expand Down Expand Up @@ -79,6 +79,7 @@ const ViewTask: React.FC<{
const setModalType = useStore(state => state.setModalType)
const modalType = useStore(state => state.modalType)
const toggleTaskCompleted = useStore(state => state.toggleTaskCompleted)
const isMounted = useRef(false)
const theme = useStore(state => state.theme())

const [subtasksM, setSubtaskM] = useState(subtasks)
Expand Down Expand Up @@ -108,12 +109,14 @@ const ViewTask: React.FC<{

useEffect(
() => {
toggleTaskCompleted(
currentBoard.id,
modalType.modalInfo!.statusId!,
modalType.modalInfo!.id,
subtasksM
)
if (isMounted.current)
toggleTaskCompleted(
currentBoard.id,
modalType.modalInfo!.statusId!,
modalType.modalInfo!.id,
subtasksM
)
isMounted.current = true
},
subtasksM.map(el => el.completed)
)
Expand Down

0 comments on commit 32c63e1

Please sign in to comment.