Unverified Commit c583e0c8 authored by Djorkaeff Alexandre's avatar Djorkaeff Alexandre Committed by GitHub
Browse files

[IMPROVEMENT] Remove useMarkdown (#1774)


Co-authored-by: default avatarDiego Mello <diegolmello@gmail.com>
parent b166d59c
......@@ -50,7 +50,6 @@ export const SNIPPETED_MESSAGES = createRequestTypes('SNIPPETED_MESSAGES', ['OPE
export const DEEP_LINKING = createRequestTypes('DEEP_LINKING', ['OPEN']);
export const SORT_PREFERENCES = createRequestTypes('SORT_PREFERENCES', ['SET_ALL', 'SET']);
export const NOTIFICATION = createRequestTypes('NOTIFICATION', ['RECEIVED', 'REMOVE']);
export const TOGGLE_MARKDOWN = 'TOGGLE_MARKDOWN';
export const TOGGLE_CRASH_REPORT = 'TOGGLE_CRASH_REPORT';
export const SET_CUSTOM_EMOJIS = 'SET_CUSTOM_EMOJIS';
export const SET_ACTIVE_USERS = 'SET_ACTIVE_USERS';
......
import * as types from './actionsTypes';
export function toggleMarkdown(value) {
return {
type: types.TOGGLE_MARKDOWN,
payload: value
};
}
......@@ -42,7 +42,7 @@ const styles = StyleSheet.create({
});
const ReplyPreview = React.memo(({
message, Message_TimeFormat, baseUrl, username, useMarkdown, replying, getCustomEmoji, close, theme
message, Message_TimeFormat, baseUrl, username, replying, getCustomEmoji, close, theme
}) => {
if (!replying) {
return null;
......@@ -67,7 +67,6 @@ const ReplyPreview = React.memo(({
username={username}
getCustomEmoji={getCustomEmoji}
numberOfLines={1}
useMarkdown={useMarkdown}
preview
theme={theme}
/>
......@@ -79,7 +78,6 @@ const ReplyPreview = React.memo(({
ReplyPreview.propTypes = {
replying: PropTypes.bool,
useMarkdown: PropTypes.bool,
message: PropTypes.object.isRequired,
Message_TimeFormat: PropTypes.string.isRequired,
close: PropTypes.func.isRequired,
......@@ -90,7 +88,6 @@ ReplyPreview.propTypes = {
};
const mapStateToProps = state => ({
useMarkdown: state.markdown.useMarkdown,
Message_TimeFormat: state.settings.Message_TimeFormat,
baseUrl: state.server.server
});
......
......@@ -71,7 +71,6 @@ class Markdown extends PureComponent {
tmid: PropTypes.string,
isEdited: PropTypes.bool,
numberOfLines: PropTypes.number,
useMarkdown: PropTypes.bool,
customEmojis: PropTypes.bool,
useRealName: PropTypes.bool,
channels: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
......@@ -368,9 +367,7 @@ class Markdown extends PureComponent {
}
render() {
const {
msg, useMarkdown = true, numberOfLines, preview = false, theme
} = this.props;
const { msg, preview = false } = this.props;
if (!msg) {
return null;
......@@ -389,10 +386,6 @@ class Markdown extends PureComponent {
return this.renderer.render(ast);
}
if (!useMarkdown && !preview) {
return <Text style={[styles.text, { color: themes[theme].bodyText }]} numberOfLines={numberOfLines}>{m}</Text>;
}
const ast = parser.parse(m);
this.isMessageContainsOnlyEmoji = isOnlyEmoji(m) && emojiCount(m) <= 3;
......
......@@ -8,7 +8,7 @@ import Video from './Video';
import Reply from './Reply';
const Attachments = React.memo(({
attachments, timeFormat, user, baseUrl, useMarkdown, showAttachment, getCustomEmoji, theme
attachments, timeFormat, user, baseUrl, showAttachment, getCustomEmoji, theme
}) => {
if (!attachments || attachments.length === 0) {
return null;
......@@ -16,17 +16,17 @@ const Attachments = React.memo(({
return attachments.map((file, index) => {
if (file.image_url) {
return <Image key={file.image_url} file={file} user={user} baseUrl={baseUrl} showAttachment={showAttachment} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} theme={theme} />;
return <Image key={file.image_url} file={file} user={user} baseUrl={baseUrl} showAttachment={showAttachment} getCustomEmoji={getCustomEmoji} theme={theme} />;
}
if (file.audio_url) {
return <Audio key={file.audio_url} file={file} user={user} baseUrl={baseUrl} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} theme={theme} />;
return <Audio key={file.audio_url} file={file} user={user} baseUrl={baseUrl} getCustomEmoji={getCustomEmoji} theme={theme} />;
}
if (file.video_url) {
return <Video key={file.video_url} file={file} user={user} baseUrl={baseUrl} showAttachment={showAttachment} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} theme={theme} />;
return <Video key={file.video_url} file={file} user={user} baseUrl={baseUrl} showAttachment={showAttachment} getCustomEmoji={getCustomEmoji} theme={theme} />;
}
// eslint-disable-next-line react/no-array-index-key
return <Reply key={index} index={index} attachment={file} timeFormat={timeFormat} user={user} baseUrl={baseUrl} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} theme={theme} />;
return <Reply key={index} index={index} attachment={file} timeFormat={timeFormat} user={user} baseUrl={baseUrl} getCustomEmoji={getCustomEmoji} theme={theme} />;
});
}, (prevProps, nextProps) => isEqual(prevProps.attachments, nextProps.attachments) && prevProps.theme === nextProps.theme);
......@@ -35,7 +35,6 @@ Attachments.propTypes = {
timeFormat: PropTypes.string,
user: PropTypes.object,
baseUrl: PropTypes.string,
useMarkdown: PropTypes.bool,
showAttachment: PropTypes.func,
getCustomEmoji: PropTypes.func,
theme: PropTypes.string
......
......@@ -74,7 +74,6 @@ class Audio extends React.Component {
file: PropTypes.object.isRequired,
baseUrl: PropTypes.string.isRequired,
user: PropTypes.object.isRequired,
useMarkdown: PropTypes.bool,
theme: PropTypes.string,
split: PropTypes.bool,
getCustomEmoji: PropTypes.func
......@@ -157,7 +156,7 @@ class Audio extends React.Component {
uri, paused, currentTime, duration
} = this.state;
const {
user, baseUrl, file, getCustomEmoji, useMarkdown, split, theme
user, baseUrl, file, getCustomEmoji, split, theme
} = this.props;
const { description } = file;
......@@ -199,7 +198,7 @@ class Audio extends React.Component {
/>
<Text style={[styles.duration, { color: themes[theme].auxiliaryText }]}>{this.duration}</Text>
</View>
<Markdown msg={description} baseUrl={baseUrl} username={user.username} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} theme={theme} />
<Markdown msg={description} baseUrl={baseUrl} username={user.username} getCustomEmoji={getCustomEmoji} theme={theme} />
</>
);
}
......
......@@ -29,7 +29,6 @@ const Content = React.memo((props) => {
preview={props.tmid && !props.isThreadRoom}
channels={props.channels}
mentions={props.mentions}
useMarkdown={props.useMarkdown && (!props.tmid || props.isThreadRoom)}
navToRoomInfo={props.navToRoomInfo}
tmid={props.tmid}
useRealName={props.useRealName}
......@@ -53,7 +52,6 @@ Content.propTypes = {
msg: PropTypes.string,
theme: PropTypes.string,
isEdited: PropTypes.bool,
useMarkdown: PropTypes.bool,
baseUrl: PropTypes.string,
user: PropTypes.object,
getCustomEmoji: PropTypes.func,
......
......@@ -41,7 +41,7 @@ export const MessageImage = React.memo(({ img, theme }) => (
));
const ImageContainer = React.memo(({
file, imageUrl, baseUrl, user, useMarkdown, showAttachment, getCustomEmoji, split, theme
file, imageUrl, baseUrl, user, showAttachment, getCustomEmoji, split, theme
}) => {
const img = imageUrl || formatAttachmentUrl(file.image_url, user.id, user.token, baseUrl);
if (!img) {
......@@ -55,7 +55,7 @@ const ImageContainer = React.memo(({
<Button split={split} theme={theme} onPress={onPress}>
<View>
<MessageImage img={img} theme={theme} />
<Markdown msg={file.description} baseUrl={baseUrl} username={user.username} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} theme={theme} />
<Markdown msg={file.description} baseUrl={baseUrl} username={user.username} getCustomEmoji={getCustomEmoji} theme={theme} />
</View>
</Button>
);
......@@ -73,7 +73,6 @@ ImageContainer.propTypes = {
imageUrl: PropTypes.string,
baseUrl: PropTypes.string,
user: PropTypes.object,
useMarkdown: PropTypes.bool,
showAttachment: PropTypes.func,
theme: PropTypes.string,
getCustomEmoji: PropTypes.func,
......
......@@ -79,7 +79,7 @@ const Title = React.memo(({ attachment, timeFormat, theme }) => {
});
const Description = React.memo(({
attachment, baseUrl, user, getCustomEmoji, useMarkdown, theme
attachment, baseUrl, user, getCustomEmoji, theme
}) => {
const text = attachment.text || attachment.title;
if (!text) {
......@@ -91,7 +91,6 @@ const Description = React.memo(({
baseUrl={baseUrl}
username={user.username}
getCustomEmoji={getCustomEmoji}
useMarkdown={useMarkdown}
theme={theme}
/>
);
......@@ -125,7 +124,7 @@ const Fields = React.memo(({ attachment, theme }) => {
}, (prevProps, nextProps) => isEqual(prevProps.attachment.fields, nextProps.attachment.fields) && prevProps.theme === nextProps.theme);
const Reply = React.memo(({
attachment, timeFormat, baseUrl, user, index, getCustomEmoji, useMarkdown, split, theme
attachment, timeFormat, baseUrl, user, index, getCustomEmoji, split, theme
}) => {
if (!attachment) {
return null;
......@@ -164,7 +163,6 @@ const Reply = React.memo(({
baseUrl={baseUrl}
user={user}
getCustomEmoji={getCustomEmoji}
useMarkdown={useMarkdown}
theme={theme}
/>
<Fields attachment={attachment} theme={theme} />
......@@ -179,7 +177,6 @@ Reply.propTypes = {
baseUrl: PropTypes.string,
user: PropTypes.object,
index: PropTypes.number,
useMarkdown: PropTypes.bool,
theme: PropTypes.string,
getCustomEmoji: PropTypes.func,
split: PropTypes.bool
......@@ -197,7 +194,6 @@ Description.propTypes = {
attachment: PropTypes.object,
baseUrl: PropTypes.string,
user: PropTypes.object,
useMarkdown: PropTypes.bool,
getCustomEmoji: PropTypes.func,
theme: PropTypes.string
};
......
......@@ -27,7 +27,7 @@ const styles = StyleSheet.create({
});
const Video = React.memo(({
file, baseUrl, user, useMarkdown, showAttachment, getCustomEmoji, theme
file, baseUrl, user, showAttachment, getCustomEmoji, theme
}) => {
if (!baseUrl) {
return null;
......@@ -54,7 +54,7 @@ const Video = React.memo(({
color={themes[theme].buttonText}
/>
</Touchable>
<Markdown msg={file.description} baseUrl={baseUrl} username={user.username} getCustomEmoji={getCustomEmoji} useMarkdown={useMarkdown} theme={theme} />
<Markdown msg={file.description} baseUrl={baseUrl} username={user.username} getCustomEmoji={getCustomEmoji} theme={theme} />
</>
);
}, (prevProps, nextProps) => isEqual(prevProps.file, nextProps.file) && prevProps.theme === nextProps.theme);
......@@ -63,7 +63,6 @@ Video.propTypes = {
file: PropTypes.object,
baseUrl: PropTypes.string,
user: PropTypes.object,
useMarkdown: PropTypes.bool,
showAttachment: PropTypes.func,
getCustomEmoji: PropTypes.func,
theme: PropTypes.string
......
......@@ -28,7 +28,6 @@ class MessageContainer extends React.Component {
isReadReceiptEnabled: PropTypes.bool,
isThreadRoom: PropTypes.bool,
useRealName: PropTypes.bool,
useMarkdown: PropTypes.bool,
autoTranslateRoom: PropTypes.bool,
autoTranslateLanguage: PropTypes.string,
status: PropTypes.number,
......@@ -227,7 +226,7 @@ class MessageContainer extends React.Component {
render() {
const {
item, user, style, archived, baseUrl, useRealName, broadcast, fetchThreadName, customThreadTimeFormat, showAttachment, timeFormat, useMarkdown, isReadReceiptEnabled, autoTranslateRoom, autoTranslateLanguage, navToRoomInfo, getCustomEmoji, isThreadRoom, callJitsi, blockAction, rid, theme
item, user, style, archived, baseUrl, useRealName, broadcast, fetchThreadName, customThreadTimeFormat, showAttachment, timeFormat, isReadReceiptEnabled, autoTranslateRoom, autoTranslateLanguage, navToRoomInfo, getCustomEmoji, isThreadRoom, callJitsi, blockAction, rid, theme
} = this.props;
const {
id, msg, ts, attachments, urls, reactions, t, avatar, u, alias, editedBy, role, drid, dcount, dlm, tmid, tcount, tlm, tmsg, mentions, channels, unread, blocks, autoTranslate: autoTranslateMessage
......@@ -272,7 +271,6 @@ class MessageContainer extends React.Component {
tcount={tcount}
tlm={tlm}
tmsg={tmsg}
useMarkdown={useMarkdown}
fetchThreadName={fetchThreadName}
mentions={mentions}
channels={channels}
......
......@@ -183,7 +183,6 @@ export default {
EMAIL: 'EMAIL',
email: 'Email',
Enable_Auto_Translate: 'Automatische Übersetzung aktivieren',
Enable_markdown: 'Markdown aktivieren',
Enable_notifications: 'Benachrichtigungen aktivieren',
Everyone_can_access_this_channel: 'Jeder kann auf diesen Kanal zugreifen',
erasing_room: 'lösche Raum',
......
......@@ -183,7 +183,6 @@ export default {
EMAIL: 'EMAIL',
email: 'e-mail',
Enable_Auto_Translate: 'Enable Auto-Translate',
Enable_markdown: 'Enable markdown',
Enable_notifications: 'Enable notifications',
Everyone_can_access_this_channel: 'Everyone can access this channel',
erasing_room: 'erasing room',
......
......@@ -176,7 +176,6 @@ export default {
EMAIL: 'EMAIL',
email: 'e-mail',
Enable_Auto_Translate: 'Permitir Auto-Translate',
Enable_markdown: 'Permitir markdown',
Enable_notifications: 'Permitir notificaciones',
Everyone_can_access_this_channel: 'Todos los usuarios pueden acceder a este canal',
erasing_room: 'eliminando sala',
......
......@@ -179,7 +179,6 @@ export default {
EMAIL: 'E-MAIL',
email: 'e-mail',
Enable_Auto_Translate: 'Abilita traduzione automatica',
Enable_markdown: 'Abilita Markdown',
Enable_notifications: 'Abilita notifiche',
Everyone_can_access_this_channel: 'Tutti hanno accesso a questo canale',
erasing_room: 'cancellazione stanza',
......
......@@ -179,7 +179,6 @@ export default {
EMAIL: 'EMAIL',
email: 'e-mail',
Enable_Auto_Translate: 'Zet Auto-Translate aan',
Enable_markdown: 'Zet markdown aan',
Enable_notifications: 'Zet notifications aan',
Everyone_can_access_this_channel: 'Iedereen kan bij dit kanaal',
erasing_room: 'kamer legen',
......
......@@ -177,7 +177,6 @@ export default {
Email_or_password_field_is_empty: 'Email ou senha estão vazios',
Email: 'Email',
email: 'e-mail',
Enable_markdown: 'Habilitar markdown',
Enable_notifications: 'Habilitar notificações',
Everyone_can_access_this_channel: 'Todos podem acessar este canal',
Error_uploading: 'Erro subindo',
......
......@@ -171,7 +171,6 @@ export default {
EMAIL: 'EMAIL',
email: 'e-mail',
Enable_Auto_Translate: 'Включить автоперевод',
Enable_markdown: 'Включить markdown',
Enable_notifications: 'Включить уведомления',
Everyone_can_access_this_channel: 'Каждый может получить доступ к этому каналу',
erasing_room: 'стирание комнаты',
......
......@@ -50,7 +50,6 @@ import I18n from '../i18n';
const TOKEN_KEY = 'reactnativemeteor_usertoken';
const SORT_PREFS_KEY = 'RC_SORT_PREFS_KEY';
export const MARKDOWN_KEY = 'RC_MARKDOWN_KEY';
export const THEME_PREFERENCES_KEY = 'RC_THEME_PREFERENCES_KEY';
export const CRASH_REPORT_KEY = 'RC_CRASH_REPORT_KEY';
const returnAnArray = obj => obj || [];
......@@ -884,13 +883,6 @@ const RocketChat = {
// RC 0.51.0
return this.sdk.methodCall('setAvatarFromService', data, contentType, service);
},
async getUseMarkdown() {
const useMarkdown = await AsyncStorage.getItem(MARKDOWN_KEY);
if (useMarkdown === null) {
return true;
}
return JSON.parse(useMarkdown);
},
async getAllowCrashReport() {
const allowCrashReport = await AsyncStorage.getItem(CRASH_REPORT_KEY);
if (allowCrashReport === null) {
......
......@@ -9,7 +9,6 @@ import createChannel from './createChannel';
import app from './app';
import sortPreferences from './sortPreferences';
import notification from './notification';
import markdown from './markdown';
import share from './share';
import crashReport from './crashReport';
import customEmojis from './customEmojis';
......@@ -28,7 +27,6 @@ export default combineReducers({
rooms,
sortPreferences,
notification,
markdown,
share,
crashReport,
customEmojis,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment