|
|
|
@ -42,25 +42,38 @@ export const useTaskListEvents = (props: IProps) => {
@@ -42,25 +42,38 @@ export const useTaskListEvents = (props: IProps) => {
|
|
|
|
|
_.some(props.items, item => _.includes(ids, item.id.toString())) |
|
|
|
|
|
|
|
|
|
const onTaskDeleted = (data: { ids: (number | string)[] }) => { |
|
|
|
|
const ids = data.ids.map(it => it.toString()) |
|
|
|
|
if (!checkListContainAnyItem(ids)) return |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
props.taskFilterStatus === TaskStatus.Active || |
|
|
|
|
props.taskFilterStatus === TaskStatus.Finished |
|
|
|
|
) { |
|
|
|
|
const filteredItems = _.filter( |
|
|
|
|
props.items, |
|
|
|
|
item => !_.includes(ids, item.id.toString()), |
|
|
|
|
) |
|
|
|
|
props.setItems(filteredItems) |
|
|
|
|
props.onAction('delete') |
|
|
|
|
|
|
|
|
|
if (props.items.length === 1) |
|
|
|
|
appEvents.emit('onLastTaskDeleted', {}) |
|
|
|
|
deleteTaskFromList(data) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onTaskHardDeleted = (data: { |
|
|
|
|
taskId: number |
|
|
|
|
executorId: number |
|
|
|
|
}) => { |
|
|
|
|
deleteTaskFromList({ ids: [data.taskId] }) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function deleteTaskFromList(data: { ids: (number | string)[] }) { |
|
|
|
|
const ids = data.ids.map(it => it.toString()) |
|
|
|
|
|
|
|
|
|
if (!checkListContainAnyItem(ids)) return |
|
|
|
|
|
|
|
|
|
const filteredItems = _.filter( |
|
|
|
|
props.items, |
|
|
|
|
item => !_.includes(ids, item.id.toString()), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
props.setItems(filteredItems) |
|
|
|
|
props.onAction('delete') |
|
|
|
|
|
|
|
|
|
if (props.items.length === 1 || _.isEmpty(filteredItems)) |
|
|
|
|
appEvents.emit('onLastTaskDeleted', {}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// *********** APP EVENTS AND SOCKET SIGNALS HANDLERS *************
|
|
|
|
|
const onTaskChanged = (data: { ids: (number | string)[] }) => { |
|
|
|
|
if (!checkListContainAnyItem(data.ids.map(it => it.toString()))) return |
|
|
|
@ -316,7 +329,10 @@ export const useTaskListEvents = (props: IProps) => {
@@ -316,7 +329,10 @@ export const useTaskListEvents = (props: IProps) => {
|
|
|
|
|
// ************************************************************
|
|
|
|
|
|
|
|
|
|
// ******** SOCKET SIGNALS LISTENERS **************************
|
|
|
|
|
useSocketListener('task/new-comment', onTaskNewComment, [props.items, account]) |
|
|
|
|
useSocketListener('task/new-comment', onTaskNewComment, [ |
|
|
|
|
props.items, |
|
|
|
|
account, |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
useSocketListener('task/new-task', onNewTask, [props.items]) |
|
|
|
|
|
|
|
|
@ -326,6 +342,8 @@ export const useTaskListEvents = (props: IProps) => {
@@ -326,6 +342,8 @@ export const useTaskListEvents = (props: IProps) => {
|
|
|
|
|
|
|
|
|
|
useSocketListener('task/delete-task', onDeleteTask, [props.items]) |
|
|
|
|
|
|
|
|
|
useSocketListener('task/hard-delete-task', onTaskHardDeleted, [props.items]) |
|
|
|
|
|
|
|
|
|
useSocketListener('task/read', onTaskRead, [props.items]) |
|
|
|
|
|
|
|
|
|
useSocketListener('task/read-docs', onTaskDocumentsRead, [props.items]) |
|
|
|
|