Skip to content

Commit a838f6c

Browse files
authored
Merge pull request #2962 from GetStream/develop
Next Release
2 parents 13f8872 + 10b4a9d commit a838f6c

File tree

6 files changed

+65
-37
lines changed

6 files changed

+65
-37
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PropsWithChildren, useCallback, useEffect, useRef, useState } from 'react';
1+
import React, { PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
22
import { KeyboardAvoidingViewProps, StyleSheet, Text, View } from 'react-native';
33

44
import debounce from 'lodash/debounce';
@@ -749,24 +749,34 @@ const ChannelWithContext = <
749749
? newMessageStateUpdateThrottleInterval
750750
: stateUpdateThrottleInterval;
751751

752-
const copyChannelState = useRef(
753-
throttle(
754-
() => {
755-
if (channel) {
756-
copyStateFromChannel(channel);
757-
copyMessagesStateFromChannel(channel);
758-
}
759-
},
760-
copyChannelStateThrottlingTime,
761-
throttleOptions,
762-
),
763-
).current;
752+
const copyChannelState = useMemo(
753+
() =>
754+
throttle(
755+
() => {
756+
if (channel) {
757+
copyStateFromChannel(channel);
758+
copyMessagesStateFromChannel(channel);
759+
}
760+
},
761+
copyChannelStateThrottlingTime,
762+
throttleOptions,
763+
),
764+
[channel, copyChannelStateThrottlingTime, copyMessagesStateFromChannel, copyStateFromChannel],
765+
);
764766

765767
const handleEvent: EventHandler<StreamChatGenerics> = (event) => {
766768
if (shouldSyncChannel) {
767-
// Ignore user.watching.start and user.watching.stop events
768-
const ignorableEvents = ['user.watching.start', 'user.watching.stop'];
769-
if (ignorableEvents.includes(event.type)) return;
769+
/**
770+
* Ignore user.watching.start and user.watching.stop as we should not copy the entire state when
771+
* they occur. Also ignore all poll related events since they're being handled in their own
772+
* reactive state and have no business having an effect on the Channel component.
773+
*/
774+
if (
775+
event.type.startsWith('poll.') ||
776+
event.type === 'user.watching.start' ||
777+
event.type === 'user.watching.stop'
778+
)
779+
return;
770780

771781
// If the event is typing.start or typing.stop, set the typing state
772782
const isTypingEvent = event.type === 'typing.start' || event.type === 'typing.stop';

package/src/components/Message/MessageSimple/MessageContent.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const styles = StyleSheet.create({
3838
borderTopLeftRadius: 16,
3939
borderTopRightRadius: 16,
4040
borderWidth: 1,
41+
overflow: 'hidden',
4142
},
4243
leftAlignContent: {
4344
justifyContent: 'flex-start',
@@ -154,6 +155,7 @@ const MessageContentWithContext = <
154155
borderRadiusS,
155156
borderTopLeftRadius,
156157
borderTopRightRadius,
158+
...container
157159
},
158160
containerInner,
159161
replyBorder,
@@ -251,7 +253,7 @@ const MessageContentWithContext = <
251253
});
252254
}
253255
}}
254-
style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1 })}
256+
style={({ pressed }) => [{ opacity: pressed ? 0.5 : 1 }, container]}
255257
{...additionalPressableProps}
256258
>
257259
<View onLayout={onLayout} style={wrapper}>

package/src/components/MessageList/MessageList.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ const MessageListWithContext = <
579579
}
580580
}
581581
// eslint-disable-next-line react-hooks/exhaustive-deps
582-
}, [rawMessageList, threadList]);
582+
}, [channel, rawMessageList, threadList]);
583583

584584
const goToMessage = async (messageId: string) => {
585585
const indexOfParentInMessageList = processedMessageList.findIndex(
@@ -1097,12 +1097,13 @@ const MessageListWithContext = <
10971097
keyboardShouldPersistTaps='handled'
10981098
keyExtractor={keyExtractor}
10991099
ListFooterComponent={ListFooterComponent}
1100+
ListHeaderComponent={ListHeaderComponent}
11001101
/**
1101-
if autoscrollToTopThreshold is 10, we scroll to recent if before new list update it was already at the bottom (10 offset or below)
1102-
minIndexForVisible = 1 means that beyond item at index 1 will not change position on list updates
1103-
minIndexForVisible is not used when autoscrollToTopThreshold = 10
1102+
If autoscrollToTopThreshold is 10, we scroll to recent only if before the update, the list was already at the
1103+
bottom (10 offset or below).
1104+
minIndexForVisible = 1 means that beyond the item at index 1 we will not change the position on list updates,
1105+
however it is not used when autoscrollToTopThreshold = 10.
11041106
*/
1105-
ListHeaderComponent={ListHeaderComponent}
11061107
maintainVisibleContentPosition={{
11071108
autoscrollToTopThreshold: autoscrollToRecent ? 10 : undefined,
11081109
minIndexForVisible: 1,

package/src/components/MessageList/hooks/useShouldScrollToRecentOnNewOwnMessage.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ export function useShouldScrollToRecentOnNewOwnMessage<
3838
}
3939
}
4040
}
41-
// eslint-disable-next-line react-hooks/exhaustive-deps
42-
}, [rawMessageList]);
41+
}, [currentUserId, rawMessageList]);
4342

