From 705b8806afb69870e8d8d3d2de717c163200287f Mon Sep 17 00:00:00 2001 From: prateek93a Date: Wed, 15 Apr 2020 18:59:09 +0530 Subject: [PATCH 1/6] fixed-issue --- app/containers/Avatar.js | 9 ++++++--- app/containers/message/MessageAvatar.js | 10 ++++++++-- app/containers/message/index.js | 3 ++- app/lib/database/model/Message.js | 2 ++ app/lib/database/model/Thread.js | 2 ++ app/lib/database/model/ThreadMessage.js | 2 ++ app/lib/database/model/migrations.js | 23 +++++++++++++++++++++++ app/lib/database/schema/app.js | 5 ++++- app/lib/methods/sendMessage.js | 2 +- 9 files changed, 50 insertions(+), 8 deletions(-) diff --git a/app/containers/Avatar.js b/app/containers/Avatar.js index 2e4aa5353f..39cce89fb5 100644 --- a/app/containers/Avatar.js +++ b/app/containers/Avatar.js @@ -5,9 +5,10 @@ import FastImage from 'react-native-fast-image'; import { settings as RocketChatSettings } from '@rocket.chat/sdk'; import Touch from '../utils/touch'; import { avatarURL } from '../utils/avatar'; +import Markdown from './markdown'; const Avatar = React.memo(({ - text, size, baseUrl, borderRadius, style, avatar, type, children, userId, token, onPress, theme + text, size, baseUrl, borderRadius, style, avatar, type, children, userId, token, onPress, theme, emoji, getCustomEmoji }) => { const avatarStyle = { width: size, @@ -23,7 +24,7 @@ const Avatar = React.memo(({ type, text, size, userId, token, avatar, baseUrl }); - let image = ( + let image = emoji ? () : ( { if (isHeader && author) { const navParam = { @@ -24,9 +24,12 @@ const MessageAvatar = React.memo(({ size={small ? 20 : 36} borderRadius={small ? 2 : 4} avatar={avatar} + emoji={emoji} + theme={theme} baseUrl={baseUrl} userId={user.id} token={user.token} + getCustomEmoji={getCustomEmoji} /> ); @@ -37,11 +40,14 @@ const MessageAvatar = React.memo(({ MessageAvatar.propTypes = { isHeader: PropTypes.bool, avatar: PropTypes.string, + emoji: PropTypes.string, + theme: PropTypes.string, author: PropTypes.obj, baseUrl: PropTypes.string, user: PropTypes.obj, small: PropTypes.bool, - navToRoomInfo: PropTypes.func + navToRoomInfo: PropTypes.func, + getCustomEmoji: PropTypes.func }; MessageAvatar.displayName = 'MessageAvatar'; diff --git a/app/containers/message/index.js b/app/containers/message/index.js index 1a49b80f68..3df586ffbd 100644 --- a/app/containers/message/index.js +++ b/app/containers/message/index.js @@ -229,7 +229,7 @@ class MessageContainer extends React.Component { 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 + id, msg, ts, attachments, urls, reactions, t, avatar, emoji, u, alias, editedBy, role, drid, dcount, dlm, tmid, tcount, tlm, tmsg, mentions, channels, unread, blocks, autoTranslate: autoTranslateMessage } = item; let message = msg; @@ -253,6 +253,7 @@ class MessageContainer extends React.Component { reactions={reactions} alias={alias} avatar={avatar} + emoji={emoji} user={user} timeFormat={timeFormat} customThreadTimeFormat={customThreadTimeFormat} diff --git a/app/lib/database/model/Message.js b/app/lib/database/model/Message.js index 24dec99a69..22dfec731f 100644 --- a/app/lib/database/model/Message.js +++ b/app/lib/database/model/Message.js @@ -30,6 +30,8 @@ export default class Message extends Model { @field('avatar') avatar; + @field('emoji') emoji; + @json('attachments', sanitizer) attachments; @json('urls', sanitizer) urls; diff --git a/app/lib/database/model/Thread.js b/app/lib/database/model/Thread.js index e84dd5b7c0..fca0122ff1 100644 --- a/app/lib/database/model/Thread.js +++ b/app/lib/database/model/Thread.js @@ -30,6 +30,8 @@ export default class Thread extends Model { @field('avatar') avatar; + @field('emoji') emoji; + @json('attachments', sanitizer) attachments; @json('urls', sanitizer) urls; diff --git a/app/lib/database/model/ThreadMessage.js b/app/lib/database/model/ThreadMessage.js index f071a9c62b..842f222856 100644 --- a/app/lib/database/model/ThreadMessage.js +++ b/app/lib/database/model/ThreadMessage.js @@ -32,6 +32,8 @@ export default class ThreadMessage extends Model { @field('avatar') avatar; + @field('emoji') emoji; + @json('attachments', sanitizer) attachments; @json('urls', sanitizer) urls; diff --git a/app/lib/database/model/migrations.js b/app/lib/database/model/migrations.js index c8d8152451..e1d741e28f 100644 --- a/app/lib/database/model/migrations.js +++ b/app/lib/database/model/migrations.js @@ -74,6 +74,29 @@ export default schemaMigrations({ ] }) ] + }, + { + toVersion: 8, + steps: [ + addColumns({ + table: 'messages', + columns: [ + { name: 'emoji', type: 'string', isOptional: true } + ] + }), + addColumns({ + table: 'thread_messages', + columns: [ + { name: 'emoji', type: 'string', isOptional: true } + ] + }), + addColumns({ + table: 'threads', + columns: [ + { name: 'emoji', type: 'string', isOptional: true } + ] + }) + ] } ] }); diff --git a/app/lib/database/schema/app.js b/app/lib/database/schema/app.js index a16cb547d0..b0ab98f6b9 100644 --- a/app/lib/database/schema/app.js +++ b/app/lib/database/schema/app.js @@ -1,7 +1,7 @@ import { appSchema, tableSchema } from '@nozbe/watermelondb'; export default appSchema({ - version: 7, + version: 8, tables: [ tableSchema({ name: 'subscriptions', @@ -66,6 +66,7 @@ export default appSchema({ { name: 'parse_urls', type: 'string' }, { name: 'groupable', type: 'boolean', isOptional: true }, { name: 'avatar', type: 'string', isOptional: true }, + { name: 'emoji', type: 'string', isOptional: true }, { name: 'attachments', type: 'string', isOptional: true }, { name: 'urls', type: 'string', isOptional: true }, { name: '_updated_at', type: 'number' }, @@ -104,6 +105,7 @@ export default appSchema({ { name: 'parse_urls', type: 'string', isOptional: true }, { name: 'groupable', type: 'boolean', isOptional: true }, { name: 'avatar', type: 'string', isOptional: true }, + { name: 'emoji', type: 'string', isOptional: true }, { name: 'attachments', type: 'string', isOptional: true }, { name: 'urls', type: 'string', isOptional: true }, { name: 'status', type: 'number', isOptional: true }, @@ -140,6 +142,7 @@ export default appSchema({ { name: 'parse_urls', type: 'string', isOptional: true }, { name: 'groupable', type: 'boolean', isOptional: true }, { name: 'avatar', type: 'string', isOptional: true }, + { name: 'emoji', type: 'string', isOptional: true }, { name: 'attachments', type: 'string', isOptional: true }, { name: 'urls', type: 'string', isOptional: true }, { name: 'status', type: 'number', isOptional: true }, diff --git a/app/lib/methods/sendMessage.js b/app/lib/methods/sendMessage.js index 2a91637a92..e196ea0a6d 100644 --- a/app/lib/methods/sendMessage.js +++ b/app/lib/methods/sendMessage.js @@ -52,7 +52,7 @@ export async function sendMessageCall(message) { // RC 0.60.0 const result = await sdk.post('chat.sendMessage', { message: { - _id, rid, msg, tmid + _id, rid, msg, tmid, emoji: ':smirk:' } }); if (result.success) { From 3484d6265c08b449ecaf27c08bc4005cdf14ec31 Mon Sep 17 00:00:00 2001 From: prateek93a Date: Wed, 15 Apr 2020 19:24:50 +0530 Subject: [PATCH 2/6] removed-hardcoded-emoji --- app/lib/methods/sendMessage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/methods/sendMessage.js b/app/lib/methods/sendMessage.js index e196ea0a6d..2a91637a92 100644 --- a/app/lib/methods/sendMessage.js +++ b/app/lib/methods/sendMessage.js @@ -52,7 +52,7 @@ export async function sendMessageCall(message) { // RC 0.60.0 const result = await sdk.post('chat.sendMessage', { message: { - _id, rid, msg, tmid, emoji: ':smirk:' + _id, rid, msg, tmid } }); if (result.success) { From 7cb5de7f7615c04f69dd6aa08cf0b19fef4437fc Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 27 Apr 2020 13:12:24 -0300 Subject: [PATCH 3/6] Merge develop --- android/app/build.gradle | 2 +- app/containers/Avatar.js | 9 ++++++++- ios/RocketChatRN/Info.plist | 2 +- ios/ShareRocketChatRN/Info.plist | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 89bd6bbdb6..44b16c6391 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -138,7 +138,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode VERSIONCODE as Integer - versionName "4.6.4" + versionName "4.7.0" vectorDrawables.useSupportLibrary = true manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String] } diff --git a/app/containers/Avatar.js b/app/containers/Avatar.js index 39cce89fb5..461013837d 100644 --- a/app/containers/Avatar.js +++ b/app/containers/Avatar.js @@ -24,7 +24,14 @@ const Avatar = React.memo(({ type, text, size, userId, token, avatar, baseUrl }); - let image = emoji ? () : ( + let image = emoji ? ( + + ) : ( CFBundlePackageType APPL CFBundleShortVersionString - 4.6.4 + 4.7.0 CFBundleSignature ???? CFBundleURLTypes diff --git a/ios/ShareRocketChatRN/Info.plist b/ios/ShareRocketChatRN/Info.plist index 3a866bf68b..d88f511bc3 100644 --- a/ios/ShareRocketChatRN/Info.plist +++ b/ios/ShareRocketChatRN/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 4.6.4 + 4.7.0 CFBundleVersion 1 NSAppTransportSecurity From d7410b80dd457c97c2b31f2947ff09c645ba0945 Mon Sep 17 00:00:00 2001 From: prateek93a Date: Fri, 1 May 2020 01:30:48 +0530 Subject: [PATCH 4/6] replaced markdown with emoji componenent --- app/containers/Avatar.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/containers/Avatar.js b/app/containers/Avatar.js index 461013837d..868fc1c9a1 100644 --- a/app/containers/Avatar.js +++ b/app/containers/Avatar.js @@ -5,7 +5,7 @@ import FastImage from 'react-native-fast-image'; import { settings as RocketChatSettings } from '@rocket.chat/sdk'; import Touch from '../utils/touch'; import { avatarURL } from '../utils/avatar'; -import Markdown from './markdown'; +import Emoji from './markdown/Emoji'; const Avatar = React.memo(({ text, size, baseUrl, borderRadius, style, avatar, type, children, userId, token, onPress, theme, emoji, getCustomEmoji @@ -25,11 +25,14 @@ const Avatar = React.memo(({ }); let image = emoji ? ( - ) : ( Date: Fri, 1 May 2020 11:01:59 +0530 Subject: [PATCH 5/6] made-changes --- app/containers/Avatar.js | 2 -- app/containers/markdown/Emoji.js | 5 ++--- app/containers/markdown/index.js | 5 ++--- app/containers/message/MessageAvatar.js | 3 ++- app/containers/message/index.js | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/containers/Avatar.js b/app/containers/Avatar.js index f6c69ce200..66bef8411b 100644 --- a/app/containers/Avatar.js +++ b/app/containers/Avatar.js @@ -31,9 +31,7 @@ const Avatar = React.memo(({ baseUrl={baseUrl} getCustomEmoji={getCustomEmoji} isMessageContainsOnlyEmoji - customEmojis literal={emoji} - emojiName={emoji.replace(/:/g, '')} /> ) : ( { const emojiUnicode = shortnameToUnicode(literal); - const emoji = getCustomEmoji && getCustomEmoji(emojiName); + const emoji = getCustomEmoji && getCustomEmoji(literal.replace(/:/g, '')); if (emoji && customEmojis) { return ( { + renderEmoji = ({ literal }) => { const { - getCustomEmoji, baseUrl, customEmojis = true, style, theme + getCustomEmoji, baseUrl, customEmojis, style, theme } = this.props; return ( { const { baseUrl, user } = useContext(MessageContext); if (isHeader && author) { diff --git a/app/containers/message/index.js b/app/containers/message/index.js index 77ab215ec6..207e5e70cf 100644 --- a/app/containers/message/index.js +++ b/app/containers/message/index.js @@ -268,7 +268,7 @@ class MessageContainer extends React.Component { reactions={reactions} alias={alias} avatar={avatar} - emoji={emoji} + emoji={emoji} timeFormat={timeFormat} customThreadTimeFormat={customThreadTimeFormat} style={style} From 93c08215d472e74289352b327e7f8776bbd6eaec Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 7 May 2020 16:12:30 -0300 Subject: [PATCH 6/6] use avatar onPress --- app/containers/message/MessageAvatar.js | 39 +++++++++++-------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/app/containers/message/MessageAvatar.js b/app/containers/message/MessageAvatar.js index bbd050a4af..9f1eb6a231 100644 --- a/app/containers/message/MessageAvatar.js +++ b/app/containers/message/MessageAvatar.js @@ -1,13 +1,12 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; -import { TouchableOpacity } from 'react-native'; import Avatar from '../Avatar'; import styles from './styles'; import MessageContext from './Context'; const MessageAvatar = React.memo(({ - isHeader, avatar, author, small, navToRoomInfo, getCustomEmoji, theme, emoji + isHeader, avatar, author, small, navToRoomInfo, emoji, getCustomEmoji, theme }) => { const { baseUrl, user } = useContext(MessageContext); if (isHeader && author) { @@ -16,24 +15,20 @@ const MessageAvatar = React.memo(({ rid: author._id }; return ( - navToRoomInfo(navParam)} - disabled={author._id === user.id} - > - - + navToRoomInfo(navParam)} + getCustomEmoji={getCustomEmoji} + avatar={avatar} + emoji={emoji} + baseUrl={baseUrl} + userId={user.id} + token={user.token} + theme={theme} + /> ); } return null; @@ -43,11 +38,11 @@ MessageAvatar.propTypes = { isHeader: PropTypes.bool, avatar: PropTypes.string, emoji: PropTypes.string, - theme: PropTypes.string, author: PropTypes.obj, small: PropTypes.bool, navToRoomInfo: PropTypes.func, - getCustomEmoji: PropTypes.func + getCustomEmoji: PropTypes.func, + theme: PropTypes.string }; MessageAvatar.displayName = 'MessageAvatar';