[FIX] UIKit crash when some app send a list (#2117)
* [FIX] StoryBook * [FIX] UIKit crash when some app send a list * [CHORE] Update snapshot * [CHORE] Remove token & id
This commit is contained in:
parent
5c99d8aa8d
commit
8c5538b148
|
@ -5161,6 +5161,25 @@ exports[`Storyshots UiKitMessage list uikitmessage 1`] = `
|
||||||
>
|
>
|
||||||
Section
|
Section
|
||||||
</Text>
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"fontSize": 20,
|
||||||
|
"fontWeight": "300",
|
||||||
|
"marginLeft": 10,
|
||||||
|
"marginTop": 30,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"backgroundColor": "#ffffff",
|
||||||
|
"color": "#0d0e12",
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Section + Markdown List
|
||||||
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={
|
style={
|
||||||
Array [
|
Array [
|
||||||
|
|
|
@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
|
||||||
import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit';
|
import { BLOCK_CONTEXT } from '@rocket.chat/ui-kit';
|
||||||
|
|
||||||
import { themes } from '../../constants/colors';
|
import { themes } from '../../constants/colors';
|
||||||
import sharedStyles from '../../views/Styles';
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
content: {
|
content: {
|
||||||
|
@ -18,11 +17,7 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
padding: 4,
|
padding: 4
|
||||||
fontSize: 16,
|
|
||||||
lineHeight: 22,
|
|
||||||
textAlignVertical: 'center',
|
|
||||||
...sharedStyles.textRegular
|
|
||||||
},
|
},
|
||||||
field: {
|
field: {
|
||||||
marginVertical: 6
|
marginVertical: 6
|
||||||
|
@ -54,7 +49,7 @@ export const Section = ({
|
||||||
accessory && accessoriesRight.includes(accessory.type) ? styles.row : styles.column
|
accessory && accessoriesRight.includes(accessory.type) ? styles.row : styles.column
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{text ? <Text style={[styles.text, { color: themes[theme].bodyText }]}>{parser.text(text)}</Text> : null}
|
{text ? <View style={styles.text}>{parser.text(text)}</View> : null}
|
||||||
{fields ? <Fields fields={fields} theme={theme} parser={parser} /> : null}
|
{fields ? <Fields fields={fields} theme={theme} parser={parser} /> : null}
|
||||||
{accessory ? <Accessory element={{ blockId, appId, ...accessory }} parser={parser} /> : null}
|
{accessory ? <Accessory element={{ blockId, appId, ...accessory }} parser={parser} /> : null}
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* eslint-disable class-methods-use-this */
|
/* eslint-disable class-methods-use-this */
|
||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet, Text } from 'react-native';
|
||||||
import {
|
import {
|
||||||
uiKitMessage,
|
uiKitMessage,
|
||||||
UiKitParserMessage,
|
UiKitParserMessage,
|
||||||
|
@ -13,8 +13,9 @@ import Markdown from '../markdown';
|
||||||
import Button from '../Button';
|
import Button from '../Button';
|
||||||
import TextInput from '../TextInput';
|
import TextInput from '../TextInput';
|
||||||
|
|
||||||
import { useBlockContext } from './utils';
|
import { useBlockContext, textParser } from './utils';
|
||||||
import { themes } from '../../constants/colors';
|
import { themes } from '../../constants/colors';
|
||||||
|
import sharedStyles from '../../views/Styles';
|
||||||
|
|
||||||
import { Divider } from './Divider';
|
import { Divider } from './Divider';
|
||||||
import { Section } from './Section';
|
import { Section } from './Section';
|
||||||
|
@ -37,6 +38,12 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
marginBottom: 16
|
marginBottom: 16
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 22,
|
||||||
|
textAlignVertical: 'center',
|
||||||
|
...sharedStyles.textRegular
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -46,7 +53,7 @@ class MessageParser extends UiKitParserMessage {
|
||||||
text({ text, type } = { text: '' }, context) {
|
text({ text, type } = { text: '' }, context) {
|
||||||
const { theme } = useContext(ThemeContext);
|
const { theme } = useContext(ThemeContext);
|
||||||
if (type !== 'mrkdwn') {
|
if (type !== 'mrkdwn') {
|
||||||
return text;
|
return <Text style={[styles.text, { color: themes[theme].bodyText }]}>{text}</Text>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isContext = context === BLOCK_CONTEXT.CONTEXT;
|
const isContext = context === BLOCK_CONTEXT.CONTEXT;
|
||||||
|
@ -70,7 +77,7 @@ class MessageParser extends UiKitParserMessage {
|
||||||
<Button
|
<Button
|
||||||
key={actionId}
|
key={actionId}
|
||||||
type={style}
|
type={style}
|
||||||
title={this.text(text)}
|
title={textParser([text])}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onPress={() => action({ value })}
|
onPress={() => action({ value })}
|
||||||
style={styles.button}
|
style={styles.button}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import messagesStatus from '../../app/constants/messagesStatus';
|
||||||
import MessageSeparator from '../../app/views/RoomView/Separator';
|
import MessageSeparator from '../../app/views/RoomView/Separator';
|
||||||
|
|
||||||
import { themes } from '../../app/constants/colors';
|
import { themes } from '../../app/constants/colors';
|
||||||
import MessageContext from '../../app/containers/message/Context';
|
|
||||||
|
|
||||||
let _theme = 'light';
|
let _theme = 'light';
|
||||||
|
|
||||||
|
@ -42,20 +41,6 @@ const getCustomEmoji = (content) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const Message = props => (
|
const Message = props => (
|
||||||
<MessageContext.Provider
|
|
||||||
value={{
|
|
||||||
user,
|
|
||||||
baseUrl,
|
|
||||||
onPress: () => {},
|
|
||||||
onLongPress: () => {},
|
|
||||||
reactionInit: () => {},
|
|
||||||
onErrorPress: () => {},
|
|
||||||
replyBroadcast: () => {},
|
|
||||||
onReactionPress: () => {},
|
|
||||||
onDiscussionPress: () => {},
|
|
||||||
onReactionLongPress: () => {}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<MessageComponent
|
<MessageComponent
|
||||||
baseUrl={baseUrl}
|
baseUrl={baseUrl}
|
||||||
user={user}
|
user={user}
|
||||||
|
@ -67,7 +52,6 @@ const Message = props => (
|
||||||
theme={_theme}
|
theme={_theme}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</MessageContext.Provider>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// eslint-disable-next-line react/prop-types
|
// eslint-disable-next-line react/prop-types
|
||||||
|
|
|
@ -31,6 +31,17 @@ export default () => (
|
||||||
}])
|
}])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<Separator title='Section + Markdown List' />
|
||||||
|
{
|
||||||
|
UiKitMessage([{
|
||||||
|
type: 'section',
|
||||||
|
text: {
|
||||||
|
type: 'mrkdwn',
|
||||||
|
text: '*List*:\n1. Item'
|
||||||
|
}
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
<Separator title='Section + Overflow' />
|
<Separator title='Section + Overflow' />
|
||||||
{
|
{
|
||||||
UiKitMessage([
|
UiKitMessage([
|
||||||
|
|
|
@ -11,6 +11,16 @@ import UiKitModal from './UiKitModal';
|
||||||
import Markdown from './Markdown';
|
import Markdown from './Markdown';
|
||||||
// import RoomViewHeader from './RoomViewHeader';
|
// import RoomViewHeader from './RoomViewHeader';
|
||||||
|
|
||||||
|
import MessageContext from '../../app/containers/message/Context';
|
||||||
|
|
||||||
|
// MessageProvider
|
||||||
|
const baseUrl = 'https://open.rocket.chat';
|
||||||
|
const user = {
|
||||||
|
id: '',
|
||||||
|
username: 'diego.mello',
|
||||||
|
token: ''
|
||||||
|
};
|
||||||
|
|
||||||
// Change here to see themed storybook
|
// Change here to see themed storybook
|
||||||
const theme = 'light';
|
const theme = 'light';
|
||||||
|
|
||||||
|
@ -26,15 +36,37 @@ const reducers = combineReducers({
|
||||||
});
|
});
|
||||||
const store = createStore(reducers);
|
const store = createStore(reducers);
|
||||||
|
|
||||||
|
const messageDecorator = story => (
|
||||||
|
<MessageContext.Provider
|
||||||
|
value={{
|
||||||
|
user,
|
||||||
|
baseUrl,
|
||||||
|
onPress: () => {},
|
||||||
|
onLongPress: () => {},
|
||||||
|
reactionInit: () => {},
|
||||||
|
onErrorPress: () => {},
|
||||||
|
replyBroadcast: () => {},
|
||||||
|
onReactionPress: () => {},
|
||||||
|
onDiscussionPress: () => {},
|
||||||
|
onReactionLongPress: () => {}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{story()}
|
||||||
|
</MessageContext.Provider>
|
||||||
|
);
|
||||||
|
|
||||||
storiesOf('RoomItem', module)
|
storiesOf('RoomItem', module)
|
||||||
.addDecorator(story => <Provider store={store}>{story()}</Provider>)
|
.addDecorator(story => <Provider store={store}>{story()}</Provider>)
|
||||||
.add('list roomitem', () => <RoomItem theme={theme} />);
|
.add('list roomitem', () => <RoomItem theme={theme} />);
|
||||||
storiesOf('Message', module)
|
storiesOf('Message', module)
|
||||||
|
.addDecorator(messageDecorator)
|
||||||
.add('list message', () => <Message theme={theme} />);
|
.add('list message', () => <Message theme={theme} />);
|
||||||
|
|
||||||
storiesOf('UiKitMessage', module)
|
storiesOf('UiKitMessage', module)
|
||||||
|
.addDecorator(messageDecorator)
|
||||||
.add('list uikitmessage', () => <UiKitMessage theme={theme} />);
|
.add('list uikitmessage', () => <UiKitMessage theme={theme} />);
|
||||||
storiesOf('UiKitModal', module)
|
storiesOf('UiKitModal', module)
|
||||||
|
.addDecorator(messageDecorator)
|
||||||
.add('list UiKitModal', () => <UiKitModal theme={theme} />);
|
.add('list UiKitModal', () => <UiKitModal theme={theme} />);
|
||||||
storiesOf('Markdown', module)
|
storiesOf('Markdown', module)
|
||||||
.add('list Markdown', () => <Markdown theme={theme} />);
|
.add('list Markdown', () => <Markdown theme={theme} />);
|
||||||
|
|
Loading…
Reference in New Issue