4443
return isMyOwnNewMessageRef;
4544
}

package/src/components/Poll/components/PollResults/PollVote.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const PollVote = ({ vote }: { vote: PollVoteClass }) => {
4747
<Avatar image={vote.user.image as string} key={vote.id} size={20} />
4848
) : null}
4949
<Text style={[styles.voteUserName, { color: black }, userName]}>
50-
{isAnonymous ? t<string>('Anonymous') : vote.user?.name}
50+
{isAnonymous ? t<string>('Anonymous') : vote.user?.name ?? vote.user?.id}
5151
</Text>
5252
</View>
5353
<Text style={[styles.voteDate, { color: text_low_emphasis }, dateText]}>{dateString}</Text>

package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,12 @@ exports[`Thread should match thread snapshot 1`] = `
573573
onResponderTerminationRequest={[Function]}
574574
onStartShouldSetResponder={[Function]}
575575
style={
576-
{
577-
"opacity": 1,
578-
}
576+
[
577+
{
578+
"opacity": 1,
579+
},
580+
{},
581+
]
579582
}
580583
>
581584
<View
@@ -589,6 +592,7 @@ exports[`Thread should match thread snapshot 1`] = `
589592
"borderTopLeftRadius": 16,
590593
"borderTopRightRadius": 16,
591594
"borderWidth": 1,
595+
"overflow": "hidden",
592596
},
593597
{
594598
"backgroundColor": "#E9EAED",
@@ -1079,9 +1083,12 @@ exports[`Thread should match thread snapshot 1`] = `
10791083
onResponderTerminationRequest={[Function]}
10801084
onStartShouldSetResponder={[Function]}
10811085
style={
1082-
{
1083-
"opacity": 1,
1084-
}
1086+
[
1087+
{
1088+
"opacity": 1,
1089+
},
1090+
{},
1091+
]
10851092
}
10861093
>
10871094
<View
@@ -1095,6 +1102,7 @@ exports[`Thread should match thread snapshot 1`] = `
10951102
"borderTopLeftRadius": 16,
10961103
"borderTopRightRadius": 16,
10971104
"borderWidth": 1,
1105+
"overflow": "hidden",
10981106
},
10991107
{
11001108
"backgroundColor": "#E9EAED",
@@ -1623,9 +1631,12 @@ exports[`Thread should match thread snapshot 1`] = `
16231631
onResponderTerminationRequest={[Function]}
16241632
onStartShouldSetResponder={[Function]}
16251633
style={
1626-
{
1627-
"opacity": 1,
1628-
}
1634+
[
1635+
{
1636+
"opacity": 1,
1637+
},
1638+
{},
1639+
]
16291640
}
16301641
>
16311642
<View
@@ -1639,6 +1650,7 @@ exports[`Thread should match thread snapshot 1`] = `
16391650
"borderTopLeftRadius": 16,
16401651
"borderTopRightRadius": 16,
16411652
"borderWidth": 1,
1653+
"overflow": "hidden",
16421654
},
16431655
{
16441656
"backgroundColor": "#E9EAED",
@@ -2122,9 +2134,12 @@ exports[`Thread should match thread snapshot 1`] = `
21222134
onResponderTerminationRequest={[Function]}
21232135
onStartShouldSetResponder={[Function]}
21242136
style={
2125-
{
2126-
"opacity": 1,
2127-
}
2137+
[
2138+
{
2139+
"opacity": 1,
2140+
},
2141+
{},
2142+
]
21282143
}
21292144
>
21302145
<View
@@ -2138,6 +2153,7 @@ exports[`Thread should match thread snapshot 1`] = `
21382153
"borderTopLeftRadius": 16,
21392154
"borderTopRightRadius": 16,
21402155
"borderWidth": 1,
2156+
"overflow": "hidden",
21412157
},
21422158
{
21432159
"backgroundColor": "#E9EAED",

0 commit comments

Comments
 (0)