Focus/blur
This commit is contained in:
parent
4f010e5e37
commit
452620c02c
|
@ -183,7 +183,7 @@ class MessageBox extends Component {
|
|||
EventEmiter.addEventListener(KEY_COMMAND, this.handleCommands);
|
||||
}
|
||||
|
||||
this.didFocusListener = navigation.addListener('didFocus', () => {
|
||||
this.unsubscribeFocus = navigation.addListener('focus', () => {
|
||||
if (this.tracking && this.tracking.resetTracking) {
|
||||
this.tracking.resetTracking();
|
||||
}
|
||||
|
@ -268,8 +268,8 @@ class MessageBox extends Component {
|
|||
if (this.getSlashCommands && this.getSlashCommands.stop) {
|
||||
this.getSlashCommands.stop();
|
||||
}
|
||||
if (this.didFocusListener && this.didFocusListener.remove) {
|
||||
this.didFocusListener.remove();
|
||||
if (this.unsubscribeFocus) {
|
||||
this.unsubscribeFocus();
|
||||
}
|
||||
if (isTablet) {
|
||||
EventEmiter.removeListener(KEY_COMMAND, this.handleCommands);
|
||||
|
|
|
@ -83,7 +83,7 @@ class RoomInfoView extends React.Component {
|
|||
}
|
||||
|
||||
const { navigation } = this.props;
|
||||
this.willFocusListener = navigation.addListener('focus', () => {
|
||||
this.unsubscribeFocus = navigation.addListener('focus', () => {
|
||||
if (this.isLivechat) {
|
||||
this.loadVisitor();
|
||||
}
|
||||
|
@ -94,8 +94,8 @@ class RoomInfoView extends React.Component {
|
|||
if (this.subscription && this.subscription.unsubscribe) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
if (this.willFocusListener) {
|
||||
this.willFocusListener();
|
||||
if (this.unsubscribeFocus) {
|
||||
this.unsubscribeFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class List extends React.Component {
|
|||
animated: false
|
||||
};
|
||||
this.init();
|
||||
this.didFocusListener = props.navigation.addListener('didFocus', () => {
|
||||
this.unsubscribeFocus = props.navigation.addListener('focus', () => {
|
||||
if (this.mounted) {
|
||||
this.setState({ animated: true });
|
||||
} else {
|
||||
|
@ -163,8 +163,8 @@ class List extends React.Component {
|
|||
if (this.onEndReached && this.onEndReached.stop) {
|
||||
this.onEndReached.stop();
|
||||
}
|
||||
if (this.didFocusListener && this.didFocusListener.remove) {
|
||||
this.didFocusListener.remove();
|
||||
if (this.unsubscribeFocus) {
|
||||
this.unsubscribeFocus();
|
||||
}
|
||||
console.countReset(`${ this.constructor.name }.render calls`);
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ class ShareListView extends React.Component {
|
|||
serverInfo: null
|
||||
};
|
||||
this.setHeader();
|
||||
this.didFocusListener = props.navigation.addListener('didFocus', () => BackHandler.addEventListener('hardwareBackPress', this.handleBackPress));
|
||||
this.willBlurListener = props.navigation.addListener('willBlur', () => BackHandler.addEventListener('hardwareBackPress', this.handleBackPress));
|
||||
this.unsubscribeFocus = props.navigation.addListener('focus', () => BackHandler.addEventListener('hardwareBackPress', this.handleBackPress));
|
||||
this.unsubscribeBlur = props.navigation.addListener('blur', () => BackHandler.addEventListener('hardwareBackPress', this.handleBackPress));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -129,6 +129,15 @@ class ShareListView extends React.Component {
|
|||
return false;
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.unsubscribeFocus) {
|
||||
this.unsubscribeFocus();
|
||||
}
|
||||
if (this.unsubscribeBlur) {
|
||||
this.unsubscribeBlur();
|
||||
}
|
||||
}
|
||||
|
||||
setHeader = () => {
|
||||
const { searching } = this.state;
|
||||
const { navigation, theme } = this.props;
|
||||
|
|
Loading…
Reference in New Issue