Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Renaming a thread is now possible without losing the capability to navigate.
The navigation from thread to parent only survives the renaming half: The updated name is shown after a refresh, but the link is not clickable.
Considered good enough for the moment
  • Loading branch information
mrsimpson committed Mar 21, 2018
1 parent b4ed740 commit 31a3729
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 879 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export class CreateRequestFromRoomId extends CreateRequestBase {
}

_getMessageUrl(msgId) {
const message = RocketChat.models.Messages.findOneById(msgId);
const room = RocketChat.models.Rooms.findOneById(message.rid);
return FlowRouter.path(RocketChat.roomTypes.getRouteLink(room.t, room), '', {msg: msgId});
return FlowRouter.path('message', {id: msgId});
}

_linkMessages(roomCreated, parentRoom) {
Expand Down Expand Up @@ -48,8 +46,8 @@ export class CreateRequestFromRoomId extends CreateRequestBase {
name: Meteor.user().username // Use @Name field for navigation
}],
channels: [{
_id: parentRoom._id, // Parent Room ID
name: parentRoom.fname || parentRoom.name
_id: parentRoom._id // Parent Room ID
// name: parentRoom.fname || parentRoom.name
}]
});
// Re-post message in the new room
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ Package.onUse(function(api) {
api.addFiles('client/lib/userRoles.js', 'client');
api.addFiles('client/lib/Layout.js', 'client');

// COMMON ROUTES
api.addFiles('startup/routes.js');

// CLIENT METHODS
api.addFiles('client/methods/sendMessage.js', 'client');
api.addFiles('client/AdminBox.js', 'client');
Expand Down
33 changes: 33 additions & 0 deletions packages/rocketchat-lib/startup/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* globals RocketChat */

import {FlowRouter} from 'meteor/kadira:flow-router';

/**
* in order to provide links to messages which are stable (e. g. survive renaming a room or changing its type)
* we introduce an explicit route. Since this needs to be executable on the client, we provide a method along with it
*/
FlowRouter.route('/message/:id', {
name: 'message',
action(params) {
Meteor.call('getCurrentRouteLink', params.id, (err, res) => {
if (!err && res) {
FlowRouter.go(res);
}
});
}
});

Meteor.methods({
getCurrentRouteLink(messageId) {
if (Meteor.isServer) {
const message = RocketChat.models.Messages.findOneById(messageId);

if (message && message.rid) {
const room = RocketChat.models.Rooms.findOneById(message.rid);
return FlowRouter.path(RocketChat.roomTypes.getRouteLink(room.t, room), '', {msg: message._id});
} else {
throw new Meteor.Error('invalid message');
}
}
}
});
Loading

0 comments on commit 31a3729

Please sign in to comment.