Fix the 'Go to room' button to use the correct room alias api

This commit is contained in:
Erik Johnston 2014-08-12 17:17:10 +01:00
parent 4add1c70e9
commit fe3c5a2726
3 changed files with 31 additions and 2 deletions

View file

@ -111,6 +111,15 @@ angular.module('matrixService', [])
}); });
}, },
joinAlias: function(room_alias) {
var path = "/join/$room_alias";
room_alias = encodeURIComponent(room_alias);
path = path.replace("$room_alias", room_alias);
return doRequest("PUT", path, undefined, {});
},
// Invite a user to a room // Invite a user to a room
invite: function(room_id, user_id) { invite: function(room_id, user_id) {
// The REST path spec // The REST path spec

View file

@ -18,6 +18,10 @@ angular.module('RoomsController', ['matrixService'])
room_id: "", room_id: "",
}; };
$scope.joinAlias = {
room_alias: "",
};
$scope.newProfileInfo = { $scope.newProfileInfo = {
name: matrixService.config().displayName, name: matrixService.config().displayName,
avatar: matrixService.config().avatarUrl avatar: matrixService.config().avatarUrl
@ -106,6 +110,22 @@ angular.module('RoomsController', ['matrixService'])
); );
}; };
$scope.joinAlias = function(room_alias) {
matrixService.joinAlias(room_alias).then(
function(response) {
if (response.hasOwnProperty("room_id")) {
$location.path("room/" + response.room_id);
return;
} else {
// TODO (erikj): Do something here?
}
},
function(reason) {
$scope.feedback = "Can't join room: " + reason;
}
);
};
$scope.setDisplayName = function(newName) { $scope.setDisplayName = function(newName) {
matrixService.setDisplayName(newName).then( matrixService.setDisplayName(newName).then(
function(response) { function(response) {

View file

@ -68,8 +68,8 @@
</div> </div>
<div> <div>
<form> <form>
<input size="40" ng-model="goToRoom.room_id" ng-enter="goToRoom(goToRoom.room_id)" placeholder="(e.g. #foo_channe:example.org)"/> <input size="40" ng-model="joinAlias.room_alias" ng-enter="joinAlias(joinAlias.room_alias)" placeholder="(e.g. #foo_channe:example.org)"/>
<button ng-disabled="!goToRoom.room_id" ng-click="goToRoom(goToRoom.room_id)">Go to room</button> <button ng-disabled="!joinAlias.room_alias" ng-click="joinAlias(joinAlias.room_alias)">Join room</button>
</form> </form>
</div> </div>
<br/> <br/>