don't change URL bar when clicking on linkified rooms or users.

be aware of /user paths.
This commit is contained in:
Matthew Hodgson 2016-08-28 02:05:23 +01:00
parent ad873c2b60
commit de82ac3bc0
3 changed files with 33 additions and 34 deletions

View file

@ -100,9 +100,9 @@ var sanitizeHtmlParams = {
if (m) { if (m) {
var entity = m[1]; var entity = m[1];
if (entity[0] === '@') { if (entity[0] === '@') {
attribs.href = '#'; // TODO attribs.href = '#/user/' + entity;
} }
else if (entity[0] === '#') { else if (entity[0] === '#' || entity[0] === '!') {
attribs.href = '#/room/' + entity; attribs.href = '#/room/' + entity;
} }
delete attribs.target; delete attribs.target;

View file

@ -176,12 +176,12 @@ module.exports = React.createClass({
// this can technically be done anywhere but doing this here keeps all // this can technically be done anywhere but doing this here keeps all
// the routing url path logic together. // the routing url path logic together.
// if (this.onAliasClick) { if (this.onAliasClick) {
// linkifyMatrix.onAliasClick = this.onAliasClick; linkifyMatrix.onAliasClick = this.onAliasClick;
// } }
// if (this.onUserClick) { if (this.onUserClick) {
// linkifyMatrix.onUserClick = this.onUserClick; linkifyMatrix.onUserClick = this.onUserClick;
// } }
window.addEventListener('resize', this.handleResize); window.addEventListener('resize', this.handleResize);
this.handleResize(); this.handleResize();
@ -761,29 +761,29 @@ module.exports = React.createClass({
} }
}, },
// onAliasClick: function(event, alias) { onAliasClick: function(event, alias) {
// event.preventDefault(); event.preventDefault();
// dis.dispatch({action: 'view_room', room_alias: alias}); dis.dispatch({action: 'view_room', room_alias: alias});
// }, },
// onUserClick: function(event, userId) { onUserClick: function(event, userId) {
// event.preventDefault(); event.preventDefault();
// // var MemberInfo = sdk.getComponent('rooms.MemberInfo');
// // var member = new Matrix.RoomMember(null, userId);
// // ContextualMenu.createMenu(MemberInfo, {
// // member: member,
// // right: window.innerWidth - event.pageX,
// // top: event.pageY
// // });
// var MemberInfo = sdk.getComponent('rooms.MemberInfo');
// var member = new Matrix.RoomMember(null, userId); // var member = new Matrix.RoomMember(null, userId);
// if (!member) { return; } // ContextualMenu.createMenu(MemberInfo, {
// dis.dispatch({
// action: 'view_user',
// member: member, // member: member,
// right: window.innerWidth - event.pageX,
// top: event.pageY
// }); // });
// },
var member = new Matrix.RoomMember(null, userId);
if (!member) { return; }
dis.dispatch({
action: 'view_user',
member: member,
});
},
onLogoutClick: function(event) { onLogoutClick: function(event) {
dis.dispatch({ dis.dispatch({

View file

@ -96,8 +96,8 @@ function matrixLinkify(linkify) {
} }
// stubs, overwritten in MatrixChat's componentDidMount // stubs, overwritten in MatrixChat's componentDidMount
// matrixLinkify.onUserClick = function(e, userId) { e.preventDefault(); }; matrixLinkify.onUserClick = function(e, userId) { e.preventDefault(); };
// matrixLinkify.onAliasClick = function(e, roomAlias) { e.preventDefault(); }; matrixLinkify.onAliasClick = function(e, roomAlias) { e.preventDefault(); };
var escapeRegExp = function(string) { var escapeRegExp = function(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@ -113,7 +113,6 @@ matrixLinkify.VECTOR_URL_PATTERN = "^(?:https?:\/\/)?(?:"
matrixLinkify.MATRIXTO_URL_PATTERN = "^(?:https?:\/\/)?(?:www\\.)?matrix\\.to/#/((#|@).*)"; matrixLinkify.MATRIXTO_URL_PATTERN = "^(?:https?:\/\/)?(?:www\\.)?matrix\\.to/#/((#|@).*)";
matrixLinkify.options = { matrixLinkify.options = {
/*
events: function (href, type) { events: function (href, type) {
switch (type) { switch (type) {
case "userid": case "userid":
@ -130,7 +129,7 @@ matrixLinkify.options = {
}; };
} }
}, },
*/
formatHref: function (href, type) { formatHref: function (href, type) {
switch (type) { switch (type) {
case 'roomalias': case 'roomalias':
@ -148,9 +147,9 @@ matrixLinkify.options = {
if (m) { if (m) {
var entity = m[1]; var entity = m[1];
if (entity[0] === '@') { if (entity[0] === '@') {
return '#'; // TODO return '#/user/' + entity;
} }
else if (entity[0] === '#') { else if (entity[0] === '#' || entity[0] === '!') {
return '#/room/' + entity; return '#/room/' + entity;
} }
} }