Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #127 from pubnub/CSK-316-remove-android-hack
Browse files Browse the repository at this point in the history
fix(lib): remove inverted flatlist fix for android
  • Loading branch information
Salet authored Oct 5, 2023
2 parents c7a4eab + 8928b34 commit 6447a8e
Show file tree
Hide file tree
Showing 12 changed files with 484 additions and 1,032 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defaults:
jobs:
tests:
name: Run builtin test cases
runs-on: ubuntu-latest
runs-on: macos-13
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down
7 changes: 6 additions & 1 deletion .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
---
name: pubnub-react-chat-components
version: v0.31.0
version: v0.32.0
scm: github.com/pubnub/react-chat-components
schema: 1
files:
- lib/dist/index.js
- lib/dist/index.es.js
changelog:
- date: 2023-10-05
version: v0.32.0
changes:
- type: bug
text: "ReactNative - remove the workaround for poor performance of inverted FlatList in Android ."
- date: 2023-10-04
version: v0.31.0
changes:
Expand Down
2 changes: 1 addition & 1 deletion load-tests/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"expo-status-bar": "~1.4.2",
"react": "18.2.0",
"@pubnub/tomato": "1.7.0",
"react-native": "0.71.6",
"react-native": "0.72.4",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pubnub/common-chat-components",
"version": "0.31.0",
"version": "0.32.0",
"main": "src/index.ts",
"license": "MIT",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pubnub/react-native-chat-components",
"version": "0.31.0",
"version": "0.32.0",
"description": "PubNub Chat Components is a development kit of React Native components that aims to help you to easily build Chat applications using PubNub infrastructure. It removes the complexicity of picking an adequate Chat engine, learning its APIs and dealing with its low-level internals. As the same time it allows you to create apps of various use cases, with different functionalities and customizable looks.",
"author": "PubNub <support@pubnub.com>",
"main": "dist/commonjs/index",
Expand Down Expand Up @@ -59,7 +59,7 @@
"pubnub-react": "3.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.6",
"react-native": "0.72.4",
"react-test-renderer": "18.2.0",
"rollup": "2.79.0",
"rollup-plugin-peer-deps-external": "2.2.4",
Expand All @@ -70,7 +70,7 @@
"pubnub": ">=4.29.9",
"pubnub-react": ">=2.1.0",
"react": ">=16.8.0",
"react-native": ">=0.69.0"
"react-native": ">=0.72.4"
},
"dependencies": {
"expo-document-picker": "11.2.2",
Expand Down

This file was deleted.

This file was deleted.

14 changes: 3 additions & 11 deletions packages/react-native/src/message-list/message-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
ListRenderItem,
NativeScrollEvent,
NativeSyntheticEvent,
Platform,
Pressable,
StyleSheet,
Text,
Expand All @@ -36,9 +35,6 @@ import { EmojiPickerElementProps } from "../types";
import { useStyle, useRotation } from "../helpers";
import SpinnerIcon from "../icons/spinner.png";
import { RemoteFile } from "./remote-file";
import { doAndroidHackWorkaround } from "./android-hack-workaround";

doAndroidHackWorkaround();

export type MessageListProps = CommonMessageListProps & {
/** Option to pass in a component that will be used for picking message reactions. For more details, refer to the Message Reactions section in the docs. */
Expand Down Expand Up @@ -92,7 +88,6 @@ export const MessageList: FC<MessageListProps> = (props: MessageListProps) => {
const [spinnerShown, setSpinnerShown] = useState(false);
const [sheetPosition] = useState(new Animated.Value(0));
const shouldShownSpinner = props.fetchMessages && !paginationEnd;
const isAndroid = Platform.OS === "android";

const rotate = useRotation(shouldShownSpinner && spinnerShown);
const listRef = useRef<FlatList>(null);
Expand Down Expand Up @@ -178,8 +173,7 @@ export const MessageList: FC<MessageListProps> = (props: MessageListProps) => {
const renderItem: ListRenderItem<MessageEnvelope> = ({ item }) => {
const envelope = item;
if (envelope.timetoken === "spinner-element") return renderSpinner();
if (envelope.timetoken === "children-element")
return <View style={isAndroid && { scaleY: -1 }}>{props.children}</View>;
if (envelope.timetoken === "children-element") return <View>{props.children}</View>;
const uuid = envelope.uuid || envelope.publisher || "";
const actions = envelope.actions;
const deleted = !!Object.keys(actions?.deleted || {}).length;
Expand All @@ -193,7 +187,6 @@ export const MessageList: FC<MessageListProps> = (props: MessageListProps) => {
style.message,
props.enableReactions && pressed && style.messagePressed,
isOwn && style.messageOwn,
isAndroid && { scaleY: -1 },
]}
onLongPress={() => handleOpenReactions(envelope.timetoken)}
>
Expand Down Expand Up @@ -315,7 +308,7 @@ export const MessageList: FC<MessageListProps> = (props: MessageListProps) => {
)}
<FlatList
testID="message-list"
style={[style.messageList, isAndroid && { scaleY: -1 }]}
style={style.messageList}
contentContainerStyle={style.messageListScroller}
data={[
{ timetoken: "children-element", message: { id: "children-element" } },
Expand All @@ -327,8 +320,7 @@ export const MessageList: FC<MessageListProps> = (props: MessageListProps) => {
ref={listRef}
onEndReached={() => fetchHistory()}
onScroll={handleScroll}
// Workaround for: https://github.com/facebook/react-native/issues/30034
inverted={!isAndroid}
inverted={true}
onViewableItemsChanged={onViewableItemsChanged}
/>
{props.reactionsPicker &&
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pubnub/react-chat-components",
"version": "0.31.0",
"version": "0.32.0",
"description": "PubNub Chat Components is a development kit of React components that aims to help you to easily build Chat applications using PubNub infrastructure. It removes the complexicity of picking an adequate Chat engine, learning its APIs and dealing with its low-level internals. As the same time it allows you to create apps of various use cases, with different functionalities and customizable looks.",
"author": "PubNub <support@pubnub.com>",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion samples/react-native/getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"pubnub": "7.2.0",
"pubnub-react": "3.0.1",
"react": "18.2.0",
"react-native": "0.71.6",
"react-native": "0.72.4",
"react-native-safe-area-context": "4.5.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion samples/react-native/mobile-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"pubnub-react": "3.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.6",
"react-native": "0.72.4",
"react-native-emoji-selector": "^0.2.0",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0",
Expand Down
Loading

0 comments on commit 6447a8e

Please sign in to comment.