mattermost-mobile/app/screens/add_reaction/index.js
Elias Nahum 016a725732
MM-28105 do not crash when in-app notification shows (#4915)
* MM-28105 do not crash when in-app notification shows

* Use index.tsx to register the notification screen

* Fix notification e2e and some import cleanup

* Update iOS notification json

* e2e: Show the add reaction screen before receiving a notification

* Update snapshots

* Patch react-native-notifications to prevent iOS crash when opening

* Apply TM4J id

Co-authored-by: Joseph Baylon <joseph.baylon@mattermost.com>
2020-10-22 14:34:49 -03:00

74 lines
1.7 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {
Keyboard,
StyleSheet,
View,
} from 'react-native';
import {Navigation} from 'react-native-navigation';
import EmojiPicker from 'app/components/emoji_picker';
import {emptyFunction} from 'app/utils/general';
import {dismissModal, setButtons} from 'app/actions/navigation';
export default class AddReaction extends PureComponent {
static propTypes = {
componentId: PropTypes.string,
closeButton: PropTypes.object,
onEmojiPress: PropTypes.func,
};
static defaultProps = {
onEmojiPress: emptyFunction,
};
leftButton = {
id: 'close-add-reaction',
testID: 'screen.add_reaction.close',
};
constructor(props) {
super(props);
setButtons(props.componentId, {
leftButtons: [{...this.leftButton, icon: props.closeButton}],
});
}
componentDidMount() {
this.navigationEventListener = Navigation.events().bindComponent(this);
}
navigationButtonPressed({buttonId}) {
if (buttonId === 'close-add-reaction') {
this.close();
}
}
close = () => {
Keyboard.dismiss();
dismissModal();
};
handleEmojiPress = (emoji) => {
this.props.onEmojiPress(emoji);
this.close();
}
render() {
return (
<View style={styles.container}>
<EmojiPicker onEmojiPress={this.handleEmojiPress}/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});