Skip to content

Commit 7ca60b2

Browse files
47328 refactor(WorkflowLog): simplify user ID handling in comments and reactions
1 parent 1f6bcbc commit 7ca60b2

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
} from '../../../../icons';
2727
import { RichEditor } from '../../../../RichEditor';
2828
import { type TMentionData } from '../../../../RichEditor/types';
29-
import { IAccount, TUserListItem } from '../../../../../types/user';
29+
import { TUserListItem } from '../../../../../types/user';
3030
import { useStatePromise } from '../../../../../hooks/useStatePromise';
3131
import { TUploadedFile } from '../../../../../utils/uploadFiles';
3232
import { IEditComment } from '../../../../../api/workflows/editComment';
@@ -90,7 +90,7 @@ export function WorkflowLogTaskComment({
9090
const handleReactionComment = (value: string) => {
9191
if (workflowStatus === EWorkflowStatus.Finished) return;
9292

93-
if (value in reactions && reactions[value].indexOf(currentUserId as Pick<IAccount, 'id'>) !== -1) {
93+
if (value in reactions && reactions[value].includes(currentUserId)) {
9494
deleteReactionComment({ id, value });
9595
} else {
9696
createReactionComment({ id, value });
@@ -263,14 +263,14 @@ export function WorkflowLogTaskComment({
263263
return typeMap[type];
264264
};
265265

266-
const renderListUsers = (list: Pick<IAccount, 'id'>[]) => {
266+
const renderListUsers = (userIds: number[]) => {
267267
return (
268268
<ul className={styles['comment__watch-list']}>
269-
{list.map((userWatch) => {
270-
const user = getUserById(users, userWatch.id);
269+
{userIds.map((listedUserId) => {
270+
const user = getUserById(users, listedUserId);
271271

272272
return (
273-
<li key={userWatch.id}>{user ? getUserFullName(user) : null}</li>
273+
<li key={listedUserId}>{user ? getUserFullName(user) : null}</li>
274274
);
275275
})}
276276
</ul>

frontend/src/public/redux/realtime/utils/__tests__/mapWorkflowLogEventFromWs.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ describe('mapWsEnvelopeToWorkflowLogItem', () => {
8787
task: null,
8888
delay: null,
8989
attachments: [],
90-
watched: [{ date: '2024-01-01T01:00:00Z', userId: { id: 3 } }],
91-
reactions: { '👍': [{ id: 3 }] },
90+
watched: [{ date: '2024-01-01T01:00:00Z', userId: 3 }],
91+
reactions: { '👍': [3] },
9292
};
9393

9494
const result = mapWsEnvelopeToWorkflowLogItem({

frontend/src/public/types/workflow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IAccount, TUserId } from './user';
1+
import { TUserId } from './user';
22
import { TUploadedFile } from '../utils/uploadFiles';
33
import { ITask, ITemplateStep, TaskWithTsp } from './tasks';
44
import {
@@ -102,8 +102,8 @@ export interface IWorkflowLogItem {
102102
targetUserId: number | null;
103103
targetGroupId: number | null;
104104
attachments: [];
105-
watched: { date: string; userId: Pick<IAccount, 'id'> }[];
106-
reactions: { [value: string]: Pick<IAccount, 'id'>[] };
105+
watched: { date: string; userId: number }[];
106+
reactions: { [value: string]: number[] };
107107
}
108108

109109
export interface IWorkflowDelay {

0 commit comments

Comments
 (0)