diff --git a/app/containers/markdown/AtMention.js b/app/containers/markdown/AtMention.js
index 8980777e4..0653a2081 100644
--- a/app/containers/markdown/AtMention.js
+++ b/app/containers/markdown/AtMention.js
@@ -7,7 +7,7 @@ import { themes } from '../../constants/colors';
import styles from './styles';
const AtMention = React.memo(({
- mention, mentions, username, navToRoomInfo, preview, style = [], theme
+ mention, mentions, username, navToRoomInfo, preview, style = [], useRealName, theme
}) => {
let mentionStyle = { ...styles.mention, color: themes[theme].buttonText };
if (mention === 'all' || mention === 'here') {
@@ -27,22 +27,23 @@ const AtMention = React.memo(({
};
}
+ const user = mentions && mentions.length && mentions.find(m => m.username === mention);
+
const handlePress = () => {
- const index = mentions.findIndex(m => m.username === mention);
const navParam = {
t: 'd',
- rid: mentions[index]._id
+ rid: user && user._id
};
navToRoomInfo(navParam);
};
- if (mentions && mentions.length && mentions.findIndex(m => m.username === mention) !== -1) {
+ if (user) {
return (
- {mention}
+ {useRealName ? user.name : user.username}
);
}
@@ -60,6 +61,7 @@ AtMention.propTypes = {
navToRoomInfo: PropTypes.func,
style: PropTypes.array,
preview: PropTypes.bool,
+ useRealName: PropTypes.bool,
theme: PropTypes.string,
mentions: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
};
diff --git a/app/containers/markdown/index.js b/app/containers/markdown/index.js
index 40af9e171..0a446ee4b 100644
--- a/app/containers/markdown/index.js
+++ b/app/containers/markdown/index.js
@@ -73,6 +73,7 @@ class Markdown extends PureComponent {
numberOfLines: PropTypes.number,
useMarkdown: PropTypes.bool,
customEmojis: PropTypes.bool,
+ useRealName: PropTypes.bool,
channels: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
mentions: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
navToRoomInfo: PropTypes.func,
@@ -251,12 +252,13 @@ class Markdown extends PureComponent {
renderAtMention = ({ mentionName }) => {
const {
- username, mentions, navToRoomInfo, preview, style, theme
+ username, mentions, navToRoomInfo, useRealName, preview, style, theme
} = this.props;
return (
{
useMarkdown={props.useMarkdown && (!props.tmid || props.isThreadRoom)}
navToRoomInfo={props.navToRoomInfo}
tmid={props.tmid}
+ useRealName={props.useRealName}
theme={props.theme}
/>
);
@@ -58,7 +59,8 @@ Content.propTypes = {
getCustomEmoji: PropTypes.func,
channels: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
mentions: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
- navToRoomInfo: PropTypes.func
+ navToRoomInfo: PropTypes.func,
+ useRealName: PropTypes.bool
};
Content.displayName = 'MessageContent';
diff --git a/app/lib/methods/subscriptions/rooms.js b/app/lib/methods/subscriptions/rooms.js
index 02fac22f3..8a0891f56 100644
--- a/app/lib/methods/subscriptions/rooms.js
+++ b/app/lib/methods/subscriptions/rooms.js
@@ -283,10 +283,9 @@ export default function subscribeRooms() {
const [notification] = ddpMessage.fields.args;
try {
const { payload: { rid } } = notification;
- const subCollection = db.collections.get('subscriptions');
- const sub = await subCollection.find(rid);
- notification.title = RocketChat.getRoomTitle(sub);
- notification.avatar = RocketChat.getRoomAvatar(sub);
+ const room = await RocketChat.getRoom(rid);
+ notification.title = RocketChat.getRoomTitle(room);
+ notification.avatar = RocketChat.getRoomAvatar(room);
} catch (e) {
// do nothing
}
diff --git a/app/presentation/RoomItem/LastMessage.js b/app/presentation/RoomItem/LastMessage.js
index 08debd9e7..a972f42f4 100644
--- a/app/presentation/RoomItem/LastMessage.js
+++ b/app/presentation/RoomItem/LastMessage.js
@@ -9,7 +9,7 @@ import { themes } from '../../constants/colors';
import shortnameToUnicode from '../../utils/shortnameToUnicode';
const formatMsg = ({
- lastMessage, type, showLastMessage, username
+ lastMessage, type, showLastMessage, username, useRealName
}) => {
if (!showLastMessage) {
return '';
@@ -33,7 +33,8 @@ const formatMsg = ({
if (isLastMessageSentByMe) {
prefix = I18n.t('You_colon');
} else if (type !== 'd') {
- prefix = `${ lastMessage.u.username }: `;
+ const { u: { name } } = lastMessage;
+ prefix = `${ useRealName ? name : lastMessage.u.username }: `;
}
let msg = `${ prefix }${ lastMessage.msg.replace(/[\n\t\r]/igm, '') }`;
@@ -46,14 +47,15 @@ const formatMsg = ({
const arePropsEqual = (oldProps, newProps) => _.isEqual(oldProps, newProps);
const LastMessage = React.memo(({
- lastMessage, type, showLastMessage, username, alert, theme
+ lastMessage, type, showLastMessage, username, alert, useRealName, theme
}) => (
{
};
const RoomItem = React.memo(({
- onPress, width, favorite, toggleFav, isRead, rid, toggleRead, hideChannel, testID, unread, userMentions, name, _updatedAt, alert, type, avatarSize, baseUrl, userId, username, token, id, prid, showLastMessage, hideUnreadStatus, lastMessage, status, avatar, theme
+ onPress, width, favorite, toggleFav, isRead, rid, toggleRead, hideChannel, testID, unread, userMentions, name, _updatedAt, alert, type, avatarSize, baseUrl, userId, username, token, id, prid, showLastMessage, hideUnreadStatus, lastMessage, status, avatar, useRealName, theme
}) => {
const date = formatDate(_updatedAt);
@@ -144,6 +145,7 @@ const RoomItem = React.memo(({
showLastMessage={showLastMessage}
username={username}
alert={alert && !hideUnreadStatus}
+ useRealName={useRealName}
theme={theme}
/>
{
const { roomUser } = this.state;
- const { username: name } = roomUser;
+ const { username } = roomUser;
const { navigation } = this.props;
try {
- const result = await RocketChat.createDirectMessage(name);
+ const result = await RocketChat.createDirectMessage(username);
if (result.success) {
await navigation.navigate('RoomsListView');
const rid = result.room._id;
- navigation.navigate('RoomView', { rid, name, t: 'd' });
+ navigation.navigate('RoomView', { rid, name: RocketChat.getRoomTitle(roomUser), t: 'd' });
}
} catch (e) {
// do nothing
diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js
index f211dbb96..94a2e79f2 100644
--- a/app/views/RoomView/index.js
+++ b/app/views/RoomView/index.js
@@ -366,7 +366,11 @@ class RoomView extends React.Component {
const subCollection = await db.collections.get('subscriptions');
const room = await subCollection.find(rid);
this.setState({ room });
- navigation.setParams({ room });
+ navigation.setParams({
+ name: this.getRoomTitle(room),
+ avatar: room.name,
+ t: room.t
+ });
this.observeRoom(room);
} catch (error) {
if (this.t !== 'd') {
diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js
index 755b761b6..0e1877f76 100644
--- a/app/views/RoomsListView/index.js
+++ b/app/views/RoomsListView/index.js
@@ -173,6 +173,7 @@ class RoomsListView extends React.Component {
appStart: PropTypes.func,
roomsRequest: PropTypes.func,
closeServerDropdown: PropTypes.func,
+ useRealName: PropTypes.bool,
split: PropTypes.bool
};
@@ -757,6 +758,7 @@ class RoomsListView extends React.Component {
},
server,
StoreLastMessage,
+ useRealName,
theme,
split
} = this.props;
@@ -791,6 +793,7 @@ class RoomsListView extends React.Component {
toggleFav={this.toggleFav}
toggleRead={this.toggleRead}
hideChannel={this.hideChannel}
+ useRealName={useRealName}
/>
);
};
diff --git a/app/views/SidebarView/index.js b/app/views/SidebarView/index.js
index 08b6931ea..65ef944fc 100644
--- a/app/views/SidebarView/index.js
+++ b/app/views/SidebarView/index.js
@@ -47,6 +47,7 @@ class Sidebar extends Component {
activeItemKey: PropTypes.string,
theme: PropTypes.string,
loadingServer: PropTypes.bool,
+ useRealName: PropTypes.bool,
split: PropTypes.bool
}
@@ -77,7 +78,7 @@ class Sidebar extends Component {
shouldComponentUpdate(nextProps, nextState) {
const { status, showStatus, isAdmin } = this.state;
const {
- Site_Name, user, baseUrl, activeItemKey, split, theme
+ Site_Name, user, baseUrl, activeItemKey, split, useRealName, theme
} = this.props;
if (nextState.showStatus !== showStatus) {
return true;
@@ -111,6 +112,9 @@ class Sidebar extends Component {
if (nextProps.split !== split) {
return true;
}
+ if (nextProps.useRealName !== useRealName) {
+ return true;
+ }
if (!equal(nextState.status, status)) {
return true;
}
@@ -242,7 +246,7 @@ class Sidebar extends Component {
render() {
const { showStatus } = this.state;
const {
- user, Site_Name, baseUrl, split, theme
+ user, Site_Name, baseUrl, useRealName, split, theme
} = this.props;
if (!user) {
@@ -278,7 +282,7 @@ class Sidebar extends Component {
- {user.username}
+ {useRealName ? user.name : user.username}
{Site_Name}
@@ -300,7 +304,8 @@ const mapStateToProps = state => ({
Site_Name: state.settings.Site_Name,
user: getUserSelector(state),
baseUrl: state.server.server,
- loadingServer: state.server.loading
+ loadingServer: state.server.loading,
+ useRealName: state.settings.UI_Use_Real_Name
});
export default connect(mapStateToProps)(withTheme(withSplit(Sidebar)));