Add defensive code to prevent extension from not working (#1872)

This commit is contained in:
Elias Nahum 2018-07-03 19:03:58 -04:00 committed by Saturnino Abril
parent 02c89faead
commit 40c7d9cb07
4 changed files with 8 additions and 4 deletions

View file

@ -77,6 +77,10 @@ export default class QuickTextInput extends React.PureComponent {
this.storedValue = this.props.value;
}
isFocused() {
return this.input.isFocused();
}
focus() {
this.input.focus();
}

View file

@ -43,7 +43,6 @@ export default function errorMessage(props) {
errorMessage.propTypes = {
close: PropTypes.func.isRequired,
formatMessage: PropTypes.func.isRequired,
};
const getStyleSheet = makeStyleSheetFromTheme((theme) => {

View file

@ -7,6 +7,7 @@ import {Animated, Dimensions, NavigatorIOS, StyleSheet, View} from 'react-native
import {Preferences} from 'mattermost-redux/constants';
import initialState from 'app/initial_state';
import mattermostBucket from 'app/mattermost_bucket';
import ExtensionPost from './extension_post';
@ -32,7 +33,7 @@ export default class SharedApp extends PureComponent {
};
mattermostBucket.readFromFile('entities', props.appGroupId).then((value) => {
this.entities = value;
this.entities = value || initialState;
this.setState({init: true});
});
}

View file

@ -232,7 +232,7 @@ export default class ExtensionPost extends PureComponent {
let totalSize = 0;
let exceededSize = false;
if (channel.type === General.GM_CHANNEL || channel.type === General.DM_CHANNEL) {
if (channel && (channel.type === General.GM_CHANNEL || channel.type === General.DM_CHANNEL)) {
channel = getChannel({entities}, channel.id);
}
@ -590,7 +590,7 @@ export default class ExtensionPost extends PureComponent {
const {currentUserId} = entities.users;
// If no text and no files do nothing
if (!value && !files.length) {
if ((!value && !files.length) || !channel) {
return;
}