refactor(task-list): streamline task addition and socket handling

- Removed local socket listener from AddTaskRow, delegating task addition to the global socket handler for real-time updates.
- Simplified the handleTaskAdded function in TaskListV2, eliminating the need for refetching tasks upon addition.
- Updated useTaskSocketHandlers to handle task data more efficiently, ensuring proper integration with the Redux store.
This commit is contained in:
chamiakJ
2025-07-06 15:42:12 +05:30
parent a5291483f7
commit 6ba1ff57b2
3 changed files with 15 additions and 83 deletions

View File

@@ -575,7 +575,9 @@ export const useTaskSocketHandlers = () => {
);
const handleNewTaskReceived = useCallback(
(data: IProjectTask) => {
(response: any) => {
// Handle array format response [index, taskData]
const data = Array.isArray(response) ? response[1] : response;
if (!data) return;
if (data.parent_task_id) {
// Handle subtask creation
@@ -600,10 +602,10 @@ export const useTaskSocketHandlers = () => {
: 'low') as 'critical' | 'high' | 'medium' | 'low',
phase: data.phase_name || 'Development',
progress: data.complete_ratio || 0,
assignees: data.assignees?.map(a => a.team_member_id) || [],
assignees: data.assignees?.map((a: any) => a.team_member_id) || [],
assignee_names: data.names || [],
labels:
data.labels?.map(l => ({
data.labels?.map((l: any) => ({
id: l.id || '',
name: l.name || '',
color: l.color_code || '#1890ff',
@@ -654,10 +656,10 @@ export const useTaskSocketHandlers = () => {
: 'low') as 'critical' | 'high' | 'medium' | 'low',
phase: data.phase_name || 'Development',
progress: data.complete_ratio || 0,
assignees: data.assignees?.map(a => a.team_member_id) || [],
assignees: data.assignees?.map((a: any) => a.team_member_id) || [],
assignee_names: data.names || [],
labels:
data.labels?.map(l => ({
data.labels?.map((l: any) => ({
id: l.id || '',
name: l.name || '',
color: l.color_code || '#1890ff',
@@ -697,7 +699,7 @@ export const useTaskSocketHandlers = () => {
}
// Use addTaskToGroup with the actual group UUID
dispatch(addTaskToGroup({ task, groupId }));
dispatch(addTaskToGroup({ task, groupId: groupId || '' }));
// Also update enhanced kanban slice for regular task creation
dispatch(