summary refs log tree commit diff
path: root/webclient/room/room-controller.js
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2014-09-06 10:13:38 -0700
committerEmmanuel ROHEE <manu@Emmanuels-MacBook-Pro.local>2014-09-08 11:28:50 +0200
commitef0304beff82ad985033405e7230a327a91fc796 (patch)
treeeb298c0fa7c2e4301e3ac1340babb0f2f5d9e4b5 /webclient/room/room-controller.js
parentSet the room_alias field when we encounter a new one, rather than only from l... (diff)
downloadsynapse-ef0304beff82ad985033405e7230a327a91fc796.tar.xz
disable broken event dup suppression, and fix echo for /me
Diffstat (limited to '')
-rw-r--r--webclient/room/room-controller.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index c738b490e2..e69adb9b46 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -302,7 +302,9 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
         scrollToBottom(true);
         
         var promise;
-        var isCmd = false;
+        var cmd;
+        var args;
+        var echo = false;
         
         // Check for IRC style commands first
         var line = $scope.textInput;
@@ -311,17 +313,16 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
         line = line.replace(/\s+$/, "");
         
         if (line[0] === "/" && line[1] !== "/") {
-            isCmd = true;
-            
             var bits = line.match(/^(\S+?)( +(.*))?$/);
-            var cmd = bits[1];
-            var args = bits[3];
+            cmd = bits[1];
+            args = bits[3];
             
             console.log("cmd: " + cmd + ", args: " + args);
             
             switch (cmd) {
                 case "/me":
                     promise = matrixService.sendEmoteMessage($scope.room_id, args);
+                    echo = true;
                     break;
                     
                 case "/nick":
@@ -453,17 +454,20 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
         }
         
         // By default send this as a message unless it's an IRC-style command
-        if (!promise && !isCmd) {
-            var message = $scope.textInput;
-            $scope.textInput = "";
-
+        if (!promise && !cmd) {
+            // Make the request
+            promise = matrixService.sendTextMessage($scope.room_id, line);
+            echo = true;
+        }
+        
+        if (echo) {
             // Echo the message to the room
             // To do so, create a minimalist fake text message event and add it to the in-memory list of room messages
             var echoMessage = {
                 content: {
-                    body: message,
+                    body: (cmd === "/me" ? args : line),
                     hsob_ts: new Date().getTime(), // fake a timestamp
-                    msgtype: "m.text"
+                    msgtype: (cmd === "/me" ? "m.emote" : "m.text"),
                 },
                 room_id: $scope.room_id,
                 type: "m.room.message",
@@ -472,11 +476,9 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput'])
                 // echo_msg_state: "messagePending"     // Add custom field to indicate the state of this fake message to HTML
             };
 
+            $scope.textInput = "";
             $rootScope.events.rooms[$scope.room_id].messages.push(echoMessage);
             scrollToBottom();
-
-            // Make the request
-            promise = matrixService.sendTextMessage($scope.room_id, message);
         }
 
         if (promise) {