Skip to content

Commit

Permalink
Changes description and handles error cases
Browse files Browse the repository at this point in the history
  • Loading branch information
gdelavald committed Jul 25, 2017
1 parent a28ea23 commit 95c6aa0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
"Click_here": "Click here",
"Click_here_for_more_info": "Click here for more info",
"Click_Direct_Message": "Click to Create Direct Message",
"Click_Direct_Message_Description": "Skip opening profile tab and goes straight to conversation",
"Click_Direct_Message_Description": "Skip opening profile tab, instead go straight to conversation",
"Client_ID": "Client ID",
"Client_Secret": "Client Secret",
"Clients_will_refresh_in_a_few_seconds": "Clients will refresh in a few seconds",
Expand Down
38 changes: 22 additions & 16 deletions packages/rocketchat-ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,23 @@ const isSubscribed = _id => ChatSubscription.find({ rid: _id }).count() > 0;
const favoritesEnabled = () => RocketChat.settings.get('Favorite_Rooms');

const userCanDrop = _id => !RocketChat.roomTypes.readOnly(_id, Meteor.user());
const openProfileTab = (e, instance, data) => {
const roomData = Session.get(`roomData${ data.rid }`);

if (RocketChat.Layout.isEmbedded()) {
fireGlobalEvent('click-user-card-message', { username: data.u.username });
e.preventDefault();
e.stopPropagation();
return;
}

if (['c', 'p', 'd'].includes(roomData.t)) {
instance.setUserDetail(data.u.username);
}

instance.tabBar.setTemplate('membersList');
return instance.tabBar.open();
};
Template.room.helpers({
isTranslated() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { autoTranslate: 1, autoTranslateLanguage: 1 } });
Expand Down Expand Up @@ -462,29 +478,19 @@ Template.room.events({
if (clickToDirectMessage) {
return Meteor.call('createDirectMessage', this._arguments[1].u.username, (error, result) => {
if (error) {
return handleError(error);
if (error.isClientSafe) {
openProfileTab(e, instance, this._arguments[1]);
} else {
return handleError(error);
}
}

if ((result != null ? result.rid : undefined) != null) {
return FlowRouter.go('direct', { username: this._arguments[1].u.username }, FlowRouter.current().queryParams);
}
});
} else {
const roomData = Session.get(`roomData${ this._arguments[1].rid }`);

if (RocketChat.Layout.isEmbedded()) {
fireGlobalEvent('click-user-card-message', { username: this._arguments[1].u.username });
e.preventDefault();
e.stopPropagation();
return;
}

if (['c', 'p', 'd'].includes(roomData.t)) {
instance.setUserDetail(this._arguments[1].u.username);
}

instance.tabBar.setTemplate('membersList');
return instance.tabBar.open();
openProfileTab(e, instance, this._arguments[1]);
}
},

Expand Down

0 comments on commit 95c6aa0

Please sign in to comment.