Skip to content
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b184147
Chore: Migrate Markdown to TS
reinaldonetof Dec 16, 2021
7ed8fa0
Chore: Migrate Markdown to TS
reinaldonetof Dec 16, 2021
e74cb27
Merge branch 'chore.ts-markdown' of https://github.com/RocketChat/Roc…
reinaldonetof Dec 16, 2021
1b586c3
minor tweak
reinaldonetof Dec 16, 2021
e621168
added preview where markdown was preview and fixed params within mark…
reinaldonetof Dec 17, 2021
1963fd3
removed ts-ignore
reinaldonetof Dec 17, 2021
a038877
fix lint
reinaldonetof Dec 17, 2021
c3ca845
removed numbersofline={0} and default value to numberOfLines=1
reinaldonetof Dec 17, 2021
d4778d7
change how to import markdown preview and remove numberOfLines
reinaldonetof Dec 17, 2021
796a072
using useTheme inside markdownPreview and remove theme from components
reinaldonetof Dec 17, 2021
962fc5e
minor tweak on interfaces
reinaldonetof Dec 17, 2021
3e0a4ee
isNewMarkdown return as boolean
reinaldonetof Dec 17, 2021
12660f6
minor tweaks
reinaldonetof Dec 17, 2021
80531c7
minor tweaks
reinaldonetof Dec 17, 2021
f2158be
removed unused component
reinaldonetof Dec 17, 2021
d75e501
fixed markdown stories
reinaldonetof Dec 17, 2021
22ad55d
updated snapshot because removed numberOfLines={0} from message/content
reinaldonetof Dec 17, 2021
29ef469
create IEmoji.ts in definitions and refactor all places where getCust…
reinaldonetof Dec 17, 2021
901da12
onLinkPress typed
reinaldonetof Dec 20, 2021
bfd2796
todo: refactor navtoroominfo
reinaldonetof Dec 21, 2021
9e043cc
formatText.test.ts
reinaldonetof Dec 21, 2021
d004018
markdown stories to typescript too
reinaldonetof Dec 21, 2021
0663b44
minor tweak
reinaldonetof Dec 21, 2021
9f02b40
IMessage definition
reinaldonetof Dec 21, 2021
f9131ac
Merge branch 'develop' into chore.ts-markdown
AlexAlexandre Jan 11, 2022
e82ea64
refactor: update new types and interfaces for use ISubscription
AlexAlexandre Jan 11, 2022
4f92934
Merge branch 'develop' into chore.ts-markdown
AlexAlexandre Jan 12, 2022
6e1b4fb
refactor: update threadItem for use new MarkdownPreview
AlexAlexandre Jan 12, 2022
f58567b
refactor: rollback wrong file commited
AlexAlexandre Jan 12, 2022
fde7c0d
Merge branch 'develop' into chore.ts-markdown
reinaldonetof Jan 21, 2022
3233cee
formatHyperlink
reinaldonetof Jan 21, 2022
94aa322
Merge branch 'develop' into chore.ts-markdown
reinaldonetof Feb 4, 2022
d9608ff
fix lint
reinaldonetof Feb 4, 2022
ecc3e6d
updated item story shot
reinaldonetof Feb 7, 2022
a8a3d4f
Merge branch 'develop' into chore.ts-markdown
reinaldonetof Feb 7, 2022
01cf44c
refactor and refactor some types
reinaldonetof Feb 9, 2022
ddbbdfb
Remove non-null assertion
diegolmello Feb 10, 2022
ad59a7a
Minor change on useRealName
diegolmello Feb 10, 2022
d6768d7
Merge branch 'develop' into chore.ts-markdown
reinaldonetof Feb 17, 2022
384fe68
tweak
reinaldonetof Feb 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/containers/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Avatar = React.memo(
if (emoji) {
image = (
<Emoji
theme={theme}
theme={theme!}
baseUrl={server}
getCustomEmoji={getCustomEmoji}
isMessageContainsOnlyEmoji
Expand Down
4 changes: 3 additions & 1 deletion app/containers/Avatar/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { TGetCustomEmoji } from '../../definitions/IEmoji';

export interface IAvatar {
server?: string;
style?: any;
Expand All @@ -14,7 +16,7 @@ export interface IAvatar {
};
theme?: string;
onPress?: () => void;
getCustomEmoji?: () => any;
getCustomEmoji?: TGetCustomEmoji;
avatarETag?: string;
isStatic?: boolean | string;
rid?: string;
Expand Down
2 changes: 1 addition & 1 deletion app/containers/EmojiPicker/CustomEmoji.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import FastImage from '@rocket.chat/react-native-fast-image';

import { ICustomEmoji } from './interfaces';
import { ICustomEmoji } from '../../definitions/IEmoji';

const CustomEmoji = React.memo(
({ baseUrl, emoji, style }: ICustomEmoji) => (
Expand Down
2 changes: 1 addition & 1 deletion app/containers/EmojiPicker/EmojiCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import shortnameToUnicode from '../../utils/shortnameToUnicode';
import styles from './styles';
import CustomEmoji from './CustomEmoji';
import scrollPersistTaps from '../../utils/scrollPersistTaps';
import { IEmoji, IEmojiCategory } from './interfaces';
import { IEmoji, IEmojiCategory } from '../../definitions/IEmoji';

const EMOJI_SIZE = 50;

Expand Down
2 changes: 1 addition & 1 deletion app/containers/EmojiPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import shortnameToUnicode from '../../utils/shortnameToUnicode';
import log from '../../utils/log';
import { themes } from '../../constants/colors';
import { withTheme } from '../../theme';
import { IEmoji } from './interfaces';
import { IEmoji } from '../../definitions/IEmoji';

const scrollProps = {
keyboardShouldPersistTaps: 'always',
Expand Down
2 changes: 1 addition & 1 deletion app/containers/MessageActions/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import database from '../../lib/database';
import { Button } from '../ActionSheet';
import { useDimensions } from '../../dimensions';
import sharedStyles from '../../views/Styles';
import { IEmoji } from '../../definitions/IEmoji';
import { TFrequentlyUsedEmojiModel } from '../../definitions/IFrequentlyUsedEmoji';
import { IEmoji } from '../EmojiPicker/interfaces';

interface IHeader {
handleReaction: Function;
Expand Down
2 changes: 1 addition & 1 deletion app/containers/MessageBox/Mentions/MentionEmoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import shortnameToUnicode from '../../../utils/shortnameToUnicode';
import styles from '../styles';
import MessageboxContext from '../Context';
import CustomEmoji from '../../EmojiPicker/CustomEmoji';
import { IEmoji } from '../../EmojiPicker/interfaces';
import { IEmoji } from '../../../definitions/IEmoji';

interface IMessageBoxMentionEmoji {
item: IEmoji;
Expand Down
2 changes: 1 addition & 1 deletion app/containers/MessageBox/Mentions/MentionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import FixedMentionItem from './FixedMentionItem';
import MentionEmoji from './MentionEmoji';
import { MENTIONS_TRACKING_TYPE_EMOJIS, MENTIONS_TRACKING_TYPE_COMMANDS, MENTIONS_TRACKING_TYPE_CANNED } from '../constants';
import { themes } from '../../../constants/colors';
import { IEmoji } from '../../EmojiPicker/interfaces';
import { IEmoji } from '../../../definitions/IEmoji';

interface IMessageBoxMentionItem {
item: {
Expand Down
32 changes: 5 additions & 27 deletions app/containers/MessageBox/ReplyPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { StyleSheet, Text, View } from 'react-native';
import moment from 'moment';
import { connect } from 'react-redux';

import Markdown from '../markdown';
import { MarkdownPreview } from '../markdown';
import { CustomIcon } from '../../lib/Icons';
import sharedStyles from '../../views/Styles';
import { themes } from '../../constants/colors';
import { IMessage } from '../../definitions/IMessage';

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -42,11 +43,7 @@ const styles = StyleSheet.create({

interface IMessageBoxReplyPreview {
replying: boolean;
message: {
ts: Date;
msg: string;
u: any;
};
message: IMessage;
Message_TimeFormat: string;
close(): void;
baseUrl: string;
Expand All @@ -57,17 +54,7 @@ interface IMessageBoxReplyPreview {
}

const ReplyPreview = React.memo(
({
message,
Message_TimeFormat,
baseUrl,
username,
replying,
getCustomEmoji,
close,
theme,
useRealName
}: IMessageBoxReplyPreview) => {
({ message, Message_TimeFormat, replying, close, theme, useRealName }: IMessageBoxReplyPreview) => {
if (!replying) {
return null;
}
Expand All @@ -82,16 +69,7 @@ const ReplyPreview = React.memo(
</Text>
<Text style={[styles.time, { color: themes[theme].auxiliaryText }]}>{time}</Text>
</View>
{/* @ts-ignore*/}
<Markdown
msg={message.msg}
baseUrl={baseUrl}
username={username}
getCustomEmoji={getCustomEmoji}
numberOfLines={1}
preview
theme={theme}
/>
<MarkdownPreview msg={message.msg} />
</View>
<CustomIcon name='close' color={themes[theme].auxiliaryText} size={20} style={styles.close} onPress={close} />
</View>
Expand Down
9 changes: 2 additions & 7 deletions app/containers/MessageBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import Navigation from '../../lib/Navigation';
import { withActionSheet } from '../ActionSheet';
import { sanitizeLikeString } from '../../lib/database/utils';
import { CustomIcon } from '../../lib/Icons';
import { IMessage } from '../../definitions/IMessage';
import { forceJpgExtension } from './forceJpgExtension';

if (isAndroid) {
Expand Down Expand Up @@ -74,12 +75,7 @@ const videoPickerConfig = {
interface IMessageBoxProps {
rid: string;
baseUrl: string;
message: {
u: {
username: string;
};
id: any;
};
message: IMessage;
replying: boolean;
editing: boolean;
threadsEnabled: boolean;
Expand Down Expand Up @@ -1072,7 +1068,6 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {

const replyPreview = !recording ? (
<ReplyPreview
// @ts-ignore
message={message}
close={replyCancel}
username={user.username}
Expand Down
3 changes: 2 additions & 1 deletion app/containers/ReactionsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CustomIcon } from '../lib/Icons';
import sharedStyles from '../views/Styles';
import { themes } from '../constants/colors';
import { withTheme } from '../theme';
import { TGetCustomEmoji } from '../definitions/IEmoji';
import SafeAreaView from './SafeAreaView';

const styles = StyleSheet.create({
Expand Down Expand Up @@ -66,7 +67,7 @@ interface IItem {
};
user?: { username: any };
baseUrl?: string;
getCustomEmoji?: Function;
getCustomEmoji?: TGetCustomEmoji;
theme?: string;
}

Expand Down
18 changes: 3 additions & 15 deletions app/containers/RoomHeader/RoomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import I18n from '../../i18n';
import sharedStyles from '../../views/Styles';
import { themes } from '../../constants/colors';
import Markdown from '../markdown';
import { MarkdownPreview } from '../markdown';
import RoomTypeIcon from '../RoomTypeIcon';
import { withTheme } from '../../theme';

Expand Down Expand Up @@ -101,16 +101,7 @@ const SubTitle = React.memo(({ usersTyping, subtitle, renderFunc, theme, scale }

// subtitle
if (subtitle) {
return (
// @ts-ignore
<Markdown
preview
msg={subtitle}
style={[styles.subtitle, { fontSize, color: themes[theme].auxiliaryText }]}
numberOfLines={1}
theme={theme}
/>
);
return <MarkdownPreview msg={subtitle} style={[styles.subtitle, { fontSize, color: themes[theme].auxiliaryText }]} />;
}

return null;
Expand All @@ -126,10 +117,7 @@ const HeaderTitle = React.memo(({ title, tmid, prid, scale, theme, testID }: TRo
);
}

return (
// @ts-ignore
<Markdown preview msg={title} style={[styles.title, titleStyle]} numberOfLines={1} theme={theme} testID={testID} />
);
return <MarkdownPreview msg={title} style={[styles.title, titleStyle]} testID={testID} />;
});

const Header = React.memo(
Expand Down
10 changes: 5 additions & 5 deletions app/containers/UIKit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useContext } from 'react';
import { StyleSheet, Text } from 'react-native';
import { BLOCK_CONTEXT, UiKitParserMessage, UiKitParserModal, uiKitMessage, uiKitModal } from '@rocket.chat/ui-kit';

import Markdown from '../markdown';
import Markdown, { MarkdownPreview } from '../markdown';
import Button from '../Button';
import TextInput from '../TextInput';
import { textParser, useBlockContext } from './utils';
Expand Down Expand Up @@ -49,10 +49,10 @@ class MessageParser extends UiKitParserMessage {
}

const isContext = context === BLOCK_CONTEXT.CONTEXT;
return (
// @ts-ignore
<Markdown msg={text} theme={theme} style={[isContext && { color: themes[theme].auxiliaryText }]} preview={isContext} />
);
if (isContext) {
return <MarkdownPreview msg={text} style={[isContext && { color: themes[theme].auxiliaryText }]} numberOfLines={0} />;
}
return <Markdown msg={text} theme={theme} style={[isContext && { color: themes[theme].auxiliaryText }]} />;
}

button(element: any, context: any) {
Expand Down
10 changes: 6 additions & 4 deletions app/containers/markdown/AtMention.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { events, logEvent } from '../../utils/log';

interface IAtMention {
mention: string;
username: string;
navToRoomInfo: Function;
username?: string;
navToRoomInfo?: Function;
style?: any;
useRealName: boolean;
useRealName?: boolean;
mentions: any;
}

Expand Down Expand Up @@ -51,7 +51,9 @@ const AtMention = React.memo(({ mention, mentions, username, navToRoomInfo, styl
t: 'd',
rid: user && user._id
};
navToRoomInfo(navParam);
if (navToRoomInfo) {
navToRoomInfo(navParam);
}
};

if (user) {
Expand Down
6 changes: 3 additions & 3 deletions app/containers/markdown/Emoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ interface IEmoji {
getCustomEmoji?: Function;
baseUrl: string;
customEmojis?: any;
style: object;
theme?: string;
style?: object;
theme: string;
onEmojiSelected?: Function;
tabEmojiStyle?: object;
}
Expand All @@ -32,7 +32,7 @@ const Emoji = React.memo(
);
}
return (
<Text style={[{ color: themes[theme!].bodyText }, isMessageContainsOnlyEmoji ? styles.textBig : styles.text, style]}>
<Text style={[{ color: themes[theme].bodyText }, isMessageContainsOnlyEmoji ? styles.textBig : styles.text, style]}>
{emojiUnicode}
</Text>
);
Expand Down
25 changes: 12 additions & 13 deletions app/containers/markdown/Hashtag.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import React from 'react';
import { Text, TextStyle } from 'react-native';
import { Text, TextStyle, StyleProp } from 'react-native';

import { themes } from '../../constants/colors';
import { useTheme } from '../../theme';
import { IUserChannel } from './interfaces';
import styles from './styles';

interface IHashtag {
hashtag: string;
navToRoomInfo: Function;
style?: TextStyle[];
channels: {
[index: number]: string | number;
name: string;
_id: number;
}[];
navToRoomInfo?: Function;
style?: StyleProp<TextStyle>[];
channels?: IUserChannel[];
}

const Hashtag = React.memo(({ hashtag, channels, navToRoomInfo, style = [] }: IHashtag) => {
const { theme } = useTheme();

const handlePress = () => {
const index = channels?.findIndex(channel => channel.name === hashtag);
const navParam = {
t: 'c',
rid: channels[index]._id
};
navToRoomInfo(navParam);
if (index && navToRoomInfo) {
const navParam = {
t: 'c',
rid: channels?.[index]._id
};
navToRoomInfo(navParam);
}
};

if (channels && channels.length && channels.findIndex(channel => channel.name === hashtag) !== -1) {
Expand Down
3 changes: 2 additions & 1 deletion app/containers/markdown/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { LISTENER } from '../Toast';
import EventEmitter from '../../utils/events';
import I18n from '../../i18n';
import openLink from '../../utils/openLink';
import { TOnLinkPress } from './interfaces';

interface ILink {
children: JSX.Element;
link: string;
theme: string;
onLinkPress: Function;
onLinkPress?: TOnLinkPress;
}

const Link = React.memo(({ children, link, theme, onLinkPress }: ILink) => {
Expand Down
2 changes: 1 addition & 1 deletion app/containers/markdown/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface IList {
ordered: boolean;
start: number;
tight: boolean;
numberOfLines: number;
numberOfLines?: number;
}

const List = React.memo(({ children, ordered, tight, start = 1, numberOfLines = 0 }: IList) => {
Expand Down
Loading