summary refs log tree commit diff
path: root/webclient/components
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-09-08 18:40:34 -0700
committerKegan Dougal <kegan@matrix.org>2014-09-08 18:40:34 -0700
commit6bdb23449a7b4f5ca0426ec6c942332b245eec30 (patch)
tree223c9c950c8dd91b288315df50023a79ddbeac4c /webclient/components
parentFixed bug which displayed an older room topic because it was being returned f... (diff)
downloadsynapse-6bdb23449a7b4f5ca0426ec6c942332b245eec30.tar.xz
Add ability to set topic by double-clicking on the topic text then hitting enter.
Diffstat (limited to 'webclient/components')
-rw-r--r--webclient/components/matrix/event-handler-service.js1
-rw-r--r--webclient/components/matrix/matrix-service.js19
2 files changed, 20 insertions, 0 deletions
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