mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Support room aliases in url bar and show them for rooms that have them
This commit is contained in:
parent
68d408bfff
commit
2771907573
@ -24,6 +24,8 @@ var React = require("react");
|
||||
// maps cannot pass through two stages).
|
||||
var MatrixReactSdk = require("../../src/index");
|
||||
|
||||
var lastLocationHashSet = null;
|
||||
|
||||
// Here, we do some crude URL analysis to allow
|
||||
// deep-linking. We only support registration
|
||||
// deep-links in this example.
|
||||
@ -46,6 +48,10 @@ function routeUrl(location) {
|
||||
}
|
||||
|
||||
function onHashChange(ev) {
|
||||
if (decodeURIComponent(window.location.hash) == lastLocationHashSet) {
|
||||
// we just set this: no need to route it!
|
||||
return;
|
||||
}
|
||||
routeUrl(window.location);
|
||||
}
|
||||
|
||||
@ -55,7 +61,9 @@ var loaded = false;
|
||||
// so a web page can update the URL bar appropriately.
|
||||
var onNewScreen = function(screen) {
|
||||
if (!loaded) return;
|
||||
window.location.hash = '#/'+screen;
|
||||
var hash = '#/' + screen;
|
||||
lastLocationHashSet = hash;
|
||||
window.location.hash = hash;
|
||||
}
|
||||
|
||||
// We use this to work out what URL the SDK should
|
||||
|
@ -202,6 +202,7 @@ module.exports = {
|
||||
|
||||
fillSpace: function() {
|
||||
var messageWrapper = this.refs.messageWrapper.getDOMNode();
|
||||
if (!messageWrapper) return;
|
||||
if (messageWrapper.scrollTop < messageWrapper.clientHeight && this.state.room.oldState.paginationToken) {
|
||||
this.setState({paginating: true});
|
||||
|
||||
|
@ -23,9 +23,11 @@ var MatrixClientPeg = require("../../MatrixClientPeg");
|
||||
var RoomListSorter = require("../../RoomListSorter");
|
||||
var Presence = require("../../Presence");
|
||||
var dis = require("../../dispatcher");
|
||||
var q = require("q");
|
||||
|
||||
var ComponentBroker = require('../../ComponentBroker');
|
||||
var Notifier = ComponentBroker.get('organisms/Notifier');
|
||||
var MatrixTools = require('../../MatrixTools');
|
||||
|
||||
module.exports = {
|
||||
PageTypes: {
|
||||
@ -136,7 +138,13 @@ module.exports = {
|
||||
currentRoom: payload.room_id,
|
||||
page_type: this.PageTypes.RoomView,
|
||||
});
|
||||
this.notifyNewScreen('room/'+payload.room_id);
|
||||
var presentedId = payload.room_id;
|
||||
var room = MatrixClientPeg.get().getRoom(payload.room_id);
|
||||
if (room) {
|
||||
var theAlias = MatrixTools.getCanonicalAliasForRoom(room);
|
||||
if (theAlias) presentedId = theAlias;
|
||||
}
|
||||
this.notifyNewScreen('room/'+presentedId);
|
||||
break;
|
||||
case 'view_prev_room':
|
||||
roomIndexDelta = -1;
|
||||
@ -249,10 +257,26 @@ module.exports = {
|
||||
params: params
|
||||
});
|
||||
} else if (screen.indexOf('room/') == 0) {
|
||||
var roomId = screen.split('/')[1];
|
||||
dis.dispatch({
|
||||
action: 'view_room',
|
||||
room_id: roomId
|
||||
var roomString = screen.split('/')[1];
|
||||
var defer = q.defer();
|
||||
if (roomString[0] == '#') {
|
||||
var self = this;
|
||||
MatrixClientPeg.get().getRoomIdForAlias(roomString).done(function(result) {
|
||||
self.setState({ready: true});
|
||||
defer.resolve(result.room_id);
|
||||
}, function() {
|
||||
self.setState({ready: true});
|
||||
defer.resolve(null);
|
||||
});
|
||||
this.setState({ready: false});
|
||||
} else {
|
||||
defer.resolve(roomString);
|
||||
}
|
||||
defer.promise.done(function(roomId) {
|
||||
dis.dispatch({
|
||||
action: 'view_room',
|
||||
room_id: roomId
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user