Files
mattermost-mobile/app/components/markdown/error_boundary.tsx
Elias Nahum 65366e53a9 Gekidou fixes (#6274)
* Add error boundry around latex to avoid crash

* Do not update channel display name when displayName is empty

* Show Muted unread channel as muted unless it has mentions

* Video size to wrapperWidth if thumbnail is not available

* Hide Threads button in channel list when only unreads filter if it does not have any unreads or mentions

* Ensure channel_item muted state is bolded when unread

* Bump network default retry to 3 attempts

* Sort only unreads by last root post if CRT is enabled

* Default canPost to true if permission is not found

* rename to ErrorBoundary (typo fix)

* simplify filterAndSortMyChannels

* Fix channel name collision with mention badges
2022-05-17 11:07:46 -04:00

59 lines
1.3 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {Text} from 'react-native';
import {makeStyleSheetFromTheme} from '@utils/theme';
import {typography} from '@utils/typography';
type State = {
hasError: boolean;
}
type Props = {
children: JSX.Element;
error: string;
theme: Theme;
}
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({
error: {
color: theme.errorTextColor,
flexDirection: 'row',
flexWrap: 'wrap',
fontStyle: 'italic',
...typography('Body', 100),
},
}));
class ErrorBoundary extends React.PureComponent<Props, State, any> {
constructor(props: Props) {
super(props);
this.state = {hasError: false};
}
componentDidCatch() {
this.setState({hasError: true});
}
render() {
// eslint-disable-next-line react/prop-types
const {children, error, theme} = this.props;
const {hasError} = this.state;
const style = getStyleSheet(theme);
if (hasError) {
return (
<Text style={style.error}>
{error}
</Text>
);
}
return children;
}
}
export default ErrorBoundary;