Skip to content

Commit 83278b6

Browse files
fix: failure to update message due to reserved fields
1 parent 89e098c commit 83278b6

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

package/src/components/Message/hooks/useMessageActions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import {
2626
} from '../../../icons';
2727
import { setClipboardString } from '../../../native';
2828
import type { DefaultStreamChatGenerics } from '../../../types/types';
29+
import { removeReservedFields } from '../../../utils/removeReservedFields';
2930
import { MessageStatusTypes } from '../../../utils/utils';
3031

3132
import type { MessageType } from '../../MessageList/hooks/useMessageList';
3233
import type { MessageActionType } from '../../MessageOverlay/MessageActionListItem';
33-
import { removeReservedFields } from '../utils/removeReservedFields';
3434

3535
export const useMessageActions = <
3636
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,

package/src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export * from './Message/MessageSimple/MessageTextContainer';
108108
export * from './Message/MessageSimple/ReactionList';
109109
export * from './Message/MessageSimple/utils/renderText';
110110
export * from './Message/utils/messageActions';
111-
export * from './Message/utils/removeReservedFields';
111+
export * from '../utils/removeReservedFields';
112112

113113
export * from './MessageInput/AttachButton';
114114
export * from './MessageInput/CommandsButton';

package/src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import type { UploadProgressIndicatorProps } from '../../components/MessageInput
3838
import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
3939
import { compressImage, getLocalAssetUri, pickDocument } from '../../native';
4040
import type { Asset, DefaultStreamChatGenerics, File, UnknownType } from '../../types/types';
41+
import { removeReservedFields } from '../../utils/removeReservedFields';
4142
import {
4243
ACITriggerSettings,
4344
ACITriggerSettingsParams,
@@ -764,7 +765,12 @@ export const MessageInputProvider = <
764765
// TODO: Remove this line and show an error when submit fails
765766
value.clearEditingState();
766767

767-
const updateMessagePromise = value.editMessage(updatedMessage).then(value.clearEditingState);
768+
const updateMessagePromise = value
769+
.editMessage(
770+
// @ts-ignore
771+
removeReservedFields(updatedMessage),
772+
)
773+
.then(value.clearEditingState);
768774
resetInput(attachments);
769775
logChatPromiseExecution(updateMessagePromise, 'update message');
770776

package/src/contexts/messageInputContext/__tests__/__snapshots__/sendMessage.test.tsx.snap

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Object {
1515
"type": "image",
1616
},
1717
],
18-
"created_at": "Sat Jul 02 2022 23:55:13 GMT+0530 (India Standard Time)",
1918
"html": "<p>regular</p>",
2019
"id": "7a85f744-cc89-4f82-a1d4-5456432cc8bf",
2120
"mentioned_users": Array [
@@ -24,8 +23,6 @@ Object {
2423
],
2524
"quoted_message": undefined,
2625
"text": "",
27-
"type": "regular",
28-
"updated_at": "Sat Jul 02 2022 23:55:13 GMT+0530 (India Standard Time)",
2926
"user": Object {
3027
"banned": false,
3128
"created_at": "2020-04-27T13:39:49.331742Z",

package/src/components/Message/utils/removeReservedFields.ts renamed to package/src/utils/removeReservedFields.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { DefaultStreamChatGenerics } from '../../../types/types';
2-
import type { MessageType } from '../../MessageList/hooks/useMessageList';
1+
import type { MessageType } from '../components/MessageList/hooks/useMessageList';
2+
import type { DefaultStreamChatGenerics } from '../types/types';
33

44
export const removeReservedFields = <
55
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -12,7 +12,11 @@ export const removeReservedFields = <
1212
'config',
1313
'created_at',
1414
'created_by',
15-
'id',
15+
'deleted_at',
16+
'i18n',
17+
'latest_reactions',
18+
'own_reactions',
19+
'reaction_counts',
1620
'last_message_at',
1721
'member_count',
1822
'type',

0 commit comments

Comments
 (0)