Skip to content

Commit 0f95259

Browse files
Revert "setting KeyboardCompatibleView initialHeight again when the layoutHeight is not equal to the new height when the keyboard is closed and setting the initial channelHeight state to a number as the types for Animated suggest removing some unused or unnecessary things"
This reverts commit ead4805.
1 parent 158588c commit 0f95259

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

docs/cookbook.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,14 +1326,11 @@ For setup regarding push notifications, first of all make sure you have followed
13261326

13271327
### Requirements
13281328

1329-
- User must be a member of channel if they expect a push notification for a message on that channel.
1329+
- User must be a member of channel, if he expects a push notification for a message on that channel.
13301330

13311331
- We only send a push notification, when user is **NOT** connected to chat, or in other words, if user does **NOT** have any active WS (websocket) connection. WS connection is established when you do
13321332

1333-
```js
1334-
await client.setUser({ id: 'user_id' })
1335-
await client.addDevice(token.token, token.os === 'ios' ? 'apn' : 'firebase')
1336-
```
1333+
`await client.setUser({ id: 'user_id' })`.
13371334

13381335
### Caveats
13391336

src/components/ChannelInner.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class ChannelInner extends PureComponent {
155155
threadMessages: [],
156156
threadLoadingMore: false,
157157
threadHasMore: true,
158+
kavEnabled: true,
158159
/** We save the events in state so that we can display event message
159160
* next to the message after which it was received, in MessageList.
160161
*
@@ -650,6 +651,8 @@ class ChannelInner extends PureComponent {
650651
this.props.disableIfFrozenChannel,
651652
});
652653

654+
renderComponent = () => this.props.children;
655+
653656
renderLoading = () => {
654657
const Indicator = this.props.LoadingIndicator;
655658
return <Indicator listType="message" />;
@@ -662,7 +665,7 @@ class ChannelInner extends PureComponent {
662665

663666
render() {
664667
let core;
665-
const { children, KeyboardCompatibleView, t } = this.props;
668+
const { KeyboardCompatibleView, t } = this.props;
666669
if (this.state.error) {
667670
this.props.logger(
668671
'Channel component',
@@ -690,7 +693,14 @@ class ChannelInner extends PureComponent {
690693
enabled={!this.props.disableKeyboardCompatibleView}
691694
>
692695
<ChannelContext.Provider value={this.getContext()}>
693-
<SuggestionsProvider>{children}</SuggestionsProvider>
696+
<SuggestionsProvider
697+
handleKeyboardAvoidingViewEnabled={(trueOrFalse) => {
698+
if (this._unmounted) return;
699+
this.setState({ kavEnabled: trueOrFalse });
700+
}}
701+
>
702+
{this.renderComponent()}
703+
</SuggestionsProvider>
694704
</ChannelContext.Provider>
695705
</KeyboardCompatibleView>
696706
);

src/components/Chat.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export const Chat = themed(
165165
this._unmounted = true;
166166
this.props.client.off('connection.recovered');
167167
this.props.client.off('connection.changed');
168+
this.props.client.off(this.handleEvent);
168169
this.unsubscribeNetInfo && this.unsubscribeNetInfo();
169170
}
170171

src/components/KeyboardCompatibleView.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class KeyboardCompatibleView extends React.PureComponent {
4242
super(props);
4343

4444
this.state = {
45-
channelHeight: new Animated.Value(Dimensions.get('window').height),
45+
channelHeight: new Animated.Value('100%'),
4646
// For some reason UI doesn't update sometimes, when state is updated using setValue.
4747
// So to force update the component, I am using following key, which will be incremented
4848
// for every keyboard slide up and down.
@@ -228,12 +228,8 @@ export class KeyboardCompatibleView extends React.PureComponent {
228228
layout: { height },
229229
},
230230
}) => {
231-
// Don't set initial height again if the keyboard is open or initialHeight and layout height are equal
232-
// Helps with issues related to bottom tab bar animations occurring after this initial onLayout call
233-
if (
234-
!this.initialHeight ||
235-
(!this._keyboardOpen && this.initialHeight !== height)
236-
) {
231+
// Not to set initial height again.
232+
if (!this.initialHeight) {
237233
this.initialHeight = height;
238234
this.state.channelHeight.setValue(this.initialHeight);
239235
}

src/components/MessageInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ class MessageInput extends PureComponent {
465465
mentioned_users: [],
466466
});
467467
} catch (err) {
468-
console.log('Failed');
468+
console.log('Fialed');
469469
}
470470
}
471471
};

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// TypeScript Version: 2.8
22

33
import * as React from 'react';
4-
import { FlatList, GestureResponderEvent } from 'react-native';
4+
import { Text, GestureResponderEvent, FlatList } from 'react-native';
55
import * as Client from 'stream-chat';
66
import * as SeamlessImmutable from 'seamless-immutable';
77
import * as i18next from 'i18next';

0 commit comments

Comments
 (0)