Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Avatar of message as an emoji #2038

Merged
merged 28 commits into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d0af3c0
Merge pull request #1 from RocketChat/develop
Prateek93a Oct 29, 2019
5eeb5ce
Merge pull request #2 from RocketChat/develop
Prateek93a Dec 5, 2019
eb42238
Merge branch 'develop' of https://github.com/Prateek93a/Rocket.Chat.R…
Prateek93a Feb 22, 2020
45ac82a
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Feb 22, 2020
827cd42
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 2, 2020
169c159
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 4, 2020
4350cde
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 11, 2020
9d0c8ec
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 14, 2020
bb4d912
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 22, 2020
bee1920
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 1, 2020
d48214d
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 1, 2020
e25eb0f
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 1, 2020
fa773ae
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 3, 2020
c2e3dc1
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 4, 2020
28d0419
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 8, 2020
0aff35f
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 10, 2020
bc57534
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 14, 2020
705b880
fixed-issue
Prateek93a Apr 15, 2020
3484d62
removed-hardcoded-emoji
Prateek93a Apr 15, 2020
7cb5de7
Merge develop
djorkaeffalexandre Apr 27, 2020
47427ef
Merge branch 'develop' into emoji-fix
djorkaeffalexandre Apr 27, 2020
f499f27
Merge branch 'develop' into emoji-fix
diegolmello Apr 30, 2020
d7410b8
replaced markdown with emoji componenent
Prateek93a Apr 30, 2020
49e69da
Merge branch 'develop' into emoji-fix
Prateek93a Apr 30, 2020
880b177
made-changes
Prateek93a May 1, 2020
72c786e
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
djorkaeffalexandre May 7, 2020
93c0821
use avatar onPress
djorkaeffalexandre May 7, 2020
26e06c2
Merge branch 'develop' into emoji-fix
diegolmello May 8, 2020
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
18 changes: 15 additions & 3 deletions app/containers/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import Touchable from 'react-native-platform-touchable';
import { settings as RocketChatSettings } from '@rocket.chat/sdk';

import { avatarURL } from '../utils/avatar';
import Emoji from './markdown/Emoji';

