diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-09-08 18:40:34 -0700 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-09-08 18:40:34 -0700 |
commit | 6bdb23449a7b4f5ca0426ec6c942332b245eec30 (patch) | |
tree | 223c9c950c8dd91b288315df50023a79ddbeac4c /webclient | |
parent | Fixed bug which displayed an older room topic because it was being returned f... (diff) | |
download | synapse-6bdb23449a7b4f5ca0426ec6c942332b245eec30.tar.xz |
Add ability to set topic by double-clicking on the topic text then hitting enter.
Diffstat (limited to '')
-rwxr-xr-x | webclient/app.css | 5 | ||||
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 1 | ||||
-rw-r--r-- | webclient/components/matrix/matrix-service.js | 19 | ||||
-rw-r--r-- | webclient/room/room-controller.js | 25 | ||||
-rw-r--r-- | webclient/room/room.html | 10 |
5 files changed, 59 insertions, 1 deletions
diff --git a/webclient/app.css b/webclient/app.css index 2f969641b4..9667f3fd22 100755 --- a/webclient/app.css +++ b/webclient/app.css @@ -297,9 +297,14 @@ a:active { color: #000; } font-size: 13px; } +.roomTopicInput { + width: 100%; +} + .roomHeaderInfo { float: right; margin-top: 15px; + width: 50%; } /*** Participant list ***/ diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 8232e3b4b0..5a3e92186e 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -149,6 +149,7 @@ angular.module('eventHandlerService', []) $rootScope.$broadcast(NAME_EVENT, event, isLiveEvent); }; + // TODO: Can this just be a generic "I am a room state event, can haz store?" var handleRoomTopic = function(event, isLiveEvent) { console.log("handleRoomTopic live="+isLiveEvent); diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index 6864726ba4..62aff091d4 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -235,6 +235,25 @@ angular.module('matrixService', []) return doRequest("GET", path, undefined, {}); }, + + setTopic: function(room_id, topic) { + var data = { + topic: topic + }; + return this.sendStateEvent(room_id, "m.room.topic", data); + }, + + + sendStateEvent: function(room_id, eventType, content, state_key) { + var path = "/rooms/$room_id/state/"+eventType; + if (state_key !== undefined) { + path += "/" + state_key; + } + room_id = encodeURIComponent(room_id); + path = path.replace("$room_id", room_id); + + return doRequest("PUT", path, undefined, content); + }, sendEvent: function(room_id, eventType, txn_id, content) { // The REST path spec diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index c8ca771b25..10ff12a96b 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -42,6 +42,31 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) $scope.imageURLToSend = ""; $scope.userIDToInvite = ""; + // vars and functions for updating the topic + $scope.topic = { + isEditing: false, + newTopicText: "", + editTopic: function() { + if ($scope.topic.isEditing) { + console.log("Warning: Already editing topic."); + return; + } + $scope.topic.newTopicText = $rootScope.events.rooms[$scope.room_id]['m.room.topic'].content.topic; + $scope.topic.isEditing = true; + }, + updateTopic: function() { + console.log("Updating topic to "+$scope.topic.newTopicText); + matrixService.setTopic($scope.room_id, $scope.topic.newTopicText); + $scope.topic.isEditing = false; + }, + cancelEdit: function() { + $scope.topic.isEditing = false; + } + }; + + + + var scrollToBottom = function(force) { console.log("Scrolling to bottom"); diff --git a/webclient/room/room.html b/webclient/room/room.html index 4be2482f96..0fe45499e0 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -7,7 +7,15 @@ {{ room_id | mRoomName }} </div> <div id="roomTopic" ng-show="events.rooms[room_id]['m.room.topic'].content.topic"> - {{ events.rooms[room_id]['m.room.topic'].content.topic }} + <div ng-hide="topic.isEditing" ng-dblclick="topic.editTopic()"> + {{ events.rooms[room_id]['m.room.topic'].content.topic | limitTo: 200}} + </div> + + <form ng-submit="topic.updateTopic()" ng-show="topic.isEditing" class="roomTopicForm"> + <input ng-model="topic.newTopicText" ng-blur="topic.cancelEdit()" class="roomTopicInput" + autofocus /> + </form> + </div> </div> </div> |