fix openening a task by link

This commit is contained in:
Никита Губарь 2024-07-26 15:50:28 +03:00
parent 1d9a47def4
commit 15f8b51327

View File

@ -53,6 +53,7 @@ export const ProjectTracker = () => {
const projectId = useParams(); const projectId = useParams();
const taskParams = useParams(); const taskParams = useParams();
const taskRefs = useRef([]); const taskRefs = useRef([]);
const hasRunEffect = useRef(false);
const [openColumnSelect, setOpenColumnSelect] = useState({}); const [openColumnSelect, setOpenColumnSelect] = useState({});
const [selectedTab, setSelectedTab] = useState(0); const [selectedTab, setSelectedTab] = useState(0);
@ -81,25 +82,15 @@ export const ProjectTracker = () => {
}, []); }, []);
useEffect(() => { useEffect(() => {
// const observer = new MutationObserver(() => { if (projectBoard.columns && taskParams.taskId && !hasRunEffect.current) {
// if (taskParams.taskId && taskRefs.current[taskParams.taskId]) {
// taskRefs.current[taskParams.taskId].click();
// console.log(taskRefs.current[taskParams.taskId]);
// }
// });
// observer.observe(document.body, { childList: true, subtree: true });
// return () => observer.disconnect();
if (projectBoard.columns && taskParams.taskId) {
for (const column of projectBoard.columns) { for (const column of projectBoard.columns) {
const task = column.tasks.find((task) => task.id == taskParams.taskId); const task = column.tasks.find((task) => task.id == taskParams.taskId);
if (task) { if (task) {
openTicket(task); openTicket(task);
hasRunEffect.current = true;
return; return;
} }
} }
console.log(projectBoard);
} }
}, [projectBoard]); }, [projectBoard]);