stream-chat-react-native-core 5.6.0-beta.0 → 5.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Attachment/Gallery.js +21 -16
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Attachment/GalleryImage.js +3 -3
- package/lib/commonjs/components/Attachment/GalleryImage.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +34 -30
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js +5 -1
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/commonjs/components/Message/hooks/useMessageActions.js +2 -2
- package/lib/commonjs/components/Message/hooks/useMessageActions.js.map +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +18 -21
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/commonjs/components/MessageInput/ImageUploadPreview.js +7 -32
- package/lib/commonjs/components/MessageInput/ImageUploadPreview.js.map +1 -1
- package/lib/commonjs/components/index.js +1 -1
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js +128 -89
- package/lib/commonjs/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js +1 -0
- package/lib/commonjs/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
- package/lib/commonjs/utils/DBSyncManager.js +16 -16
- package/lib/commonjs/utils/DBSyncManager.js.map +1 -1
- package/lib/commonjs/{components/Message/utils → utils}/removeReservedFields.js +1 -1
- package/lib/commonjs/utils/removeReservedFields.js.map +1 -0
- package/lib/commonjs/utils/utils.js +2 -2
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Gallery.js +21 -16
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Attachment/GalleryImage.js +3 -3
- package/lib/module/components/Attachment/GalleryImage.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +34 -30
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js +5 -1
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/module/components/Message/hooks/useMessageActions.js +2 -2
- package/lib/module/components/Message/hooks/useMessageActions.js.map +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +18 -21
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/module/components/MessageInput/ImageUploadPreview.js +7 -32
- package/lib/module/components/MessageInput/ImageUploadPreview.js.map +1 -1
- package/lib/module/components/index.js +1 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/contexts/messageInputContext/MessageInputContext.js +128 -89
- package/lib/module/contexts/messageInputContext/MessageInputContext.js.map +1 -1
- package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js +1 -0
- package/lib/module/contexts/messageInputContext/hooks/useMessageDetailsForState.js.map +1 -1
- package/lib/module/utils/DBSyncManager.js +16 -16
- package/lib/module/utils/DBSyncManager.js.map +1 -1
- package/lib/module/{components/Message/utils → utils}/removeReservedFields.js +1 -1
- package/lib/module/utils/removeReservedFields.js.map +1 -0
- package/lib/module/utils/utils.js +2 -2
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/MessageInput/FileUploadPreview.d.ts +1 -1
- package/lib/typescript/components/MessageInput/ImageUploadPreview.d.ts +1 -1
- package/lib/typescript/components/index.d.ts +1 -1
- package/lib/typescript/store/mappers/mapTaskToStorable.d.ts +0 -8
- package/lib/typescript/store/types.d.ts +0 -4
- package/lib/typescript/utils/DBSyncManager.d.ts +1 -1
- package/lib/typescript/{components/Message/utils → utils}/removeReservedFields.d.ts +2 -2
- package/lib/typescript/utils/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Attachment/Gallery.tsx +5 -1
- package/src/components/Attachment/GalleryImage.tsx +2 -0
- package/src/components/Channel/Channel.tsx +12 -11
- package/src/components/ChannelList/hooks/usePaginatedChannels.ts +6 -4
- package/src/components/Message/hooks/useMessageActions.tsx +1 -1
- package/src/components/MessageInput/FileUploadPreview.tsx +4 -5
- package/src/components/MessageInput/ImageUploadPreview.tsx +10 -35
- package/src/components/index.ts +1 -1
- package/src/contexts/messageInputContext/MessageInputContext.tsx +94 -75
- package/src/contexts/messageInputContext/__tests__/__snapshots__/sendMessage.test.tsx.snap +0 -3
- package/src/contexts/messageInputContext/hooks/useMessageDetailsForState.ts +1 -0
- package/src/store/types.ts +0 -5
- package/src/utils/DBSyncManager.ts +1 -1
- package/src/{components/Message/utils → utils}/removeReservedFields.ts +7 -3
- package/src/utils/utils.ts +7 -6
- package/src/version.json +1 -1
- package/lib/commonjs/components/Message/utils/removeReservedFields.js.map +0 -1
- package/lib/commonjs/utils/pendingTaskUtils.js +0 -302
- package/lib/commonjs/utils/pendingTaskUtils.js.map +0 -1
- package/lib/module/components/Message/utils/removeReservedFields.js.map +0 -1
- package/lib/module/utils/pendingTaskUtils.js +0 -302
- package/lib/module/utils/pendingTaskUtils.js.map +0 -1
- package/lib/typescript/utils/pendingTaskUtils.d.ts +0 -13
- package/src/utils/pendingTaskUtils.ts +0 -131
|
@@ -80,7 +80,7 @@ type ImageUploadPreviewPropsWithContext<
|
|
|
80
80
|
MessageInputContextValue<StreamChatGenerics>,
|
|
81
81
|
'imageUploads' | 'removeImage' | 'uploadImage'
|
|
82
82
|
> &
|
|
83
|
-
Pick<ChatContextValue<StreamChatGenerics>, '
|
|
83
|
+
Pick<ChatContextValue<StreamChatGenerics>, 'enableOfflineSupport'>;
|
|
84
84
|
|
|
85
85
|
export type ImageUploadPreviewProps<
|
|
86
86
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -93,7 +93,7 @@ const ImageUploadPreviewWithContext = <
|
|
|
93
93
|
>(
|
|
94
94
|
props: ImageUploadPreviewPropsWithContext<StreamChatGenerics>,
|
|
95
95
|
) => {
|
|
96
|
-
const { enableOfflineSupport, imageUploads,
|
|
96
|
+
const { enableOfflineSupport, imageUploads, removeImage, uploadImage } = props;
|
|
97
97
|
|
|
98
98
|
const {
|
|
99
99
|
theme: {
|
|
@@ -131,7 +131,7 @@ const ImageUploadPreviewWithContext = <
|
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
const renderItem = ({ index, item }: ImageUploadPreviewItem) => {
|
|
134
|
-
const indicatorType = getIndicatorTypeForFileState(item.state,
|
|
134
|
+
const indicatorType = getIndicatorTypeForFileState(item.state, enableOfflineSupport);
|
|
135
135
|
const itemMarginForIndex = index === imageUploads.length - 1 ? { marginRight: 8 } : {};
|
|
136
136
|
|
|
137
137
|
return (
|
|
@@ -202,40 +202,15 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
|
|
|
202
202
|
prevProps: ImageUploadPreviewPropsWithContext<StreamChatGenerics>,
|
|
203
203
|
nextProps: ImageUploadPreviewPropsWithContext<StreamChatGenerics>,
|
|
204
204
|
) => {
|
|
205
|
-
const {
|
|
206
|
-
|
|
207
|
-
imageUploads: prevImageUploads,
|
|
208
|
-
isOnline: prevIsOnline,
|
|
209
|
-
} = prevProps;
|
|
210
|
-
const {
|
|
211
|
-
enableOfflineSupport: nextEnableOfflineSupport,
|
|
212
|
-
imageUploads: nextImageUploads,
|
|
213
|
-
isOnline: nextIsOnline,
|
|
214
|
-
} = nextProps;
|
|
215
|
-
|
|
216
|
-
const isOnlineEqual = prevIsOnline === nextIsOnline;
|
|
217
|
-
|
|
218
|
-
if (!isOnlineEqual) {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const enableOfflineSupportEqual = prevEnableOfflineSupport === nextEnableOfflineSupport;
|
|
223
|
-
|
|
224
|
-
if (!enableOfflineSupportEqual) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
205
|
+
const { imageUploads: prevImageUploads } = prevProps;
|
|
206
|
+
const { imageUploads: nextImageUploads } = nextProps;
|
|
227
207
|
|
|
228
|
-
|
|
208
|
+
return (
|
|
229
209
|
prevImageUploads.length === nextImageUploads.length &&
|
|
230
210
|
prevImageUploads.every(
|
|
231
211
|
(prevImageUpload, index) => prevImageUpload.state === nextImageUploads[index].state,
|
|
232
|
-
)
|
|
233
|
-
|
|
234
|
-
if (!imageUploadsEqual) {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return true;
|
|
212
|
+
)
|
|
213
|
+
);
|
|
239
214
|
};
|
|
240
215
|
|
|
241
216
|
const MemoizedImageUploadPreviewWithContext = React.memo(
|
|
@@ -251,13 +226,13 @@ export const ImageUploadPreview = <
|
|
|
251
226
|
>(
|
|
252
227
|
props: ImageUploadPreviewProps<StreamChatGenerics>,
|
|
253
228
|
) => {
|
|
254
|
-
const { enableOfflineSupport
|
|
229
|
+
const { enableOfflineSupport } = useChatContext<StreamChatGenerics>();
|
|
255
230
|
const { imageUploads, removeImage, uploadImage } = useMessageInputContext<StreamChatGenerics>();
|
|
256
231
|
|
|
257
232
|
return (
|
|
258
233
|
<MemoizedImageUploadPreviewWithContext
|
|
259
234
|
{...{ imageUploads, removeImage, uploadImage }}
|
|
260
|
-
{...{ enableOfflineSupport
|
|
235
|
+
{...{ enableOfflineSupport }}
|
|
261
236
|
{...props}
|
|
262
237
|
/>
|
|
263
238
|
);
|
package/src/components/index.ts
CHANGED
|
@@ -108,7 +108,7 @@ export * from './Message/MessageSimple/MessageTextContainer';
|
|
|
108
108
|
export * from './Message/MessageSimple/ReactionList';
|
|
109
109
|
export * from './Message/MessageSimple/utils/renderText';
|
|
110
110
|
export * from './Message/utils/messageActions';
|
|
111
|
-
export * from '
|
|
111
|
+
export * from '../utils/removeReservedFields';
|
|
112
112
|
|
|
113
113
|
export * from './MessageInput/AttachButton';
|
|
114
114
|
export * from './MessageInput/CommandsButton';
|
|
@@ -38,6 +38,7 @@ import type { UploadProgressIndicatorProps } from '../../components/MessageInput
|
|
|
38
38
|
import type { MessageType } from '../../components/MessageList/hooks/useMessageList';
|
|
39
39
|
import { compressImage, getLocalAssetUri, pickDocument } from '../../native';
|
|
40
40
|
import type { Asset, DefaultStreamChatGenerics, File, UnknownType } from '../../types/types';
|
|
41
|
+
import { removeReservedFields } from '../../utils/removeReservedFields';
|
|
41
42
|
import {
|
|
42
43
|
ACITriggerSettings,
|
|
43
44
|
ACITriggerSettingsParams,
|
|
@@ -490,21 +491,20 @@ export const MessageInputProvider = <
|
|
|
490
491
|
return true;
|
|
491
492
|
}
|
|
492
493
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
return false;
|
|
494
|
+
const imagesAndFiles = [...imageUploads, ...fileUploads];
|
|
495
|
+
if (enableOfflineSupport) {
|
|
496
|
+
// Allow only if none of the attachments have unsupported status
|
|
497
|
+
for (const file of imagesAndFiles) {
|
|
498
|
+
if (file.state === FileState.NOT_SUPPORTED) {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
501
|
}
|
|
502
502
|
|
|
503
503
|
return true;
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
for (const file of
|
|
507
|
-
if (
|
|
506
|
+
for (const file of imagesAndFiles) {
|
|
507
|
+
if (!file || file.state === FileState.UPLOAD_FAILED) {
|
|
508
508
|
continue;
|
|
509
509
|
}
|
|
510
510
|
if (file.state === FileState.UPLOADING) {
|
|
@@ -623,6 +623,62 @@ export const MessageInputProvider = <
|
|
|
623
623
|
setText('');
|
|
624
624
|
};
|
|
625
625
|
|
|
626
|
+
const mapImageUploadToAttachment = (image: ImageUpload) => {
|
|
627
|
+
const mime_type: string | boolean = lookup(image.file.filename as string);
|
|
628
|
+
return {
|
|
629
|
+
fallback: image.file.name,
|
|
630
|
+
image_url: image.url,
|
|
631
|
+
mime_type: mime_type ? mime_type : undefined,
|
|
632
|
+
original_height: image.height,
|
|
633
|
+
original_width: image.width,
|
|
634
|
+
originalFile: image.file,
|
|
635
|
+
type: 'image',
|
|
636
|
+
} as Attachment;
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
const mapFileUploadToAttachment = (file: FileUpload) => {
|
|
640
|
+
const mime_type: string | boolean = lookup(file.file.name as string);
|
|
641
|
+
if (file.file.type?.startsWith('image/')) {
|
|
642
|
+
return {
|
|
643
|
+
fallback: file.file.name,
|
|
644
|
+
image_url: file.url,
|
|
645
|
+
mime_type: mime_type ? mime_type : undefined,
|
|
646
|
+
originalFile: file.file,
|
|
647
|
+
type: 'image',
|
|
648
|
+
};
|
|
649
|
+
} else if (file.file.type?.startsWith('audio/')) {
|
|
650
|
+
return {
|
|
651
|
+
asset_url: file.url || file.file.uri,
|
|
652
|
+
duration: file.file.duration,
|
|
653
|
+
file_size: file.file.size,
|
|
654
|
+
mime_type: file.file.type,
|
|
655
|
+
originalFile: file.file,
|
|
656
|
+
title: file.file.name,
|
|
657
|
+
type: 'audio',
|
|
658
|
+
};
|
|
659
|
+
} else if (file.file.type?.startsWith('video/')) {
|
|
660
|
+
return {
|
|
661
|
+
asset_url: file.url || file.file.uri,
|
|
662
|
+
duration: file.file.duration,
|
|
663
|
+
file_size: file.file.size,
|
|
664
|
+
mime_type: file.file.type,
|
|
665
|
+
originalFile: file.file,
|
|
666
|
+
thumb_url: file.thumb_url,
|
|
667
|
+
title: file.file.name,
|
|
668
|
+
type: 'video',
|
|
669
|
+
};
|
|
670
|
+
} else {
|
|
671
|
+
return {
|
|
672
|
+
asset_url: file.url || file.file.uri,
|
|
673
|
+
file_size: file.file.size,
|
|
674
|
+
mime_type: file.file.type,
|
|
675
|
+
originalFile: file.file,
|
|
676
|
+
title: file.file.name,
|
|
677
|
+
type: 'file',
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
|
|
626
682
|
// TODO: Figure out why this is async, as it doesn't await any promise.
|
|
627
683
|
// eslint-disable-next-line require-await
|
|
628
684
|
const sendMessage = async () => {
|
|
@@ -648,6 +704,14 @@ export const MessageInputProvider = <
|
|
|
648
704
|
|
|
649
705
|
const attachments = [] as Attachment<StreamChatGenerics>[];
|
|
650
706
|
for (const image of imageUploads) {
|
|
707
|
+
if (enableOfflineSupport) {
|
|
708
|
+
if (image.state === FileState.NOT_SUPPORTED) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
attachments.push(mapImageUploadToAttachment(image));
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
|
|
651
715
|
if ((!image || image.state === FileState.UPLOAD_FAILED) && !enableOfflineSupport) {
|
|
652
716
|
continue;
|
|
653
717
|
}
|
|
@@ -667,28 +731,21 @@ export const MessageInputProvider = <
|
|
|
667
731
|
}
|
|
668
732
|
|
|
669
733
|
// To get the mime type of the image from the file name and send it as an response for an image
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
if (
|
|
673
|
-
image.state === FileState.UPLOADED ||
|
|
674
|
-
image.state === FileState.FINISHED ||
|
|
675
|
-
(enableOfflineSupport && image.state === FileState.UPLOAD_FAILED)
|
|
676
|
-
) {
|
|
677
|
-
// @ts-ignore
|
|
678
|
-
attachments.push({
|
|
679
|
-
fallback: image.file.name,
|
|
680
|
-
image_url: image.url,
|
|
681
|
-
mime_type: mime_type ? mime_type : undefined,
|
|
682
|
-
original_height: image.height,
|
|
683
|
-
original_width: image.width,
|
|
684
|
-
originalFile: image.file,
|
|
685
|
-
type: 'image',
|
|
686
|
-
});
|
|
734
|
+
if (image.state === FileState.UPLOADED || image.state === FileState.FINISHED) {
|
|
735
|
+
attachments.push(mapImageUploadToAttachment(image));
|
|
687
736
|
}
|
|
688
737
|
}
|
|
689
738
|
|
|
690
739
|
for (const file of fileUploads) {
|
|
691
|
-
if (
|
|
740
|
+
if (enableOfflineSupport) {
|
|
741
|
+
if (file.state === FileState.NOT_SUPPORTED) {
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
attachments.push(mapFileUploadToAttachment(file));
|
|
745
|
+
continue;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (!file || file.state === FileState.UPLOAD_FAILED) {
|
|
692
749
|
continue;
|
|
693
750
|
}
|
|
694
751
|
|
|
@@ -697,52 +754,9 @@ export const MessageInputProvider = <
|
|
|
697
754
|
sending.current = false;
|
|
698
755
|
return;
|
|
699
756
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
file.state === FileState.UPLOADED ||
|
|
704
|
-
file.state === FileState.FINISHED ||
|
|
705
|
-
(enableOfflineSupport && file.state === FileState.UPLOAD_FAILED)
|
|
706
|
-
) {
|
|
707
|
-
if (file.file.type?.startsWith('image/')) {
|
|
708
|
-
attachments.push({
|
|
709
|
-
fallback: file.file.name,
|
|
710
|
-
image_url: file.url,
|
|
711
|
-
mime_type: mime_type ? mime_type : undefined,
|
|
712
|
-
originalFile: file.file,
|
|
713
|
-
type: 'image',
|
|
714
|
-
});
|
|
715
|
-
} else if (file.file.type?.startsWith('audio/')) {
|
|
716
|
-
attachments.push({
|
|
717
|
-
asset_url: file.url || file.file.uri,
|
|
718
|
-
duration: file.file.duration,
|
|
719
|
-
file_size: file.file.size,
|
|
720
|
-
mime_type: file.file.type,
|
|
721
|
-
originalFile: file.file,
|
|
722
|
-
title: file.file.name,
|
|
723
|
-
type: 'audio',
|
|
724
|
-
});
|
|
725
|
-
} else if (file.file.type?.startsWith('video/')) {
|
|
726
|
-
attachments.push({
|
|
727
|
-
asset_url: file.url || file.file.uri,
|
|
728
|
-
duration: file.file.duration,
|
|
729
|
-
file_size: file.file.size,
|
|
730
|
-
mime_type: file.file.type,
|
|
731
|
-
originalFile: file.file,
|
|
732
|
-
thumb_url: file.thumb_url,
|
|
733
|
-
title: file.file.name,
|
|
734
|
-
type: 'video',
|
|
735
|
-
});
|
|
736
|
-
} else {
|
|
737
|
-
attachments.push({
|
|
738
|
-
asset_url: file.url || file.file.uri,
|
|
739
|
-
file_size: file.file.size,
|
|
740
|
-
mime_type: file.file.type,
|
|
741
|
-
originalFile: file.file,
|
|
742
|
-
title: file.file.name,
|
|
743
|
-
type: 'file',
|
|
744
|
-
});
|
|
745
|
-
}
|
|
757
|
+
|
|
758
|
+
if (file.state === FileState.UPLOADED || file.state === FileState.FINISHED) {
|
|
759
|
+
attachments.push(mapFileUploadToAttachment(file));
|
|
746
760
|
}
|
|
747
761
|
}
|
|
748
762
|
|
|
@@ -764,7 +778,12 @@ export const MessageInputProvider = <
|
|
|
764
778
|
// TODO: Remove this line and show an error when submit fails
|
|
765
779
|
value.clearEditingState();
|
|
766
780
|
|
|
767
|
-
const updateMessagePromise = value
|
|
781
|
+
const updateMessagePromise = value
|
|
782
|
+
.editMessage(
|
|
783
|
+
// @ts-ignore
|
|
784
|
+
removeReservedFields(updatedMessage),
|
|
785
|
+
)
|
|
786
|
+
.then(value.clearEditingState);
|
|
768
787
|
resetInput(attachments);
|
|
769
788
|
logChatPromiseExecution(updateMessagePromise, 'update message');
|
|
770
789
|
|
|
@@ -15,7 +15,6 @@ Object {
|
|
|
15
15
|
"type": "image",
|
|
16
16
|
},
|
|
17
17
|
],
|
|
18
|
-
"created_at": "Sat Jul 02 2022 23:55:13 GMT+0530 (India Standard Time)",
|
|
19
18
|
"html": "<p>regular</p>",
|
|
20
19
|
"id": "7a85f744-cc89-4f82-a1d4-5456432cc8bf",
|
|
21
20
|
"mentioned_users": Array [
|
|
@@ -24,8 +23,6 @@ Object {
|
|
|
24
23
|
],
|
|
25
24
|
"quoted_message": undefined,
|
|
26
25
|
"text": "",
|
|
27
|
-
"type": "regular",
|
|
28
|
-
"updated_at": "Sat Jul 02 2022 23:55:13 GMT+0530 (India Standard Time)",
|
|
29
26
|
"user": Object {
|
|
30
27
|
"banned": false,
|
|
31
28
|
"created_at": "2020-04-27T13:39:49.331742Z",
|
package/src/store/types.ts
CHANGED
|
@@ -16,7 +16,6 @@ export type PreparedQueries = [string] | [string, Array<any>];
|
|
|
16
16
|
export type PendingTaskTypes = {
|
|
17
17
|
deleteMessage: 'delete-message';
|
|
18
18
|
deleteReaction: 'delete-reaction';
|
|
19
|
-
sendMessage: 'send-message';
|
|
20
19
|
sendReaction: 'send-reaction';
|
|
21
20
|
};
|
|
22
21
|
|
|
@@ -30,10 +29,6 @@ export type PendingTask = {
|
|
|
30
29
|
payload: Parameters<Channel['sendReaction']>;
|
|
31
30
|
type: PendingTaskTypes['sendReaction'];
|
|
32
31
|
}
|
|
33
|
-
| {
|
|
34
|
-
payload: Parameters<Channel['sendMessage']>;
|
|
35
|
-
type: PendingTaskTypes['sendMessage'];
|
|
36
|
-
}
|
|
37
32
|
| {
|
|
38
33
|
payload: Parameters<StreamChat['deleteMessage']>;
|
|
39
34
|
type: PendingTaskTypes['deleteMessage'];
|
|
@@ -208,7 +208,7 @@ export class DBSyncManager {
|
|
|
208
208
|
}
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
-
dropPendingTasks = (conditions: { messageId: string }) => {
|
|
211
|
+
static dropPendingTasks = (conditions: { messageId: string }) => {
|
|
212
212
|
const tasks = getPendingTasks(conditions);
|
|
213
213
|
|
|
214
214
|
for (const task of tasks) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { MessageType } from '../components/MessageList/hooks/useMessageList';
|
|
2
|
+
import type { DefaultStreamChatGenerics } from '../types/types';
|
|
3
3
|
|
|
4
4
|
export const removeReservedFields = <
|
|
5
5
|
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
|
|
@@ -12,7 +12,11 @@ export const removeReservedFields = <
|
|
|
12
12
|
'config',
|
|
13
13
|
'created_at',
|
|
14
14
|
'created_by',
|
|
15
|
-
'
|
|
15
|
+
'deleted_at',
|
|
16
|
+
'i18n',
|
|
17
|
+
'latest_reactions',
|
|
18
|
+
'own_reactions',
|
|
19
|
+
'reaction_counts',
|
|
16
20
|
'last_message_at',
|
|
17
21
|
'member_count',
|
|
18
22
|
'type',
|
package/src/utils/utils.ts
CHANGED
|
@@ -64,15 +64,16 @@ type IndicatorStatesMap = Record<ValueOf<typeof FileState>, Progress | null>;
|
|
|
64
64
|
|
|
65
65
|
export const getIndicatorTypeForFileState = (
|
|
66
66
|
fileState: FileStateValue,
|
|
67
|
-
isOnline: boolean,
|
|
68
67
|
enableOfflineSupport: boolean,
|
|
69
68
|
): Progress | null => {
|
|
70
69
|
const indicatorMap: IndicatorStatesMap = {
|
|
71
|
-
[FileState.UPLOADING]:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
[FileState.UPLOADING]: enableOfflineSupport
|
|
71
|
+
? ProgressIndicatorTypes.INACTIVE
|
|
72
|
+
: ProgressIndicatorTypes.IN_PROGRESS,
|
|
73
|
+
// If offline support is disabled, then there is no need
|
|
74
|
+
[FileState.UPLOAD_FAILED]: enableOfflineSupport
|
|
75
|
+
? ProgressIndicatorTypes.INACTIVE
|
|
76
|
+
: ProgressIndicatorTypes.RETRY,
|
|
76
77
|
[FileState.NOT_SUPPORTED]: ProgressIndicatorTypes.NOT_SUPPORTED,
|
|
77
78
|
[FileState.UPLOADED]: ProgressIndicatorTypes.INACTIVE,
|
|
78
79
|
[FileState.FINISHED]: ProgressIndicatorTypes.INACTIVE,
|
package/src/version.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["removeReservedFields.ts"],"names":["removeReservedFields","message","retryMessage","reserved","forEach","key"],"mappings":";;;;;;;;;AAGO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,CAGlCC,OAHkC,EAI/B;AACH,MAAMC,YAAY,iCAAQD,OAAR,CAAlB;AACA,MAAME,QAAQ,GAAG,CACf,KADe,EAEf,QAFe,EAGf,YAHe,EAIf,YAJe,EAKf,IALe,EAMf,iBANe,EAOf,cAPe,EAQf,MARe,EASf,YATe,CAAjB;AAWAA,EAAAA,QAAQ,CAACC,OAAT,CAAiB,UAACC,GAAD,EAAS;AACxB,WAAOH,YAAY,CAACG,GAAD,CAAnB;AACD,GAFD;AAIA,SAAOH,YAAP;AACD,CAtBM","sourcesContent":["import type { DefaultStreamChatGenerics } from '../../../types/types';\nimport type { MessageType } from '../../MessageList/hooks/useMessageList';\n\nexport const removeReservedFields = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n message: MessageType<StreamChatGenerics>,\n) => {\n const retryMessage = { ...message };\n const reserved = [\n 'cid',\n 'config',\n 'created_at',\n 'created_by',\n 'id',\n 'last_message_at',\n 'member_count',\n 'type',\n 'updated_at',\n ];\n reserved.forEach((key) => {\n delete retryMessage[key];\n });\n\n return retryMessage;\n};\n"]}
|