Skip to content

Commit aacb0e5

Browse files
authored
Fix/qa 2nd (#30)
* skip: renamed newMessagesFromNext to newMessagesFromMembers * skip: remove appVersion from props * skip: edit script * fix(android): flipper path * fix(foundation): dynamic import fast-image * fix(uikit): reconnect binding * skip * fix(utils): remove react-native dependency * feat: added dynamic module concept code * feat: added netinfo * fix: ios media save when file doesn't have extension * docs: update README * fix: [QM-1683] disabled on pending message * skip * docs(README): update badge * chore: remove lerna allowBranch * docs: update badge color on README * docs: update opensource guidelines. * chore: update sendbird sdk
1 parent c29a87f commit aacb0e5

File tree

38 files changed

+414
-124
lines changed

38 files changed

+414
-124
lines changed

OPENSOURCE_GUIDELINES.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Sendbird UIKit Open Source Guidelines
2+
3+
Sendbird is excited to share UIKit to the open source community in order to speed up the go-to-market strategy for our customers. We’ve already seen how UIKit enables you to go to market with ease, but now we want to provide you with the flexibility to fine tune UIKit for your own market needs.
4+
5+
This community guideline outlines Sendbird’s stance on open source and explains how you can take advantage of UIKit’s open source.
6+
7+
* We recommend you to use UIKit open source only if the standard UIKit SDK does not suit your use case. This includes if you’d like to use a Sendbird Chat SDK feature that is currently unavailable in UIKit.
8+
* We will provide limited support should you choose to use our open source code and fork it (clone and edit the code in your own repository) because we won’t be able to transparently understand the code.
9+
* We don’t accept direct contributions to the source code. If you discover a bug or would like to suggest improvements to the source code, you can share them in the [Sendbird Community UIKit forum](https://community.sendbird.com/c/sendbird-chat-uikit/)).
10+
11+
_UIKit is licensed under the MIT open source license_

README.md

+91-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,106 @@
11
# sendbird-uikit-react-native
22

3-
uikit
3+
[![Platform React-Native](https://img.shields.io/badge/Platform-React--Native-orange.svg)](https://reactnative.dev/)
4+
[![Language TypeScript](https://img.shields.io/badge/Language-TypeScript-orange.svg)](https://www.typescriptlang.org/)
45

5-
[![Status_Build](https://github.com/sendbird/sendbird-uikit-react-native/actions/workflows/status-build.yml/badge.svg)](https://github.com/sendbird/sendbird-uikit-react-native/actions/workflows/status-build.yml)
6-
[![Status_Test](https://github.com/sendbird/sendbird-uikit-react-native/actions/workflows/status-test.yml/badge.svg)](https://github.com/sendbird/sendbird-uikit-react-native/actions/workflows/status-test.yml)
6+
## Requirements
77

8-
---
8+
- Nodejs 14 or newer
9+
- Watchman
10+
- JDK 11 or newer
11+
- XCode
12+
- Android Studio
13+
14+
More details, please see https://reactnative.dev/docs/environment-setup
15+
16+
<br/>
17+
18+
## Development
19+
20+
We tried development on macOS / Linux systems. You might encounter problems in running sample or scripts like `yarn build` in Windows machines. We are using sample app for development, you can check the sample app [here](/sample) and also check the UI components via storybook in the sample app.
21+
22+
### Run sample app
23+
24+
```shell
25+
yarn install
26+
npx pod-install
27+
28+
yarn sample:android
29+
yarn sample:ios
30+
```
31+
32+
### Creating a new key function files
33+
34+
Run the script and enter the key function name as a lower camel case like `groupChannel`, and then you can see the auto generated files in the `/packages/uikit-react-native/src/domain`
35+
36+
```shell
37+
yarn workspace @sendbird/uikit-react-native run create-domain
38+
```
39+
40+
### Managing repository
41+
42+
> **Note**
43+
> We are using [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces) and [lerna](https://github.com/lerna/lerna) to maintain this monorepo
44+
45+
#### Package dependencies
46+
47+
See [yarn workspace](https://classic.yarnpkg.com/en/docs/cli/workspace)
48+
49+
```shell
50+
# Add dependency to specific workspace package
51+
yarn workspace @sendbird/package add package-name
52+
# Remove dependency from specific workspace package
53+
yarn workspace @sendbird/package remove package-name
54+
55+
# Add dependency to root
56+
yarn workspace -W add package-name
57+
```
58+
59+
> **Warning** You should better install to root if you're trying to install native view modules.
60+
> Sometimes native view module in the workspace is not hoisted, and it leads to `Tried to register two views` error on the sample app.
61+
62+
#### Bump version
63+
64+
See [lerna version](https://github.com/lerna/lerna/tree/main/commands/version)
65+
66+
```shell
67+
lerna version {major|minor|patch} [--no-git-tag-version] [--no-private]
68+
69+
# or
70+
71+
yarn bump:{major|minor|patch}
72+
```
73+
74+
#### Publish
75+
76+
See [lerna publish](https://github.com/lerna/lerna/tree/main/commands/publish)
77+
78+
<br/>
979

1080
## Scripts
1181

12-
### Lint & Prettier
82+
### Build
1383

14-
- check: `yarn lint`
15-
- fix: `yarn fix`
84+
```shell
85+
yarn build
86+
```
1687

1788
### Test
1889

19-
- test: `yarn test`
90+
```shell
91+
# Unit test
92+
yarn test
2093

21-
### Package dependencies
94+
# Build test
95+
yarn test:build
96+
```
2297

23-
- add: `yarn workspace @sendbird/package add some-package`
24-
- remove: `yarn workspace @sendbird/package remove some-package`
98+
### Lint and Prettier
2599

26-
### Publish
27-
> Bump > Build > Deploy
100+
```shell
101+
# Check formatting
102+
yarn lint
28103

29-
- bump script: `lerna version {major|minor|patch} [--no-git-tag-version] [--no-private]` or `yarn bump:{major|minor|patch}`
30-
- build script: `yarn build`
104+
# Fix formatting
105+
yarn fix
106+
```

lerna.json

-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@
88
"version": "0.1.2",
99
"command": {
1010
"publish": {
11-
"allowBranch": "main",
1211
"conventionalCommits": true,
1312
"createRelease": "github",
1413
"message": "chore(release): publish %v"
1514
},
1615
"version": {
17-
"allowBranch": [
18-
"main",
19-
"*/lerna"
20-
],
2116
"conventionalCommits": true,
2217
"exact": true,
2318
"gitRemote": "origin",

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"postinstall": "patch-package",
2121
"prepare": "lerna run --stream --sort prepare",
2222
"reset": "find . -type dir -name node_modules | xargs rm -rf",
23-
"clean": "rm -rf docs && lerna run clean",
23+
"clean": "lerna run clean",
2424
"build": "lerna run build",
2525
"docs": "yarn build && typedoc --out docs --entryPointStrategy packages 'packages/*' && yarn clean",
2626
"test": "jest --verbose",
@@ -58,6 +58,7 @@
5858
"react": "17.0.2",
5959
"react-native": "0.66.4",
6060
"react-native-builder-bob": "^0.18.2",
61+
"react-native-fast-image": "^8.5.11",
6162
"react-native-safe-area-context": "^3.3.2",
6263
"react-test-renderer": "^17.0.2",
6364
"typedoc": "^0.23.7",

packages/uikit-chat-hooks/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ React custom hooks with Sendbird Chat SDK v3, made for UIKit
55
## Installation
66

77
```sh
8-
npm install @sendbird/uikit-chat-hooks
8+
npm i @sendbird/uikit-chat-hooks
99
```

packages/uikit-chat-hooks/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
"peerDependencies": {
4949
"react": ">=16.13.1",
50-
"sendbird": "^3.1.21"
50+
"sendbird": "^3.1.22"
5151
},
5252
"react-native-builder-bob": {
5353
"source": "src",

packages/uikit-chat-hooks/src/channel/useGroupChannelMessages/reducer.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { useMemo, useReducer } from 'react';
1+
import { useReducer } from 'react';
22

33
import type {
44
SendbirdBaseMessage,
55
SendbirdFileMessage,
66
SendbirdMessage,
77
SendbirdUserMessage,
88
} from '@sendbird/uikit-utils';
9-
import { arrayToMapWithGetter, getMessageUniqId, isMyMessage, isNewMessage } from '@sendbird/uikit-utils';
9+
import { arrayToMapWithGetter, getMessageUniqId, isMyMessage, isNewMessage, useIIFE } from '@sendbird/uikit-utils';
1010

1111
import type { UseGroupChannelMessagesOptions } from '../../types';
1212

@@ -110,12 +110,12 @@ export const useGroupChannelMessagesReducer = (
110110
dispatch({ type: 'update_refreshing', value: { status } });
111111
};
112112

113-
const messages = useMemo(() => {
113+
const messages = useIIFE(() => {
114114
if (sortComparator) return Object.values(messageMap).sort(sortComparator);
115115
return Object.values(messageMap);
116-
}, [sortComparator, messageMap]);
117-
const nextMessages = useMemo(() => Object.values(nextMessageMap), [nextMessageMap]);
118-
const newMessagesFromNext = useMemo(() => nextMessages.filter((msg) => isNewMessage(msg, userId)), [nextMessages]);
116+
});
117+
const nextMessages = Object.values(nextMessageMap);
118+
const newMessagesFromMembers = nextMessages.filter((msg) => isNewMessage(msg, userId));
119119

120120
return {
121121
updateLoading,
@@ -129,6 +129,6 @@ export const useGroupChannelMessagesReducer = (
129129
refreshing,
130130
messages,
131131
nextMessages,
132-
newMessagesFromNext,
132+
newMessagesFromMembers,
133133
};
134134
};

packages/uikit-chat-hooks/src/channel/useGroupChannelMessages/useGroupChannelMessagesWithCollection.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const useGroupChannelMessagesWithCollection: UseGroupChannelMessages = (s
4949
refreshing,
5050
messages,
5151
nextMessages,
52-
newMessagesFromNext,
52+
newMessagesFromMembers,
5353
updateMessages,
5454
updateNextMessages,
5555
deleteNextMessages,
@@ -301,7 +301,7 @@ export const useGroupChannelMessagesWithCollection: UseGroupChannelMessages = (s
301301
refresh,
302302
messages,
303303
nextMessages,
304-
newMessagesFromNext,
304+
newMessagesFromMembers,
305305
next,
306306
prev,
307307
sendUserMessage,

packages/uikit-chat-hooks/src/channel/useGroupChannelMessages/useGroupChannelMessagesWithQuery.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const useGroupChannelMessagesWithQuery: UseGroupChannelMessages = (sdk, c
3636
refreshing,
3737
messages,
3838
nextMessages,
39-
newMessagesFromNext,
39+
newMessagesFromMembers,
4040
updateMessages,
4141
updateNextMessages,
4242
deleteNextMessages,
@@ -237,7 +237,7 @@ export const useGroupChannelMessagesWithQuery: UseGroupChannelMessages = (sdk, c
237237
refresh,
238238
messages,
239239
nextMessages,
240-
newMessagesFromNext,
240+
newMessagesFromMembers,
241241
next,
242242
prev,
243243
sendUserMessage,

packages/uikit-chat-hooks/src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export interface UseGroupChannelMessages {
127127
* - Not updated message
128128
* - Not current user's message
129129
* */
130-
newMessagesFromNext: SendbirdMessage[];
130+
newMessagesFromMembers: SendbirdMessage[];
131131

132132
/**
133133
* Fetch next messages to state

packages/uikit-react-native-foundation/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Sendbird UIKit foundation library for React-Native
55
## Installation
66

77
```sh
8-
npm install @sendbird/uikit-react-native-foundation react-native-safe-area-context
8+
npm i @sendbird/uikit-react-native-foundation react-native-safe-area-context
99
```
1010

11-
(Optional) if you want use react-native-fast-image
11+
(Optional) If you want use [`react-native-fast-image`](https://github.com/DylanVann/react-native-fast-image) instead of default Image component
1212

1313
```sh
14-
npm install react-native-fast-image
14+
npm i react-native-fast-image
1515
```

packages/uikit-react-native-foundation/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"peerDependencies": {
5353
"react": ">=16.13.1",
5454
"react-native": ">=0.63.3",
55+
"react-native-fast-image": "^8.5.11",
5556
"react-native-safe-area-context": "^3.3.2"
5657
},
5758
"peerDependenciesMeta": {

packages/uikit-react-native-foundation/src/components/Image/Image.fastimage.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import FastImage, { FastImageProps, ResizeMode, Source } from 'react-native-fast-image';
2+
import _FastImage, { FastImageProps, ResizeMode, Source } from 'react-native-fast-image';
33

44
import type { SendbirdImageComponent, SendbirdImageProps } from './index';
55

@@ -45,6 +45,9 @@ function convertResizeMode(mode?: SendbirdImageProps['resizeMode']): ResizeMode
4545
return undefined;
4646
}
4747
}
48+
49+
const FastImage = _FastImage as (props: FastImageProps) => JSX.Element;
50+
4851
const Image_FastImage: SendbirdImageComponent = ({ source, resizeMode, onLoad, onError, style, ...props }) => {
4952
return (
5053
<FastImage

packages/uikit-react-native-foundation/src/components/Image/Image.reactnative.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { Image } from 'react-native';
33

44
import type { SendbirdImageComponent } from './index';
55

6-
const Image_ReactNative: SendbirdImageComponent = ({ onLoad, onError, ...props }) => {
6+
const Image_ReactNative: SendbirdImageComponent = ({ onLoad, onError, style, tintColor, ...props }) => {
77
return (
88
<Image
99
{...props}
10+
style={[style, { tintColor }]}
1011
onError={onError && ((e) => onError(e.nativeEvent))}
1112
onLoad={onLoad && ((e) => onLoad(e.nativeEvent.source))}
1213
/>

packages/uikit-react-native-foundation/src/components/Image/index.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ import { NativeModules } from 'react-native';
55
export interface SendbirdImageProps extends Omit<NativeImageProps, 'onLoad' | 'onError'> {
66
onLoad?: (event: { width: number; height: number }) => void;
77
onError?: (event: { error?: unknown }) => void;
8+
tintColor?: string;
89
}
910

1011
export type SendbirdImageComponent = React.FC<SendbirdImageProps>;
1112

1213
function getImageModule(): SendbirdImageComponent {
13-
const hasFastImage = Boolean(NativeModules.FastImageView) && Boolean(require('react-native-fast-image'));
14+
const hasFastImage = Boolean(NativeModules.FastImageView);
1415
if (hasFastImage) {
15-
return require('./Image.fastimage').default;
16+
try {
17+
require('react-native-fast-image');
18+
return require('./Image.fastimage').default;
19+
} catch (e) {
20+
return require('./Image.reactnative').default;
21+
}
1622
} else {
1723
return require('./Image.reactnative').default;
1824
}

0 commit comments

Comments
 (0)