Skip to content

Commit 1db08a2

Browse files
committed
fix: remove inverted list android workaround
1 parent bb61233 commit 1db08a2

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

package/src/components/MessageList/MessageList.tsx

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
22
import {
33
FlatListProps,
44
FlatList as FlatListType,
5-
Platform,
65
ScrollViewProps,
76
StyleSheet,
87
View,
@@ -739,9 +738,6 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
739738
// eslint-disable-next-line react-hooks/exhaustive-deps
740739
}, [targetedMessage]);
741740

742-
// TODO: do not apply on RN 0.73 and above
743-
const shouldApplyAndroidWorkaround = inverted && Platform.OS === 'android';
744-
745741
const renderItem = useCallback(
746742
({ index, item: message }: { index: number; item: LocalMessage }) => {
747743
if (!channel || channel.disconnected || (!channel.initialized && !channel.offlineMode)) {
@@ -785,10 +781,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
785781
);
786782

787783
return (
788-
<View
789-
style={[shouldApplyAndroidWorkaround ? styles.invertAndroid : undefined]}
790-
testID={`message-list-item-${index}`}
791-
>
784+
<View testID={`message-list-item-${index}`}>
792785
{message.type === 'system' ? (
793786
<MessageSystem
794787
message={message}
@@ -832,7 +825,6 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
832825
myMessageTheme,
833826
onThreadSelect,
834827
screenPadding,
835-
shouldApplyAndroidWorkaround,
836828
shouldShowUnreadUnderlay,
837829
threadList,
838830
],
@@ -1153,30 +1145,26 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
11531145

11541146
const ListFooterComponent = useCallback(
11551147
() => (
1156-
<View style={shouldApplyAndroidWorkaround ? styles.invertAndroid : undefined}>
1148+
<View>
11571149
<FooterComponent />
11581150
</View>
11591151
),
1160-
[shouldApplyAndroidWorkaround, FooterComponent],
1152+
[FooterComponent],
11611153
);
11621154

11631155
const ListHeaderComponent = useCallback(
11641156
() => (
1165-
<View style={shouldApplyAndroidWorkaround ? styles.invertAndroid : undefined}>
1157+
<View>
11661158
<HeaderComponent />
11671159
</View>
11681160
),
1169-
[shouldApplyAndroidWorkaround, HeaderComponent],
1161+
[HeaderComponent],
11701162
);
11711163

11721164
const ItemSeparatorComponent = additionalFlatListProps?.ItemSeparatorComponent;
11731165
const WrappedItemSeparatorComponent = useCallback(
1174-
() => (
1175-
<View style={[shouldApplyAndroidWorkaround ? styles.invertAndroid : undefined]}>
1176-
{ItemSeparatorComponent ? <ItemSeparatorComponent /> : null}
1177-
</View>
1178-
),
1179-
[ItemSeparatorComponent, shouldApplyAndroidWorkaround],
1166+
() => <View>{ItemSeparatorComponent ? <ItemSeparatorComponent /> : null}</View>,
1167+
[ItemSeparatorComponent],
11801168
);
11811169

11821170
// We need to omit the style related props from the additionalFlatListProps and add them directly instead of spreading
@@ -1195,13 +1183,8 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
11951183
}
11961184

11971185
const flatListStyle = useMemo(
1198-
() => [
1199-
styles.listContainer,
1200-
listContainer,
1201-
additionalFlatListProps?.style,
1202-
shouldApplyAndroidWorkaround ? styles.invertAndroid : undefined,
1203-
],
1204-
[additionalFlatListProps?.style, listContainer, shouldApplyAndroidWorkaround],
1186+
() => [styles.listContainer, listContainer, additionalFlatListProps?.style],
1187+
[additionalFlatListProps?.style, listContainer],
12051188
);
12061189

12071190
const flatListContentContainerStyle = useMemo(
@@ -1241,7 +1224,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
12411224
/** Disables the MessageList UI. Which means, message actions, reactions won't work. */
12421225
data={processedMessageList}
12431226
extraData={disabled}
1244-
inverted={shouldApplyAndroidWorkaround ? false : inverted}
1227+
inverted={inverted}
12451228
ItemSeparatorComponent={WrappedItemSeparatorComponent}
12461229
keyboardShouldPersistTaps='handled'
12471230
keyExtractor={keyExtractor}
@@ -1264,7 +1247,7 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
12641247
onViewableItemsChanged={stableOnViewableItemsChanged}
12651248
ref={refCallback}
12661249
renderItem={renderItem}
1267-
showsVerticalScrollIndicator={!shouldApplyAndroidWorkaround}
1250+
showsVerticalScrollIndicator={false}
12681251
style={flatListStyle}
12691252
testID='message-flat-list'
12701253
viewabilityConfig={flatListViewabilityConfig}

0 commit comments

Comments
 (0)