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

[New] Reply privately to group messages #14150

Merged
merged 5 commits into from
Apr 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 22 additions & 1 deletion app/ui-utils/client/lib/MessageAction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'underscore';
import { FlowRouter } from 'meteor/kadira:flow-router';
import moment from 'moment';
import toastr from 'toastr';
import mem from 'mem';
Expand Down Expand Up @@ -317,13 +318,33 @@ Meteor.startup(async function() {
if (Subscriptions.findOne({ rid: message.rid }) == null) {
return false;
}

return true;
},
order: 6,
group: 'menu',
});

MessageAction.addButton({
id: 'reply-privately',
icon: 'chat',
label: 'Reply_in_direct_message',
context: ['message', 'message-mobile'],
action() {
const { msg } = messageArgs(this);
roomTypes.openRouteLink('d', { name: msg.u.username }, { ...FlowRouter.current().queryParams, reply: msg._id });
},
condition(message) {
if (Subscriptions.findOne({ rid: message.rid }) == null) {
return false;
}
if (roomTypes.getRoomType(message.rid) === 'd') {
return false;
}
return true;
},
order: 7,
group: 'menu',
});

MessageAction.addButton({
id: 'ignore-user',
Expand Down
7 changes: 7 additions & 0 deletions app/ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -1255,3 +1255,10 @@ Template.room.onRendered(function() {
});

});

callbacks.add('enter-room', async (sub) => {
const isAReplyInDMFromChannel = FlowRouter.getQueryParam('reply') && sub.t === 'd';
if (isAReplyInDMFromChannel && chatMessages[sub.rid]) {
await chatMessages[sub.rid].restoreReplies();
}
});
11 changes: 11 additions & 0 deletions app/utils/client/lib/roomTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ export const roomTypes = new class RocketChatRoomTypes extends RoomTypesCommon {
getUserStatus(roomType, roomId) {
return this.roomTypes[roomType] && typeof this.roomTypes[roomType].getUserStatus === 'function' && this.roomTypes[roomType].getUserStatus(roomId);
}
getRoomType(roomId) {
const fields = {
t: 1,
};
const room = ChatRoom.findOne({
_id: roomId,
}, {
fields,
});
return room && room.t;
}
findRoom(roomType, identifier, user) {
return this.roomTypes[roomType] && this.roomTypes[roomType].findRoom(identifier, user);
}
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2406,6 +2406,7 @@
"Replied_on": "Replied on",
"Replies": "Replies",
"Reply": "Reply",
"Reply_in_direct_message": "Reply in Direct Message",
"ReplyTo": "Reply-To",
"Report_Abuse": "Report Abuse",
"Report_exclamation_mark": "Report!",
Expand Down