From 6bdb23449a7b4f5ca0426ec6c942332b245eec30 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 8 Sep 2014 18:40:34 -0700 Subject: Add ability to set topic by double-clicking on the topic text then hitting enter. --- webclient/components/matrix/event-handler-service.js | 1 + webclient/components/matrix/matrix-service.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'webclient/components') 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 -- cgit 1.4.1