Open tu2-atmanand opened 1 month ago
The possible reason, why I think this must be happening is due to the fact that, I am using MarkdownRenderer for SubTasks and Description. But still, the Show Description button should have shown, after updating/adding Description content to the task. So, something is happening.
Also, now, i have to think on using an method to refresh only a specific taskItem Card whenever it changes. Like, incase of realTime Scanning, if suppose say, i figure out how to detect only the specific part of file being modified by user, then i can find out whether the task has been changed or other part of the file is being modified. This way, In the UI side, i can assign the taskItem with an id, which will be the task.id. And i can use function like getElementById to refresh that specific task.
Other than this, for now i have to come up with a better solution, because, when task is suppose to move from one column to another, then both of this columns should be refreshed. Or in case of editing just the content of the task, then the taskItem Card HTML should be re-rendered. I will have to go through my code again to see if any such thing will be possible.
The second biggest issue which i was facing in this main issue when any task's due date has been updated, then the task was suppose to go along with its subTasks and Description from one column to another. But earlier, its subTasks and Description were not getting moved and also those properties of this task was getting replaced to the task which was below to the task under consideration. So, to solve this issue i came up with a best solution of assigning a unique Id which was an combination of task.id and index of the subTasks, and this has been solved the issue using the following code :
const subtaskTextRefs = useRef<{ [key: string]: HTMLDivElement | null }>({});
useEffect(() => {
// Render subtasks after componentRef is initialized
task.body.forEach((subtaskText, index) => {
const uniqueKey = `${task.id}-${index}`;
const element = subtaskTextRefs.current[uniqueKey];
if (element) {
element.innerHTML = ''; // Clear previous content
const strippedSubtaskText = subtaskText.replace(/- \[.*?\]/, "").trim();
MarkdownUIRenderer.renderSubtaskText(
app,
strippedSubtaskText,
element,
task.filePath,
componentRef.current
);
hookMarkdownLinkMouseEventHandlers(app, element, task.filePath, task.filePath);
}
});
}, [task.body, task.filePath, app]);
// Render sub-tasks and remaining body separately
const renderSubTasks = () => {
try {
if (task.body.length > 0) {
return (
<>
{task.body.map((line, index) => {
const isCompleted = line.trim().startsWith('- [x]');
const isSubTask = line.trim().startsWith('- [ ]') || line.trim().startsWith('- [x]');
const subtaskText = line.replace(/- \[.\] /, '').trim();
// Calculate padding based on the number of tabs
const numTabs = line.match(/^\t+/)?.[0].length || 0;
const paddingLeft = numTabs > 1 ? `${(numTabs - 1) * 15}px` : '0px';
// Create a unique key for this subtask based on task.id and index
const uniqueKey = `${task.id}-${index}`;
return isSubTask ? (
<div
className="taskItemBodySubtaskItem"
key={uniqueKey}
style={{ paddingLeft }}
id={uniqueKey} // Assign a unique ID for each subtask element
>
<input
type="checkbox"
className="taskItemBodySubtaskItemCheckbox"
checked={isCompleted}
onChange={() => handleSubtaskCheckboxChange(index, isCompleted)}
/>
{/* Render each subtask separately */}
<div
className="subtaskTextRenderer"
ref={(el) => (subtaskTextRefs.current[uniqueKey] = el)} // Assign unique ref to each subtask
/>
</div>
) : null;
})}
</>
);
} else {
return null;
}
} catch (error) {
console.log('Getting error while trying to render the SubTasks: ', error);
return null;
}
};
If we could focus on this two things, then the whole issue will be resolved.
This is not related to this issue but still adding :
It was a very silly mistake of mine, because of which I has to write so many things. I knew a long back it uses to refreshes only columns and not the whole board when i use to do the checkbox operation or edit operations, etc.
MISTAKE : While making changes in the TaskItemUtils file, i removed the emmit lines which were refreshing the tasks after those json operatoins.🤣
Now, even though I have solved that problem, keep testing the board thoroughly, to find out in which case the board is not updating. Obviously the issue of Description getting appending to previous task issue is still there, but now the board has became usable, after solving this error now. I have to still keep optimizing the code now. I am not telling to write high level code this time, that is before releasing, keep the code simple only, but there may be some HTML methods only to refresh a specific taskItem kind of approaches which i can use to solve this problem, or to make the refreshing operation more optimized.
There are the below three major issues I am facing, after I make the board Operations or when the board refreshes after detecting a file change, the changes didnt update in the board, this is basically with the
REFRESH_COLUMN
event :[x] First onc is as shown in the image, when i update the task from the Modal :
[x] Second biggest issue is with the checkBox event. So, the following things happen when I click on the checkbox :
[x] Third is similar to the second one, when any tasks's due date is been changed, then only its Title gets moved to the destination column where its suppose to go, but its subTasks and Description doesnt moves along with it. Instead, these properties gets replaced to the task below the task which was moved earlier from the source column.
[x] Fourth issue is again similar to the second one, but its for Deleting a Task, if there is a taskItem just below the taskItem we are deleting (taskItem-1) say taskItem-2, then the when we delete the taskItem-1, its gets deleted very well deleted, but again, the SubTasks and Body of the taskItem-1 gets attached to this taskItem-2, when it comes up.