Skip to content

Commit ace7679

Browse files
committed
chore: resolve conflicts from base branch
2 parents 44c6a6d + f887ee1 commit ace7679

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

package/src/components/MessageInput/components/AttachmentPreview/ImageAttachmentUploadPreview.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const ImageAttachmentUploadPreview = ({
2323
handleRetry,
2424
removeAttachments,
2525
}: ImageAttachmentUploadPreviewProps) => {
26-
const [loading, setLoading] = useState(false);
26+
const [loading, setLoading] = useState(true);
2727
const { enableOfflineSupport } = useChatContext();
2828
const indicatorType = loading
2929
? ProgressIndicatorTypes.IN_PROGRESS
@@ -49,10 +49,6 @@ export const ImageAttachmentUploadPreview = ({
4949
setLoading(false);
5050
}, []);
5151

52-
const onLoadStartHandler = useCallback(() => {
53-
setLoading(true);
54-
}, []);
55-
5652
return (
5753
<View style={[styles.itemContainer, itemContainer]} testID={'image-attachment-upload-preview'}>
5854
<AttachmentUploadProgressIndicator
@@ -62,12 +58,12 @@ export const ImageAttachmentUploadPreview = ({
6258
>
6359
<Image
6460
onLoadEnd={onLoadEndHandler}
65-
onLoadStart={onLoadStartHandler}
6661
resizeMode='cover'
6762
source={{ uri: attachment.localMetadata.previewUri ?? attachment.image_url }}
6863
style={[styles.upload, upload]}
6964
/>
7065
</AttachmentUploadProgressIndicator>
66+
7167
<DismissAttachmentUpload onPress={onDismissHandler} />
7268
{indicatorType === ProgressIndicatorTypes.NOT_SUPPORTED ? (
7369
<AttachmentUnsupportedIndicator indicatorType={indicatorType} isImage={true} />

package/src/components/Poll/CreatePollContent.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,18 @@ export const CreatePollContent = () => {
6666

6767
useEffect(() => {
6868
if (!createPollOptionHeight) return;
69+
const newCurrentOptionPositions: CurrentOptionPositionsCache = {
70+
inverseIndexCache: {},
71+
positionCache: {},
72+
};
6973
options.forEach((option, index) => {
70-
currentOptionPositions.value = {
71-
...currentOptionPositions.value,
72-
inverseIndexCache: {
73-
...currentOptionPositions.value.inverseIndexCache,
74-
[index]: option.id,
75-
},
76-
positionCache: {
77-
...currentOptionPositions.value.positionCache,
78-
[option.id]: {
79-
updatedIndex: index,
80-
updatedTop: index * createPollOptionHeight,
81-
},
82-
},
74+
newCurrentOptionPositions.inverseIndexCache[index] = option.id;
75+
newCurrentOptionPositions.positionCache[option.id] = {
76+
updatedIndex: index,
77+
updatedTop: index * createPollOptionHeight,
8378
};
8479
});
80+
currentOptionPositions.value = newCurrentOptionPositions;
8581
}, [createPollOptionHeight, currentOptionPositions, options]);
8682

8783
const onBackPressHandler = useCallback(() => {

package/src/components/Poll/components/CreatePollOptions.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useMemo } from 'react';
1+
import React, { useCallback, useEffect, useMemo } from 'react';
22
import { StyleSheet, Text, TextInput, View } from 'react-native';
33
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
44
import Animated, {
@@ -11,6 +11,7 @@ import Animated, {
1111
useSharedValue,
1212
withDelay,
1313
withSpring,
14+
withTiming,
1415
} from 'react-native-reanimated';
1516

1617
import { PollComposerOption, PollComposerState } from 'stream-chat';
@@ -295,6 +296,19 @@ export const CreatePollOptions = ({ currentOptionPositions }: CreatePollOptionsP
295296
// this will hold id for item which user started dragging
296297
const draggedItemId = useSharedValue<string | null>(null);
297298

299+
// holds the animated height of the option container
300+
const animatedOptionsContainerHeight = useSharedValue(createPollOptionHeight * options.length);
301+
302+
useEffect(() => {
303+
animatedOptionsContainerHeight.value = withTiming(createPollOptionHeight * options.length, {
304+
duration: 200,
305+
});
306+
}, [animatedOptionsContainerHeight, createPollOptionHeight, options.length]);
307+
308+
const animatedOptionsContainerStyle = useAnimatedStyle(() => ({
309+
height: animatedOptionsContainerHeight.value,
310+
}));
311+
298312
const boundaries = useMemo(
299313
() => ({ maxBound: (options.length - 1) * createPollOptionHeight, minBound: 0 }),
300314
[createPollOptionHeight, options.length],
@@ -332,7 +346,7 @@ export const CreatePollOptions = ({ currentOptionPositions }: CreatePollOptionsP
332346
return (
333347
<View style={[styles.container, container]}>
334348
<Text style={[styles.text, { color: black }, title]}>{t<string>('Options')}</Text>
335-
<View style={{ height: createPollOptionHeight * options.length }}>
349+
<Animated.View style={animatedOptionsContainerStyle}>
336350
{options.map((option, index) => (
337351
<MemoizedCreatePollOption
338352
boundaries={boundaries}
@@ -348,7 +362,7 @@ export const CreatePollOptions = ({ currentOptionPositions }: CreatePollOptionsP
348362
option={option}
349363
/>
350364
))}
351-
</View>
365+
</Animated.View>
352366
</View>
353367
);
354368
};

package/src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ import type { MessageInputProps } from '../../components/MessageInput/MessageInp
5959
import type { MoreOptionsButtonProps } from '../../components/MessageInput/MoreOptionsButton';
6060
import type { SendButtonProps } from '../../components/MessageInput/SendButton';
6161
import { useStableCallback } from '../../hooks/useStableCallback';
62-
import { createAttachmentsCompositionMiddleware } from '../../middlewares/attachments';
62+
import {
63+
createAttachmentsCompositionMiddleware,
64+
createDraftAttachmentsCompositionMiddleware,
65+
} from '../../middlewares/attachments';
6366

6467
import { isDocumentPickerAvailable, MediaTypes, NativeHandlers } from '../../native';
6568
import { File } from '../../types/types';
@@ -480,6 +483,10 @@ export const MessageInputProvider = ({
480483
messageComposer.compositionMiddlewareExecutor.replace([
481484
createAttachmentsCompositionMiddleware(messageComposer),
482485
]);
486+
487+
messageComposer.draftCompositionMiddlewareExecutor.replace([
488+
createDraftAttachmentsCompositionMiddleware(messageComposer),
489+
]);
483490
}
484491
}, [
485492
value.doFileUploadRequest,

0 commit comments

Comments
 (0)