Skip to content

Commit 8723699

Browse files
Merge pull request #233 from pneumaticapp/frontend/websockets/47328__Some_events_are_processed_incorrectly_in_websockets
47328 frontend [ websockets ] Some events are processed incorrectly in websockets.
2 parents a1734c9 + 7ca60b2 commit 8723699

28 files changed

Lines changed: 1033 additions & 810 deletions

frontend/src/public/components/TaskCard/TaskCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,14 +606,14 @@ export function TaskCard({
606606
className={classnames(styles['container'], viewMode === ETaskCardViewMode.Guest && styles['container_guest'])}
607607
>
608608
{renderHeader()}
609-
<p className={styles['description']}>
609+
<div className={styles['description']}>
610610
<RichText
611611
text={task.description}
612612
interactiveChecklists
613613
renderExtensions={[...createChecklistExtension(task), ...createProgressbarExtension(task)]}
614614
hideIcon
615615
/>
616-
</p>
616+
</div>
617617
<div className={styles['info']}>
618618
<div className={styles['performers']}>
619619
{renderPerformersControllers()}

frontend/src/public/components/Workflows/WorkflowLog/WorkflowLogEvents/WorkflowLogTaskComment/WorkflowLogTaskComment.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useEffect, useRef, useState } from 'react';
2+
import { useSelector } from 'react-redux';
23
import { useIntl } from 'react-intl';
34
import classnames from 'classnames';
45
import { InView } from 'react-intersection-observer';
@@ -13,6 +14,8 @@ import { getUserFullName } from '../../../../../utils/users';
1314
import { RichText } from '../../../../RichText';
1415
import { Attachments } from '../../../../Attachments';
1516
import { UserData } from '../../../../UserData';
17+
import { getUserById } from '../../../../UserData/utils/getUserById';
18+
import { getUsers } from '../../../../../redux/selectors/user';
1619
import {
1720
AddEmojiIcon,
1821
CommentDeleteIcon,
@@ -23,7 +26,7 @@ import {
2326
} from '../../../../icons';
2427
import { RichEditor } from '../../../../RichEditor';
2528
import { type TMentionData } from '../../../../RichEditor/types';
26-
import { IAccount, TUserListItem } from '../../../../../types/user';
29+
import { TUserListItem } from '../../../../../types/user';
2730
import { useStatePromise } from '../../../../../hooks/useStatePromise';
2831
import { TUploadedFile } from '../../../../../utils/uploadFiles';
2932
import { IEditComment } from '../../../../../api/workflows/editComment';
@@ -59,6 +62,7 @@ export function WorkflowLogTaskComment({
5962
mentions,
6063
}: TWorkflowLogTaskCommentProps) {
6164
const { formatMessage } = useIntl();
65+
const users = useSelector(getUsers);
6266

6367
const clickRef = useRef<HTMLButtonElement>(null);
6468
const [isShowTooltipEmoji, setIsShowTooltipEmoji] = useState(false);
@@ -86,7 +90,7 @@ export function WorkflowLogTaskComment({
8690
const handleReactionComment = (value: string) => {
8791
if (workflowStatus === EWorkflowStatus.Finished) return;
8892

89-
if (value in reactions && reactions[value].indexOf(currentUserId as Pick<IAccount, 'id'>) !== -1) {
93+
if (value in reactions && reactions[value].includes(currentUserId)) {
9094
deleteReactionComment({ id, value });
9195
} else {
9296
createReactionComment({ id, value });
@@ -259,30 +263,26 @@ export function WorkflowLogTaskComment({
259263
return typeMap[type];
260264
};
261265

262-
const renderListUsers = (list: Pick<IAccount, 'id'>[]) => {
266+
const renderListUsers = (userIds: number[]) => {
263267
return (
264268
<ul className={styles['comment__watch-list']}>
265-
{list.map((userWatch) => {
269+
{userIds.map((listedUserId) => {
270+
const user = getUserById(users, listedUserId);
271+
266272
return (
267-
<UserData userId={userWatch as number}>
268-
{(user) => {
269-
if (!user) return null;
270-
const userName = getUserFullName(user);
271-
272-
return <li>{userName}</li>;
273-
}}
274-
</UserData>
273+
<li key={listedUserId}>{user ? getUserFullName(user) : null}</li>
275274
);
276275
})}
277276
</ul>
278277
);
279278
};
280279

281280
const renderReaction = () => {
282-
return Object.entries(reactions).map(([value, users]) => {
281+
return Object.entries(reactions).map(([value, reactedUserIds]) => {
283282
return (
284283
<Tooltip
285-
content={renderListUsers(users)}
284+
key={value}
285+
content={renderListUsers(reactedUserIds)}
286286
containerClassName={classnames(styles['comment__footer-item'], workflowModal && styles['is-modal'])}
287287
>
288288
<button
@@ -292,7 +292,7 @@ export function WorkflowLogTaskComment({
292292
className={styles['comment__footer-item']}
293293
>
294294
<div className={styles['comment__footer-item-emoji']}>{value}</div>
295-
<span>{users.length}</span>
295+
<span>{reactedUserIds.length}</span>
296296
</button>
297297
</Tooltip>
298298
);

frontend/src/public/redux/accounts/slice.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,26 @@ const accountsSlice = createSlice({
192192
closeCreateUserModal: (state) => {
193193
state.isCreateUserModalOpen = false;
194194
},
195+
196+
upsertUserFromWs: (state, action: PayloadAction<TUserListItem>) => {
197+
const user = action.payload;
198+
const upsertList = (list: TUserListItem[]) => {
199+
const hasUser = list.some((item) => item.id === user.id);
200+
if (!hasUser) {
201+
return [...list, user];
202+
}
203+
return list.map((item) => (item.id === user.id ? { ...item, ...user } : item));
204+
};
205+
206+
state.users = upsertList(state.users);
207+
state.team.list = upsertList(state.team.list);
208+
},
209+
210+
removeUserFromWs: (state, action: PayloadAction<number>) => {
211+
const removeFromList = (list: TUserListItem[]) => list.filter((item) => item.id !== action.payload);
212+
state.users = removeFromList(state.users);
213+
state.team.list = removeFromList(state.team.list);
214+
},
195215
},
196216
});
197217

@@ -242,6 +262,8 @@ export const {
242262
closeCreateUserModal,
243263
changeUserManager,
244264
changeUserReports,
265+
upsertUserFromWs,
266+
removeUserFromWs,
245267
} = accountsSlice.actions;
246268

247269
export default accountsSlice.reducer;

frontend/src/public/redux/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export * from './integrations/actions';
99
export * from './notifications/actions';
1010
export * from './selectTemplateModal/actions';
1111
export * from './runWorkflowModal/actions';
12-
export * from './groups/actions';
12+
export * from './groups/slice';
1313
export * from './dashboard/actions';
1414
export * from './highlights/actions';
1515
export * from './webhooks/actions';

frontend/src/public/redux/groups/actions.ts

Lines changed: 0 additions & 152 deletions
This file was deleted.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export * from './reducer';
2-
3-
export { reducer as groups } from './reducer';
1+
export { default as groups } from './slice';
2+
export * from './slice';

0 commit comments

Comments
 (0)