Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expo 36 support and some more stuff #102

Merged
merged 11 commits into from
Dec 24, 2019
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [0.5.0] 2019-12-23

#### stream-chat-expo (Expo package)

- Changes to add compatibility for Expo 36. Adding [netinfo](https://github.com/react-native-community/react-native-netinfo) as peer dependency - https://github.com/GetStream/stream-chat-react-native/issues/97
- Disabling the longpress on image viewer (in Attachment) - https://github.com/GetStream/stream-chat-react-native/issues/100 to avoid freezing of UI.
- Fixing broken threads issue

#### stream-chat-react-native (Native package)

- Disabling the longpress on image viewer (in Attachment) - https://github.com/GetStream/stream-chat-react-native/issues/100 to avoid freezing of UI.
- Fixing broken threads issue

## [0.4.0] 2019-12-16

- Adding support for customizing markdown styles - https://github.com/GetStream/stream-chat-react-native/pull/99/files#diff-ede54911d9164ea37e65e92f2e18cb91R56
Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,20 @@ yarn global add expo-cli
# * >=12.0.0 (Current Release)
expo init StreamChatExpoExample
cd StreamChatExpoExample

# Add chat expo package
yarn add stream-chat-expo

# If you are using stream-chat-expo <= 0.4.0 and expo <= 34, then you don't need to add @react-native-community/netinfo as dependency. Since previously we used use NetInfo from react-native package.
yarn add @react-native-community/netinfo
```

Please check [Example](https://github.com/GetStream/stream-chat-react-native/blob/master/examples/one/App.js) to see usage of the components.
Please check [Example](https://github.com/GetStream/stream-chat-react-native/blob/master/examples/ExpoMessaging/App.js) to see usage of the components.

OR you can swap [this file](https://github.com/GetStream/stream-chat-react-native/blob/master/examples/one/App.js) for your `App.js` in the root folder with additional following steps:
OR you can swap [this file](https://github.com/GetStream/stream-chat-react-native/blob/master/examples/ExpoMessaging/App.js) for your `App.js` in the root folder with additional following steps:

```bash
yarn add react-navigation
yarn add react-navigation@3.2.1 react-native-gesture-handler react-native-reanimated
```

and finally
Expand Down Expand Up @@ -146,7 +151,7 @@ react-native link react-native-document-picker

```

Please check [Example](https://github.com/GetStream/stream-chat-react-native/blob/master/examples/two/App.js) to see usage of components.
Please check [Example](https://github.com/GetStream/stream-chat-react-native/blob/master/examples/NativeMessaging/App.js) to see usage of components.

OR you can swap this file for your `App.js` in root folder with additional following steps:

Expand Down Expand Up @@ -184,7 +189,7 @@ Just to be sure, please verify you are using appropriate version of following pa

- react-native-image-picker : https://github.com/react-native-community/react-native-image-picker#react-native-compatibility

Please check [Example](https://github.com/GetStream/stream-chat-react-native/blob/master/examples/two/App.js) to see usage of components.
Please check [Example](https://github.com/GetStream/stream-chat-react-native/blob/master/examples/NativeMessaging/App.js) to see usage of components.

OR you can swap this file for your `App.js` in root folder with additional following steps:

Expand Down Expand Up @@ -248,7 +253,7 @@ In current context, dependencies such as `react-native-document-picker` and (if
1. When you execute `react-native run-ios` for the first time, it starts a metro bundler in parallel. It can result into some errors, since build process isn't complete yet. Try the following to fix this:
1. Close/stop the metro bundler process.
2. Let the build process finish completely, it can take usually around 2-3 minutes for the first time.
3. Start the metro bundler manually by executing `yarn start` inside `stream-chat-react-native/examples/two` directory.
3. Start the metro bundler manually by executing `yarn start` inside `stream-chat-react-native/examples/NativeMessaging` directory.
2. When you execute `react-native run-android`, you may (not necessarily) run into following error:

```ERROR
Expand Down Expand Up @@ -277,9 +282,9 @@ In current context, dependencies such as `react-native-document-picker` and (if

To resolve this, do the following

1. Craete a file named `local.properties` inside `stream-chat-react-native/examples/two/android` directory
1. Craete a file named `local.properties` inside `stream-chat-react-native/examples/NativeMessaging/android` directory
2. Put the this line in that file. Make sure sdk path is correctly mentioned as per your system:
```
sdk.dir=/Users/{user_name}/Library/Android/sdk/
```
3. Rerun `react-native run-android` in `stream-chat-react-native/examples/two` directory
3. Rerun `react-native run-android` in `stream-chat-react-native/examples/NativeMessaging` directory
2 changes: 1 addition & 1 deletion examples/ExpoMessaging/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const theme = {
`,
},
};


const filters = { type: 'messaging' };
const sort = { last_message_at: -1 };
Expand Down
3 changes: 2 additions & 1 deletion expo-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"stream-chat-react-native-core": "v0.4.0"
},
"peerDependencies": {
"expo": "^32.0.0"
"expo": "^32.0.0",
"@react-native-community/netinfo": ">=2.0.7"
}
}
1 change: 1 addition & 0 deletions expo-package/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const normalBundle = {
'expo-document-picker',
'expo-permissions',
'react-native-unimodules',
'@react-native-community/netinfo',
],
plugins: [
replace({
Expand Down
36 changes: 28 additions & 8 deletions expo-package/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* And they have been removed from Expo package. But these packages don't work with Expo 32 sdk (because of linking issue).
*/
import { registerNativeHandlers } from 'stream-chat-react-native-core';
import { NetInfo } from 'react-native';
import NetInfo from '@react-native-community/netinfo';
import { Constants } from 'react-native-unimodules';
import * as Expo from 'expo';

Expand All @@ -30,18 +30,38 @@ if (manifest.sdkVersion.split('.')[0] >= 33) {
registerNativeHandlers({
NetInfo: {
addEventListener(listener) {
const unsubscribe = NetInfo.addEventListener('connectionChange', () => {
NetInfo.isConnected.fetch().then((isConnected) => {
let unsubscribe;
// For NetInfo >= 3.x.x
if (NetInfo.fetch && typeof NetInfo.fetch === 'function') {
unsubscribe = NetInfo.addEventListener(({ isConnected }) => {
listener(isConnected);
});
});
return unsubscribe.remove;
return unsubscribe;
} else {
// For NetInfo < 3.x.x
unsubscribe = NetInfo.addEventListener('connectionChange', () => {
NetInfo.isConnected.fetch().then((isConnected) => {
listener(isConnected);
});
});

return unsubscribe.remove;
}
},

fetch() {
return new Promise((resolve, reject) => {
NetInfo.isConnected.fetch().then((isConnected) => {
resolve(isConnected);
}, reject);
// For NetInfo >= 3.x.x
if (NetInfo.fetch && typeof NetInfo.fetch === 'function') {
NetInfo.fetch().then(({ isConnected }) => {
resolve(isConnected);
}, reject);
} else {
// For NetInfo < 3.x.x
NetInfo.isConnected.fetch().then((isConnected) => {
resolve(isConnected);
}, reject);
}
});
},
},
Expand Down