Bug 1157646 - Stop passing the roomOwner parameter around everywhere in Loop's rooms. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Thu, 27 Aug 2015 12:10:47 +0100
changeset 292191 4722e298ea31763f9ae39cc246050504b4574a3a
parent 292190 b94599998a85d13ba208d54adc9e7d8c825de0f5
child 292192 cdc4dc6af44936b6c5b2a188136c06007e57569a
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1157646
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1157646 - Stop passing the roomOwner parameter around everywhere in Loop's rooms. r=mikedeboer
browser/components/loop/content/shared/js/actions.js
browser/components/loop/content/shared/js/activeRoomStore.js
browser/components/loop/standalone/content/js/standaloneMozLoop.js
browser/components/loop/test/shared/activeRoomStore_test.js
browser/components/loop/test/shared/textChatStore_test.js
browser/components/loop/test/shared/textChatView_test.js
browser/components/loop/test/standalone/standaloneMozLoop_test.js
browser/components/loop/ui/fake-mozLoop.js
browser/components/loop/ui/ui-showcase.js
browser/components/loop/ui/ui-showcase.jsx
--- a/browser/components/loop/content/shared/js/actions.js
+++ b/browser/components/loop/content/shared/js/actions.js
@@ -457,32 +457,30 @@ loop.shared.actions = (function() {
      * XXX: should move to some roomActions module - refs bug 1079284
      *
      * @see https://wiki.mozilla.org/Loop/Architecture/Rooms#GET_.2Frooms.2F.7Btoken.7D
      */
     SetupRoomInfo: Action.define("setupRoomInfo", {
       // roomContextUrls: Array - Optional.
       // roomDescription: String - Optional.
       // roomName: String - Optional.
-      roomOwner: String,
       roomToken: String,
       roomUrl: String,
       socialShareProviders: Array
     }),
 
     /**
      * Updates the room information when it is received.
      * XXX: should move to some roomActions module - refs bug 1079284
      *
      * @see https://wiki.mozilla.org/Loop/Architecture/Rooms#GET_.2Frooms.2F.7Btoken.7D
      */
     UpdateRoomInfo: Action.define("updateRoomInfo", {
       // description: String - Optional.
       // roomName: String - Optional.
-      roomOwner: String,
       roomUrl: String
       // urls: Array - Optional.
       // See https://wiki.mozilla.org/Loop/Architecture/Context#Format_of_context.value
     }),
 
     /**
      * Updates the Social API information when it is received.
      * XXX: should move to some roomActions module - refs bug 1079284
--- a/browser/components/loop/content/shared/js/activeRoomStore.js
+++ b/browser/components/loop/content/shared/js/activeRoomStore.js
@@ -268,17 +268,16 @@ loop.store.ActiveRoomStore = (function()
             return;
           }
 
           this.dispatchAction(new sharedActions.SetupRoomInfo({
             roomToken: actionData.roomToken,
             roomContextUrls: roomData.decryptedContext.urls,
             roomDescription: roomData.decryptedContext.description,
             roomName: roomData.decryptedContext.roomName,
-            roomOwner: roomData.roomOwner,
             roomUrl: roomData.roomUrl,
             socialShareProviders: this._mozLoop.getSocialShareProviders()
           }));
 
           // For the conversation window, we need to automatically
           // join the room.
           this.dispatchAction(new sharedActions.JoinRoom());
         }.bind(this));
@@ -320,17 +319,16 @@ loop.store.ActiveRoomStore = (function()
           this.dispatchAction(new sharedActions.RoomFailure({
             error: err,
             failedJoinRequest: false
           }));
           return;
         }
 
         var roomInfoData = new sharedActions.UpdateRoomInfo({
-          roomOwner: result.roomOwner,
           roomUrl: result.roomUrl
         });
 
         // If we've got this far, then we want to go to the ready state
         // regardless of success of failure. This is because failures of
         // crypto don't stop the user using the room, they just stop
         // us putting up the information.
         roomInfoData.roomState = ROOM_STATES.READY;
@@ -391,17 +389,16 @@ loop.store.ActiveRoomStore = (function()
         console.error("Room info already set up!");
         return;
       }
 
       this.setStoreState({
         roomContextUrls: actionData.roomContextUrls,
         roomDescription: actionData.roomDescription,
         roomName: actionData.roomName,
-        roomOwner: actionData.roomOwner,
         roomState: ROOM_STATES.READY,
         roomToken: actionData.roomToken,
         roomUrl: actionData.roomUrl,
         socialShareProviders: actionData.socialShareProviders
       });
 
       this._onUpdateListener = this._handleRoomUpdate.bind(this);
       this._onDeleteListener = this._handleRoomDelete.bind(this);
@@ -415,17 +412,16 @@ loop.store.ActiveRoomStore = (function()
 
     /**
      * Handles the updateRoomInfo action. Updates the room data.
      *
      * @param {sharedActions.UpdateRoomInfo} actionData
      */
     updateRoomInfo: function(actionData) {
       var newState = {
-        roomOwner: actionData.roomOwner,
         roomUrl: actionData.roomUrl
       };
       // Iterate over the optional fields that _may_ be present on the actionData
       // object.
       Object.keys(OPTIONAL_ROOMINFO_FIELDS).forEach(function(field) {
         if (actionData[field]) {
           newState[OPTIONAL_ROOMINFO_FIELDS[field]] = actionData[field];
         }
@@ -451,17 +447,16 @@ loop.store.ActiveRoomStore = (function()
      * @param {String} eventName The name of the event
      * @param {Object} roomData  The new roomData.
      */
     _handleRoomUpdate: function(eventName, roomData) {
       this.dispatchAction(new sharedActions.UpdateRoomInfo({
         urls: roomData.decryptedContext.urls,
         description: roomData.decryptedContext.description,
         roomName: roomData.decryptedContext.roomName,
-        roomOwner: roomData.roomOwner,
         roomUrl: roomData.roomUrl
       }));
     },
 
     /**
      * Handles the deletion of a room, notified by the mozLoop rooms API.
      *
      * @param {String} eventName The name of the event
--- a/browser/components/loop/standalone/content/js/standaloneMozLoop.js
+++ b/browser/components/loop/standalone/content/js/standaloneMozLoop.js
@@ -86,17 +86,16 @@ loop.StandaloneMozLoop = (function(mozL1
           }
         }.bind(this)
       });
 
       req.done(function(responseData) {
         try {
           // We currently only require things we need rather than everything possible.
           callback(null, validate(responseData, {
-            roomOwner: String,
             roomUrl: String
           }));
         } catch (err) {
           console.error("Error requesting call info", err.message);
           callback(err);
         }
       }.bind(this));
 
--- a/browser/components/loop/test/shared/activeRoomStore_test.js
+++ b/browser/components/loop/test/shared/activeRoomStore_test.js
@@ -305,17 +305,16 @@ describe("loop.store.ActiveRoomStore", f
     var fakeToken, fakeRoomData;
 
     beforeEach(function() {
       fakeToken = "337-ff-54";
       fakeRoomData = {
         decryptedContext: {
           roomName: "Monkeys"
         },
-        roomOwner: "Alfred",
         roomUrl: "http://invalid"
       };
 
       store = new loop.store.ActiveRoomStore(dispatcher, {
         mozLoop: fakeMozLoop,
         sdkDriver: {}
       });
       fakeMozLoop.rooms.get.withArgs(fakeToken).callsArgOnWith(
@@ -348,17 +347,16 @@ describe("loop.store.ActiveRoomStore", f
 
         sinon.assert.calledTwice(dispatcher.dispatch);
         sinon.assert.calledWithExactly(dispatcher.dispatch,
           new sharedActions.SetupRoomInfo({
             roomContextUrls: undefined,
             roomDescription: undefined,
             roomToken: fakeToken,
             roomName: fakeRoomData.decryptedContext.roomName,
-            roomOwner: fakeRoomData.roomOwner,
             roomUrl: fakeRoomData.roomUrl,
             socialShareProviders: []
           }));
       });
 
     it("should dispatch a JoinRoom action if the get is successful",
       function() {
         store.setupWindowData(new sharedActions.SetupWindowData({
@@ -421,38 +419,35 @@ describe("loop.store.ActiveRoomStore", f
     it("should call mozLoop.rooms.get to get the room data", function() {
       store.fetchServerData(fetchServerAction);
 
       sinon.assert.calledOnce(fakeMozLoop.rooms.get);
     });
 
     it("should dispatch an UpdateRoomInfo message with 'no data' failure if neither roomName nor context are supplied", function() {
       fakeMozLoop.rooms.get.callsArgWith(1, null, {
-        roomOwner: "Dan",
         roomUrl: "http://invalid"
       });
 
       store.fetchServerData(fetchServerAction);
 
       sinon.assert.calledOnce(dispatcher.dispatch);
       sinon.assert.calledWithExactly(dispatcher.dispatch,
         new sharedActions.UpdateRoomInfo({
           roomInfoFailure: ROOM_INFO_FAILURES.NO_DATA,
-          roomOwner: "Dan",
           roomState: ROOM_STATES.READY,
           roomUrl: "http://invalid"
         }));
     });
 
     describe("mozLoop.rooms.get returns roomName as a separate field (no context)", function() {
       it("should dispatch UpdateRoomInfo if mozLoop.rooms.get is successful", function() {
         var roomDetails = {
           roomName: "fakeName",
-          roomUrl: "http://invalid",
-          roomOwner: "gavin"
+          roomUrl: "http://invalid"
         };
 
         fakeMozLoop.rooms.get.callsArgWith(1, null, roomDetails);
 
         store.fetchServerData(fetchServerAction);
 
         sinon.assert.calledOnce(dispatcher.dispatch);
         sinon.assert.calledWithExactly(dispatcher.dispatch,
@@ -465,22 +460,20 @@ describe("loop.store.ActiveRoomStore", f
     describe("mozLoop.rooms.get returns encryptedContext", function() {
       var roomDetails, expectedDetails;
 
       beforeEach(function() {
         roomDetails = {
           context: {
             value: "fakeContext"
           },
-          roomUrl: "http://invalid",
-          roomOwner: "Mark"
+          roomUrl: "http://invalid"
         };
         expectedDetails = {
-          roomUrl: "http://invalid",
-          roomOwner: "Mark"
+          roomUrl: "http://invalid"
         };
 
         fakeMozLoop.rooms.get.callsArgWith(1, null, roomDetails);
 
         sandbox.stub(loop.crypto, "isSupported").returns(true);
       });
 
       it("should dispatch UpdateRoomInfo message with 'unsupported' failure if WebCrypto is unsupported", function() {
@@ -592,17 +585,16 @@ describe("loop.store.ActiveRoomStore", f
   });
 
   describe("#setupRoomInfo", function() {
     var fakeRoomInfo;
 
     beforeEach(function() {
       fakeRoomInfo = {
         roomName: "Its a room",
-        roomOwner: "Me",
         roomToken: "fakeToken",
         roomUrl: "http://invalid",
         socialShareProviders: []
       };
     });
 
     it("should set the state to READY", function() {
       store.setupRoomInfo(new sharedActions.SetupRoomInfo(fakeRoomInfo));
@@ -610,45 +602,42 @@ describe("loop.store.ActiveRoomStore", f
       expect(store._storeState.roomState).eql(ROOM_STATES.READY);
     });
 
     it("should save the room information", function() {
       store.setupRoomInfo(new sharedActions.SetupRoomInfo(fakeRoomInfo));
 
       var state = store.getStoreState();
       expect(state.roomName).eql(fakeRoomInfo.roomName);
-      expect(state.roomOwner).eql(fakeRoomInfo.roomOwner);
       expect(state.roomToken).eql(fakeRoomInfo.roomToken);
       expect(state.roomUrl).eql(fakeRoomInfo.roomUrl);
       expect(state.socialShareProviders).eql([]);
     });
   });
 
   describe("#updateRoomInfo", function() {
     var fakeRoomInfo;
 
     beforeEach(function() {
       fakeRoomInfo = {
         roomName: "Its a room",
-        roomOwner: "Me",
         roomUrl: "http://invalid",
         urls: [{
           description: "fake site",
           location: "http://invalid.com",
           thumbnail: "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
         }]
       };
     });
 
     it("should save the room information", function() {
       store.updateRoomInfo(new sharedActions.UpdateRoomInfo(fakeRoomInfo));
 
       var state = store.getStoreState();
       expect(state.roomName).eql(fakeRoomInfo.roomName);
-      expect(state.roomOwner).eql(fakeRoomInfo.roomOwner);
       expect(state.roomUrl).eql(fakeRoomInfo.roomUrl);
       expect(state.roomContextUrls).eql(fakeRoomInfo.urls);
     });
   });
 
   describe("#updateSocialShareInfo", function() {
     var fakeSocialShareInfo;
 
@@ -1498,17 +1487,16 @@ describe("loop.store.ActiveRoomStore", f
     });
   });
 
   describe("Events", function() {
     describe("update:{roomToken}", function() {
       beforeEach(function() {
         store.setupRoomInfo(new sharedActions.SetupRoomInfo({
           roomName: "Its a room",
-          roomOwner: "Me",
           roomToken: "fakeToken",
           roomUrl: "http://invalid",
           socialShareProviders: []
         }));
       });
 
       it("should dispatch an UpdateRoomInfo action", function() {
         sinon.assert.calledTwice(fakeMozLoop.rooms.on);
@@ -1516,60 +1504,56 @@ describe("loop.store.ActiveRoomStore", f
         var fakeRoomData = {
           decryptedContext: {
             description: "fakeDescription",
             roomName: "fakeName",
             urls: {
               fake: "url"
             }
           },
-          roomOwner: "you",
           roomUrl: "original"
         };
 
         fakeMozLoop.rooms.on.callArgWith(1, "update", fakeRoomData);
 
         sinon.assert.calledOnce(dispatcher.dispatch);
         sinon.assert.calledWithExactly(dispatcher.dispatch,
           new sharedActions.UpdateRoomInfo({
             description: "fakeDescription",
             roomName: fakeRoomData.decryptedContext.roomName,
-            roomOwner: fakeRoomData.roomOwner,
             roomUrl: fakeRoomData.roomUrl,
             urls: {
               fake: "url"
             }
           }));
       });
 
       it("should call close window", function() {
         var fakeRoomData = {
           decryptedContext: {
             description: "fakeDescription",
             roomName: "fakeName",
             urls: {
               fake: "url"
             }
           },
-          roomOwner: "you",
           roomUrl: "original"
         };
 
         fakeMozLoop.rooms.on.callArgWith(1, "update", fakeRoomData);
 
         sinon.assert.calledOnce(window.close);
       });
     });
 
     describe("delete:{roomToken}", function() {
       var fakeRoomData = {
         decryptedContext: {
           roomName: "Its a room"
         },
-        roomOwner: "Me",
         roomToken: "fakeToken",
         roomUrl: "http://invalid"
       };
 
       beforeEach(function() {
         store.setupRoomInfo(new sharedActions.SetupRoomInfo(
           _.extend(fakeRoomData, {
             socialShareProviders: []
--- a/browser/components/loop/test/shared/textChatStore_test.js
+++ b/browser/components/loop/test/shared/textChatStore_test.js
@@ -151,34 +151,32 @@ describe("loop.store.TextChatStore", fun
         new CustomEvent("LoopChatMessageAppended"));
     });
   });
 
   describe("#updateRoomInfo", function() {
     it("should add the room name to the list", function() {
       store.updateRoomInfo(new sharedActions.UpdateRoomInfo({
         roomName: "Let's share!",
-        roomOwner: "Mark",
         roomUrl: "fake"
       }));
 
       expect(store.getStoreState("messageList")).eql([{
         type: CHAT_MESSAGE_TYPES.SPECIAL,
         contentType: CHAT_CONTENT_TYPES.ROOM_NAME,
         message: "Let's share!",
         extraData: undefined,
         sentTimestamp: undefined,
         receivedTimestamp: undefined
       }]);
     });
 
     it("should add the context to the list", function() {
       store.updateRoomInfo(new sharedActions.UpdateRoomInfo({
         roomName: "Let's share!",
-        roomOwner: "Mark",
         roomUrl: "fake",
         urls: [{
           description: "A wonderful event",
           location: "http://wonderful.invalid",
           thumbnail: "fake"
         }]
       }));
 
@@ -201,17 +199,16 @@ describe("loop.store.TextChatStore", fun
             thumbnail: "fake"
           }
         }
       ]);
     });
 
     it("should not add more than one context message", function() {
       store.updateRoomInfo(new sharedActions.UpdateRoomInfo({
-        roomOwner: "Mark",
         roomUrl: "fake",
         urls: [{
           description: "A wonderful event",
           location: "http://wonderful.invalid",
           thumbnail: "fake"
         }]
       }));
 
@@ -223,17 +220,16 @@ describe("loop.store.TextChatStore", fun
         receivedTimestamp: undefined,
         extraData: {
           location: "http://wonderful.invalid",
           thumbnail: "fake"
         }
       }]);
 
       store.updateRoomInfo(new sharedActions.UpdateRoomInfo({
-        roomOwner: "Mark",
         roomUrl: "fake",
         urls: [{
           description: "A wonderful event2",
           location: "http://wonderful.invalid2",
           thumbnail: "fake2"
         }]
       }));
 
@@ -248,16 +244,15 @@ describe("loop.store.TextChatStore", fun
           thumbnail: "fake2"
         }
       }]);
     });
 
     it("should not dispatch a LoopChatMessageAppended event", function() {
       store.updateRoomInfo(new sharedActions.UpdateRoomInfo({
         roomName: "Let's share!",
-        roomOwner: "Mark",
         roomUrl: "fake"
       }));
 
       sinon.assert.notCalled(window.dispatchEvent);
     });
   });
 });
--- a/browser/components/loop/test/shared/textChatView_test.js
+++ b/browser/components/loop/test/shared/textChatView_test.js
@@ -535,17 +535,16 @@ describe("loop.shared.views.TextChatView
 
     it("should render a room name special entry", function() {
       view = mountTestComponent({
         showRoomName: true
       });
 
       store.updateRoomInfo(new sharedActions.UpdateRoomInfo({
         roomName: "A wonderful surprise!",
-        roomOwner: "Chris",
         roomUrl: "Fake"
       }));
 
       var node = view.getDOMNode();
       expect(node.querySelector(".text-chat-entries")).to.not.eql(null);
 
       var entries = node.querySelectorAll(".text-chat-entry");
       expect(entries.length).eql(1);
@@ -553,17 +552,16 @@ describe("loop.shared.views.TextChatView
       expect(entries[0].classList.contains("room-name")).eql(true);
     });
 
     it("should render a special entry for the context url", function() {
       view = mountTestComponent();
 
       store.updateRoomInfo(new sharedActions.UpdateRoomInfo({
         roomName: "A Very Long Conversation Name",
-        roomOwner: "fake",
         roomUrl: "http://showcase",
         urls: [{
           description: "A wonderful page!",
           location: "http://wonderful.invalid"
           // use the fallback thumbnail
         }]
       }));
 
--- a/browser/components/loop/test/standalone/standaloneMozLoop_test.js
+++ b/browser/components/loop/test/standalone/standaloneMozLoop_test.js
@@ -78,18 +78,17 @@ describe("loop.StandaloneMozLoop", funct
       expect(requests[0].method).eql("GET");
     });
 
     it("should call the callback with success parameters", function() {
       mozLoop.rooms.get("fakeToken", callback);
 
       var roomDetails = {
         roomName: "fakeName",
-        roomUrl: "http://invalid",
-        roomOwner: "gavin"
+        roomUrl: "http://invalid"
       };
 
       requests[0].respond(200, {"Content-Type": "application/json"},
         JSON.stringify(roomDetails));
 
       sinon.assert.calledOnce(callback);
       sinon.assert.calledWithExactly(callback, null, roomDetails);
     });
--- a/browser/components/loop/ui/fake-mozLoop.js
+++ b/browser/components/loop/ui/fake-mozLoop.js
@@ -10,43 +10,40 @@ var fakeRooms = [
       "roomName": "First Room Name",
       "urls": [{
         description: "The mozilla page",
         location: "https://www.mozilla.org",
         thumbnail: "https://www.mozilla.org/favicon.ico"
       }]
     },
     "roomUrl": "http://localhost:3000/rooms/_nxD4V4FflQ",
-    "roomOwner": "Alexis",
     "maxSize": 2,
     "creationTime": 1405517546,
     "ctime": 1405517546,
     "expiresAt": 1405534180,
     "participants": []
   },
   {
     "roomToken": "QzBbvGmIZWU",
     "decryptedContext": {
       "roomName": "Second Room Name"
     },
     "roomUrl": "http://localhost:3000/rooms/QzBbvGmIZWU",
-    "roomOwner": "Alexis",
     "maxSize": 2,
     "creationTime": 1405517546,
     "ctime": 1405517546,
     "expiresAt": 1405534180,
     "participants": []
   },
   {
     "roomToken": "3jKS_Els9IU",
     "decryptedContext": {
       "roomName": "UX Discussion"
     },
     "roomUrl": "http://localhost:3000/rooms/3jKS_Els9IU",
-    "roomOwner": "Alexis",
     "maxSize": 2,
     "clientMaxSize": 2,
     "creationTime": 1405517546,
     "ctime": 1405517818,
     "expiresAt": 1405534180,
     "participants": [
        { "displayName": "Alexis", "account": "alexis@example.com", "roomConnectionId": "2a1787a6-4a73-43b5-ae3e-906ec1e763cb" },
        { "displayName": "Adam", "roomConnectionId": "781f012b-f1ea-4ce1-9105-7cfc36fb4ec7" }
--- a/browser/components/loop/ui/ui-showcase.js
+++ b/browser/components/loop/ui/ui-showcase.js
@@ -380,17 +380,16 @@
   var conversationStores = [];
   for (var index = 0; index < 5; index++) {
     conversationStores[index] = makeConversationStore();
   }
 
   // Update the text chat store with the room info.
   textChatStore.updateRoomInfo(new sharedActions.UpdateRoomInfo({
     roomName: "A Very Long Conversation Name",
-    roomOwner: "fake",
     roomUrl: "http://showcase",
     urls: [{
       description: "A wonderful page!",
       location: "http://wonderful.invalid"
       // use the fallback thumbnail
     }]
   }));
 
--- a/browser/components/loop/ui/ui-showcase.jsx
+++ b/browser/components/loop/ui/ui-showcase.jsx
@@ -380,17 +380,16 @@
   var conversationStores = [];
   for (var index = 0; index < 5; index++) {
     conversationStores[index] = makeConversationStore();
   }
 
   // Update the text chat store with the room info.
   textChatStore.updateRoomInfo(new sharedActions.UpdateRoomInfo({
     roomName: "A Very Long Conversation Name",
-    roomOwner: "fake",
     roomUrl: "http://showcase",
     urls: [{
       description: "A wonderful page!",
       location: "http://wonderful.invalid"
       // use the fallback thumbnail
     }]
   }));