const Avatar = React.memo(({
text, size, baseUrl, borderRadius, style, avatar, type, children, userId, token, onPress
text, size, baseUrl, borderRadius, style, avatar, type, children, userId, token, onPress, theme, emoji, getCustomEmoji
}) => {
const avatarStyle = {
width: size,
Expand All @@ -24,7 +25,15 @@ const Avatar = React.memo(({
type, text, size, userId, token, avatar, baseUrl
});

let image = (
let image = emoji ? (
<Emoji
theme={theme}
baseUrl={baseUrl}
getCustomEmoji={getCustomEmoji}
isMessageContainsOnlyEmoji
literal={emoji}
/>
) : (
<FastImage
style={avatarStyle}
source={{
Expand Down Expand Up @@ -56,13 +65,16 @@ Avatar.propTypes = {
style: PropTypes.any,
text: PropTypes.string,
avatar: PropTypes.string,
emoji: PropTypes.string,
size: PropTypes.number,
borderRadius: PropTypes.number,
type: PropTypes.string,
children: PropTypes.object,
userId: PropTypes.string,
token: PropTypes.string,
onPress: PropTypes.func
theme: PropTypes.string,
onPress: PropTypes.func,
getCustomEmoji: PropTypes.func
};

Avatar.defaultProps = {
Expand Down
5 changes: 2 additions & 3 deletions app/containers/markdown/Emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { themes } from '../../constants/colors';
import styles from './styles';

const Emoji = React.memo(({
emojiName, literal, isMessageContainsOnlyEmoji, getCustomEmoji, baseUrl, customEmojis, style = [], theme
literal, isMessageContainsOnlyEmoji, getCustomEmoji, baseUrl, customEmojis = true, style = [], theme
}) => {
const emojiUnicode = shortnameToUnicode(literal);
const emoji = getCustomEmoji && getCustomEmoji(emojiName);
const emoji = getCustomEmoji && getCustomEmoji(literal.replace(/:/g, ''));
if (emoji && customEmojis) {
return (
<CustomEmoji
Expand All @@ -36,7 +36,6 @@ const Emoji = React.memo(({
});

Emoji.propTypes = {
emojiName: PropTypes.string,
literal: PropTypes.string,
isMessageContainsOnlyEmoji: PropTypes.bool,
getCustomEmoji: PropTypes.func,
Expand Down
5 changes: 2 additions & 3 deletions app/containers/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,12 @@ class Markdown extends PureComponent {
);
}

renderEmoji = ({ emojiName, literal }) => {
renderEmoji = ({ literal }) => {
const {
getCustomEmoji, baseUrl, customEmojis = true, style, theme
getCustomEmoji, baseUrl, customEmojis, style, theme
} = this.props;
return (
<MarkdownEmoji
emojiName={emojiName}
literal={literal}
isMessageContainsOnlyEmoji={this.isMessageContainsOnlyEmoji}
getCustomEmoji={getCustomEmoji}
Expand Down
10 changes: 8 additions & 2 deletions app/containers/message/MessageAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from './styles';
import MessageContext from './Context';

const MessageAvatar = React.memo(({
isHeader, avatar, author, small, navToRoomInfo
isHeader, avatar, author, small, navToRoomInfo, emoji, getCustomEmoji, theme
}) => {
const { baseUrl, user } = useContext(MessageContext);
if (isHeader && author) {
Expand All @@ -21,10 +21,13 @@ const MessageAvatar = React.memo(({
size={small ? 20 : 36}
borderRadius={small ? 2 : 4}
onPress={author._id === user.id ? undefined : () => navToRoomInfo(navParam)}
getCustomEmoji={getCustomEmoji}
avatar={avatar}
emoji={emoji}
baseUrl={baseUrl}
userId={user.id}
token={user.token}
theme={theme}
/>
);
}
Expand All @@ -34,9 +37,12 @@ const MessageAvatar = React.memo(({
MessageAvatar.propTypes = {
isHeader: PropTypes.bool,
avatar: PropTypes.string,
emoji: PropTypes.string,
author: PropTypes.obj,
small: PropTypes.bool,
navToRoomInfo: PropTypes.func
navToRoomInfo: PropTypes.func,
getCustomEmoji: PropTypes.func,
theme: PropTypes.string
};
MessageAvatar.displayName = 'MessageAvatar';

Expand Down
3 changes: 2 additions & 1 deletion app/containers/message/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,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;
Expand Down Expand Up @@ -268,6 +268,7 @@ class MessageContainer extends React.Component {
reactions={reactions}
alias={alias}
avatar={avatar}
emoji={emoji}
timeFormat={timeFormat}
customThreadTimeFormat={customThreadTimeFormat}
style={style}
Expand Down
2 changes: 2 additions & 0 deletions app/lib/database/model/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default class Message extends Model {

@field('avatar') avatar;

@field('emoji') emoji;

@json('attachments', sanitizer) attachments;

@json('urls', sanitizer) urls;
Expand Down
2 changes: 2 additions & 0 deletions app/lib/database/model/Thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default class Thread extends Model {

@field('avatar') avatar;

@field('emoji') emoji;

@json('attachments', sanitizer) attachments;

@json('urls', sanitizer) urls;
Expand Down
2 changes: 2 additions & 0 deletions app/lib/database/model/ThreadMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default class ThreadMessage extends Model {

@field('avatar') avatar;

@field('emoji') emoji;

@json('attachments', sanitizer) attachments;

@json('urls', sanitizer) urls;
Expand Down
18 changes: 18 additions & 0 deletions app/lib/database/model/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ 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 }
]
}),
addColumns({
table: 'subscriptions',
columns: [
Expand Down
3 changes: 3 additions & 0 deletions app/lib/database/schema/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,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' },
Expand Down Expand Up @@ -105,6 +106,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 },
Expand Down Expand Up @@ -141,6 +143,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 },
Expand Down