|
|
|
@ -95,8 +95,6 @@ export const useTaskListEvents = (props: IProps) => {
@@ -95,8 +95,6 @@ export const useTaskListEvents = (props: IProps) => {
|
|
|
|
|
taskId: number | string |
|
|
|
|
userId?: number |
|
|
|
|
}) => { |
|
|
|
|
if (data.userId && data.userId !== account.id) return |
|
|
|
|
|
|
|
|
|
const index = _.findIndex( |
|
|
|
|
props.items, |
|
|
|
|
item => item.id.toString() === data.taskId.toString(), |
|
|
|
@ -112,6 +110,11 @@ export const useTaskListEvents = (props: IProps) => {
@@ -112,6 +110,11 @@ export const useTaskListEvents = (props: IProps) => {
|
|
|
|
|
props.setItems(changedItems) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onCommentsAreRead = (data: SocketEvents['task/read-comments']) => { |
|
|
|
|
if (!data.userId || (data.userId && data.userId !== account.id)) return |
|
|
|
|
onTaskCommentsRead(data) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onTaskDocumentsRead = (data: { taskId: number | string }) => { |
|
|
|
|
const index = _.findIndex( |
|
|
|
|
props.items, |
|
|
|
@ -129,7 +132,9 @@ export const useTaskListEvents = (props: IProps) => {
@@ -129,7 +132,9 @@ export const useTaskListEvents = (props: IProps) => {
|
|
|
|
|
props.setItems(changedItems) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onTaskNewComment = (data: { taskId: number }) => { |
|
|
|
|
const onTaskNewComment = (data: SocketEvents['task/new-comment']) => { |
|
|
|
|
if (data.userId === account.id) return |
|
|
|
|
|
|
|
|
|
const index = _.findIndex( |
|
|
|
|
props.items, |
|
|
|
|
item => item.id.toString() === data.taskId.toString(), |
|
|
|
@ -311,7 +316,7 @@ export const useTaskListEvents = (props: IProps) => {
@@ -311,7 +316,7 @@ export const useTaskListEvents = (props: IProps) => {
|
|
|
|
|
// ************************************************************
|
|
|
|
|
|
|
|
|
|
// ******** SOCKET SIGNALS LISTENERS **************************
|
|
|
|
|
useSocketListener('task/new-comment', onTaskNewComment, [props.items]) |
|
|
|
|
useSocketListener('task/new-comment', onTaskNewComment, [props.items, account]) |
|
|
|
|
|
|
|
|
|
useSocketListener('task/new-task', onNewTask, [props.items]) |
|
|
|
|
|
|
|
|
@ -325,7 +330,7 @@ export const useTaskListEvents = (props: IProps) => {
@@ -325,7 +330,7 @@ export const useTaskListEvents = (props: IProps) => {
|
|
|
|
|
|
|
|
|
|
useSocketListener('task/read-docs', onTaskDocumentsRead, [props.items]) |
|
|
|
|
|
|
|
|
|
useSocketListener('task/read-comments', onTaskCommentsRead, [props.items]) |
|
|
|
|
useSocketListener('task/read-comments', onCommentsAreRead, [props.items]) |
|
|
|
|
|
|
|
|
|
useSocketListener('task/new-docs', onTaskNewDocument, [props.items]) |
|
|
|
|
|
|
|
|
|