Merge pull request #24 from matrix-org/linkify

Add callback support for linkified users/aliases
This commit is contained in:
Kegsay
2015-10-27 12:25:20 +00:00
4 changed files with 72 additions and 29 deletions
+23 -1
View File
@@ -21,6 +21,7 @@ var dis = require("../../dispatcher");
var sdk = require('../../index');
var MatrixTools = require('../../MatrixTools');
var linkifyMatrix = require("../../linkify-matrix");
var Cas = require("../../CasLogic");
@@ -66,6 +67,15 @@ module.exports = {
} else {
this.notifyNewScreen('login');
}
// this can technically be done anywhere but doing this here keeps all
// the routing url path logic together.
if (this.onAliasClick) {
linkifyMatrix.onAliasClick = this.onAliasClick;
}
if (this.onUserClick) {
linkifyMatrix.onUserClick = this.onUserClick;
}
},
componentWillUnmount: function() {
@@ -212,7 +222,19 @@ module.exports = {
}
break;
case 'view_room_alias':
MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias).done(function(result) {
var foundRoom = MatrixTools.getRoomForAlias(
MatrixClientPeg.get().getRooms(), payload.room_alias
);
if (foundRoom) {
dis.dispatch({
action: 'view_room',
room_id: foundRoom.roomId
});
return;
}
// resolve the alias and *then* view it
MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias).done(
function(result) {
dis.dispatch({
action: 'view_room',
room_id: result.room_id