diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-09-30 17:55:06 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-09-30 17:55:06 +0100 |
commit | 9605593d11b67199a98ed25f121a2af2e1c9587a (patch) | |
tree | dc57897bfcbd1591fa0dfb219e376353584654e9 /webclient/home | |
parent | SYN-75 Verify signatures on server to server transactions (diff) | |
parent | pyflakes cleanup (diff) | |
download | synapse-9605593d11b67199a98ed25f121a2af2e1c9587a.tar.xz |
Merge branch 'develop' into server2server_signing
Conflicts: synapse/storage/__init__.py tests/rest/test_presence.py
Diffstat (limited to 'webclient/home')
-rw-r--r-- | webclient/home/home-controller.js | 59 | ||||
-rw-r--r-- | webclient/home/home.html | 13 |
2 files changed, 62 insertions, 10 deletions
diff --git a/webclient/home/home-controller.js b/webclient/home/home-controller.js index e35219bebb..f1295560ef 100644 --- a/webclient/home/home-controller.js +++ b/webclient/home/home-controller.js @@ -42,6 +42,10 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen displayName: "", avatarUrl: "" }; + + $scope.newChat = { + user: "" + }; var refresh = function() { @@ -82,18 +86,24 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen // Go to a room $scope.goToRoom = function(room_id) { - // Simply open the room page on this room id - //$location.url("room/" + room_id); matrixService.join(room_id).then( function(response) { + var final_room_id = room_id; if (response.data.hasOwnProperty("room_id")) { - if (response.data.room_id != room_id) { - $location.url("room/" + response.data.room_id); - return; - } + final_room_id = response.data.room_id; } - $location.url("room/" + room_id); + // TODO: factor out the common housekeeping whenever we try to join a room or alias + matrixService.roomState(final_room_id).then( + function(response) { + eventHandlerService.handleEvents(response.data, false, true); + }, + function(error) { + $scope.feedback = "Failed to get room state for: " + final_room_id; + } + ); + + $location.url("room/" + final_room_id); }, function(error) { $scope.feedback = "Can't join room: " + JSON.stringify(error.data); @@ -104,6 +114,15 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen $scope.joinAlias = function(room_alias) { matrixService.joinAlias(room_alias).then( function(response) { + // TODO: factor out the common housekeeping whenever we try to join a room or alias + matrixService.roomState(response.room_id).then( + function(response) { + eventHandlerService.handleEvents(response.data, false, true); + }, + function(error) { + $scope.feedback = "Failed to get room state for: " + response.room_id; + } + ); // Go to this room $location.url("room/" + room_alias); }, @@ -112,6 +131,32 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen } ); }; + + // FIXME: factor this out between user-controller and home-controller etc. + $scope.messageUser = function() { + + // FIXME: create a new room every time, for now + + matrixService.create(null, 'private').then( + function(response) { + // This room has been created. Refresh the rooms list + var room_id = response.data.room_id; + console.log("Created room with id: "+ room_id); + + matrixService.invite(room_id, $scope.newChat.user).then( + function() { + $scope.feedback = "Invite sent successfully"; + $scope.$parent.goToPage("/room/" + room_id); + }, + function(reason) { + $scope.feedback = "Failure: " + JSON.stringify(reason); + }); + }, + function(error) { + $scope.feedback = "Failure: " + JSON.stringify(error.data); + }); + }; + $scope.onInit = function() { // Load profile data diff --git a/webclient/home/home.html b/webclient/home/home.html index 5a1e18e1de..0af382916e 100644 --- a/webclient/home/home.html +++ b/webclient/home/home.html @@ -17,7 +17,7 @@ <div>{{ config.user_id }}</div> </div> </div> - + <h3>Recent conversations</h3> <div ng-include="'recents/recents.html'"></div> <br/> @@ -52,17 +52,24 @@ <div> <form> - <input size="40" ng-model="newRoom.room_alias" ng-enter="createNewRoom(newRoom.room_alias, newRoom.private)" placeholder="(e.g. foo_channel)"/> + <input size="40" ng-model="newRoom.room_alias" ng-enter="createNewRoom(newRoom.room_alias, newRoom.private)" placeholder="(e.g. foo)"/> <input type="checkbox" ng-model="newRoom.private">private <button ng-disabled="!newRoom.room_alias" ng-click="createNewRoom(newRoom.room_alias, newRoom.private)">Create room</button> </form> </div> <div> <form> - <input size="40" ng-model="joinAlias.room_alias" ng-enter="joinAlias(joinAlias.room_alias)" placeholder="(e.g. #foo_channel:example.org)"/> + <input size="40" ng-model="joinAlias.room_alias" ng-enter="joinAlias(joinAlias.room_alias)" placeholder="(e.g. #foo:example.org)"/> <button ng-disabled="!joinAlias.room_alias" ng-click="joinAlias(joinAlias.room_alias)">Join room</button> </form> </div> + <div> + <form> + <input size="40" ng-model="newChat.user" ng-enter="messageUser()" placeholder="e.g. @user:domain.com"/> + <button ng-disabled="!newChat.user" ng-click="messageUser()">Message user</button> + </form> + </div> + <br/> {{ feedback }} |