Bug 1198841 - Brief message to invite someone to join when joining a room with someone already there [r=Standard8]
This commit is contained in:
@@ -593,8 +593,20 @@ loop.roomViews = (function(mozL10n) {
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the invitation controls should be shown.
|
||||||
|
*
|
||||||
|
* @return {Boolean} True if there's no guests.
|
||||||
|
*/
|
||||||
_shouldRenderInvitationOverlay: function() {
|
_shouldRenderInvitationOverlay: function() {
|
||||||
return (this.state.roomState !== ROOM_STATES.HAS_PARTICIPANTS);
|
var hasGuests = typeof this.state.participants === "object" &&
|
||||||
|
this.state.participants.filter(function(participant) {
|
||||||
|
return !participant.owner;
|
||||||
|
}).length > 0;
|
||||||
|
|
||||||
|
// Don't show if the room has participants whether from the room state or
|
||||||
|
// there being non-owner guests in the participants array.
|
||||||
|
return this.state.roomState !== ROOM_STATES.HAS_PARTICIPANTS && !hasGuests;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -593,8 +593,20 @@ loop.roomViews = (function(mozL10n) {
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the invitation controls should be shown.
|
||||||
|
*
|
||||||
|
* @return {Boolean} True if there's no guests.
|
||||||
|
*/
|
||||||
_shouldRenderInvitationOverlay: function() {
|
_shouldRenderInvitationOverlay: function() {
|
||||||
return (this.state.roomState !== ROOM_STATES.HAS_PARTICIPANTS);
|
var hasGuests = typeof this.state.participants === "object" &&
|
||||||
|
this.state.participants.filter(function(participant) {
|
||||||
|
return !participant.owner;
|
||||||
|
}).length > 0;
|
||||||
|
|
||||||
|
// Don't show if the room has participants whether from the room state or
|
||||||
|
// there being non-owner guests in the participants array.
|
||||||
|
return this.state.roomState !== ROOM_STATES.HAS_PARTICIPANTS && !hasGuests;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ loop.store.ActiveRoomStore = (function() {
|
|||||||
var OPTIONAL_ROOMINFO_FIELDS = {
|
var OPTIONAL_ROOMINFO_FIELDS = {
|
||||||
urls: "roomContextUrls",
|
urls: "roomContextUrls",
|
||||||
description: "roomDescription",
|
description: "roomDescription",
|
||||||
|
participants: "participants",
|
||||||
roomInfoFailure: "roomInfoFailure",
|
roomInfoFailure: "roomInfoFailure",
|
||||||
roomName: "roomName",
|
roomName: "roomName",
|
||||||
roomState: "roomState"
|
roomState: "roomState"
|
||||||
@@ -296,6 +297,7 @@ loop.store.ActiveRoomStore = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.dispatchAction(new sharedActions.SetupRoomInfo({
|
this.dispatchAction(new sharedActions.SetupRoomInfo({
|
||||||
|
participants: roomData.participants,
|
||||||
roomToken: actionData.roomToken,
|
roomToken: actionData.roomToken,
|
||||||
roomContextUrls: roomData.decryptedContext.urls,
|
roomContextUrls: roomData.decryptedContext.urls,
|
||||||
roomDescription: roomData.decryptedContext.description,
|
roomDescription: roomData.decryptedContext.description,
|
||||||
@@ -418,6 +420,7 @@ loop.store.ActiveRoomStore = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setStoreState({
|
this.setStoreState({
|
||||||
|
participants: actionData.participants,
|
||||||
roomContextUrls: actionData.roomContextUrls,
|
roomContextUrls: actionData.roomContextUrls,
|
||||||
roomDescription: actionData.roomDescription,
|
roomDescription: actionData.roomDescription,
|
||||||
roomName: actionData.roomName,
|
roomName: actionData.roomName,
|
||||||
@@ -449,7 +452,7 @@ loop.store.ActiveRoomStore = (function() {
|
|||||||
// Iterate over the optional fields that _may_ be present on the actionData
|
// Iterate over the optional fields that _may_ be present on the actionData
|
||||||
// object.
|
// object.
|
||||||
Object.keys(OPTIONAL_ROOMINFO_FIELDS).forEach(function(field) {
|
Object.keys(OPTIONAL_ROOMINFO_FIELDS).forEach(function(field) {
|
||||||
if (actionData[field]) {
|
if (actionData[field] !== undefined) {
|
||||||
newState[OPTIONAL_ROOMINFO_FIELDS[field]] = actionData[field];
|
newState[OPTIONAL_ROOMINFO_FIELDS[field]] = actionData[field];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -478,6 +481,7 @@ loop.store.ActiveRoomStore = (function() {
|
|||||||
this.dispatchAction(new sharedActions.UpdateRoomInfo({
|
this.dispatchAction(new sharedActions.UpdateRoomInfo({
|
||||||
urls: roomData.decryptedContext.urls,
|
urls: roomData.decryptedContext.urls,
|
||||||
description: roomData.decryptedContext.description,
|
description: roomData.decryptedContext.description,
|
||||||
|
participants: roomData.participants,
|
||||||
roomName: roomData.decryptedContext.roomName,
|
roomName: roomData.decryptedContext.roomName,
|
||||||
roomUrl: roomData.roomUrl
|
roomUrl: roomData.roomUrl
|
||||||
}));
|
}));
|
||||||
@@ -792,7 +796,16 @@ loop.store.ActiveRoomStore = (function() {
|
|||||||
* one participantleaves.
|
* one participantleaves.
|
||||||
*/
|
*/
|
||||||
remotePeerDisconnected: function() {
|
remotePeerDisconnected: function() {
|
||||||
|
// Update the participants to just the owner.
|
||||||
|
var participants = this.getStoreState("participants");
|
||||||
|
if (participants) {
|
||||||
|
participants = participants.filter(function(participant) {
|
||||||
|
return participant.owner;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.setStoreState({
|
this.setStoreState({
|
||||||
|
participants: participants,
|
||||||
roomState: ROOM_STATES.SESSION_CONNECTED,
|
roomState: ROOM_STATES.SESSION_CONNECTED,
|
||||||
remoteSrcVideoObject: null
|
remoteSrcVideoObject: null
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -470,8 +470,51 @@ describe("loop.roomViews", function () {
|
|||||||
|
|
||||||
view = mountTestComponent();
|
view = mountTestComponent();
|
||||||
|
|
||||||
|
expect(TestUtils.findRenderedComponentWithType(view,
|
||||||
|
loop.roomViews.DesktopRoomInvitationView).getDOMNode()).to.not.eql(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should render the DesktopRoomInvitationView if roomState is `JOINED` with just owner",
|
||||||
|
function() {
|
||||||
|
activeRoomStore.setStoreState({
|
||||||
|
participants: [{owner: true}],
|
||||||
|
roomState: ROOM_STATES.JOINED
|
||||||
|
});
|
||||||
|
|
||||||
|
view = mountTestComponent();
|
||||||
|
|
||||||
|
expect(TestUtils.findRenderedComponentWithType(view,
|
||||||
|
loop.roomViews.DesktopRoomInvitationView).getDOMNode()).to.not.eql(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should render the DesktopRoomConversationView if roomState is `JOINED` with remote participant",
|
||||||
|
function() {
|
||||||
|
activeRoomStore.setStoreState({
|
||||||
|
participants: [{}],
|
||||||
|
roomState: ROOM_STATES.JOINED
|
||||||
|
});
|
||||||
|
|
||||||
|
view = mountTestComponent();
|
||||||
|
|
||||||
TestUtils.findRenderedComponentWithType(view,
|
TestUtils.findRenderedComponentWithType(view,
|
||||||
loop.roomViews.DesktopRoomInvitationView);
|
loop.roomViews.DesktopRoomConversationView);
|
||||||
|
expect(TestUtils.findRenderedComponentWithType(view,
|
||||||
|
loop.roomViews.DesktopRoomInvitationView).getDOMNode()).to.eql(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should render the DesktopRoomConversationView if roomState is `JOINED` with participants",
|
||||||
|
function() {
|
||||||
|
activeRoomStore.setStoreState({
|
||||||
|
participants: [{owner: true}, {}],
|
||||||
|
roomState: ROOM_STATES.JOINED
|
||||||
|
});
|
||||||
|
|
||||||
|
view = mountTestComponent();
|
||||||
|
|
||||||
|
TestUtils.findRenderedComponentWithType(view,
|
||||||
|
loop.roomViews.DesktopRoomConversationView);
|
||||||
|
expect(TestUtils.findRenderedComponentWithType(view,
|
||||||
|
loop.roomViews.DesktopRoomInvitationView).getDOMNode()).to.eql(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render the DesktopRoomConversationView if roomState is `HAS_PARTICIPANTS`",
|
it("should render the DesktopRoomConversationView if roomState is `HAS_PARTICIPANTS`",
|
||||||
@@ -482,6 +525,8 @@ describe("loop.roomViews", function () {
|
|||||||
|
|
||||||
TestUtils.findRenderedComponentWithType(view,
|
TestUtils.findRenderedComponentWithType(view,
|
||||||
loop.roomViews.DesktopRoomConversationView);
|
loop.roomViews.DesktopRoomConversationView);
|
||||||
|
expect(TestUtils.findRenderedComponentWithType(view,
|
||||||
|
loop.roomViews.DesktopRoomInvitationView).getDOMNode()).to.eql(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call onCallTerminated when the call ended", function() {
|
it("should call onCallTerminated when the call ended", function() {
|
||||||
|
|||||||
@@ -310,6 +310,7 @@ describe("loop.store.ActiveRoomStore", function () {
|
|||||||
decryptedContext: {
|
decryptedContext: {
|
||||||
roomName: "Monkeys"
|
roomName: "Monkeys"
|
||||||
},
|
},
|
||||||
|
participants: [],
|
||||||
roomUrl: "http://invalid"
|
roomUrl: "http://invalid"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -350,6 +351,7 @@ describe("loop.store.ActiveRoomStore", function () {
|
|||||||
new sharedActions.SetupRoomInfo({
|
new sharedActions.SetupRoomInfo({
|
||||||
roomContextUrls: undefined,
|
roomContextUrls: undefined,
|
||||||
roomDescription: undefined,
|
roomDescription: undefined,
|
||||||
|
participants: [],
|
||||||
roomToken: fakeToken,
|
roomToken: fakeToken,
|
||||||
roomName: fakeRoomData.decryptedContext.roomName,
|
roomName: fakeRoomData.decryptedContext.roomName,
|
||||||
roomUrl: fakeRoomData.roomUrl,
|
roomUrl: fakeRoomData.roomUrl,
|
||||||
@@ -1277,6 +1279,30 @@ describe("loop.store.ActiveRoomStore", function () {
|
|||||||
|
|
||||||
expect(store.getStoreState().remoteSrcVideoObject).eql(null);
|
expect(store.getStoreState().remoteSrcVideoObject).eql(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should remove non-owner participants", function() {
|
||||||
|
store.setStoreState({
|
||||||
|
participants: [{owner: true}, {}]
|
||||||
|
});
|
||||||
|
|
||||||
|
store.remotePeerDisconnected();
|
||||||
|
|
||||||
|
var participants = store.getStoreState().participants;
|
||||||
|
expect(participants).to.have.length.of(1);
|
||||||
|
expect(participants[0].owner).eql(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should keep the owner participant", function() {
|
||||||
|
store.setStoreState({
|
||||||
|
participants: [{owner: true}]
|
||||||
|
});
|
||||||
|
|
||||||
|
store.remotePeerDisconnected();
|
||||||
|
|
||||||
|
var participants = store.getStoreState().participants;
|
||||||
|
expect(participants).to.have.length.of(1);
|
||||||
|
expect(participants[0].owner).eql(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#connectionStatus", function() {
|
describe("#connectionStatus", function() {
|
||||||
@@ -1518,6 +1544,7 @@ describe("loop.store.ActiveRoomStore", function () {
|
|||||||
sinon.assert.calledWithExactly(dispatcher.dispatch,
|
sinon.assert.calledWithExactly(dispatcher.dispatch,
|
||||||
new sharedActions.UpdateRoomInfo({
|
new sharedActions.UpdateRoomInfo({
|
||||||
description: "fakeDescription",
|
description: "fakeDescription",
|
||||||
|
participants: undefined,
|
||||||
roomName: fakeRoomData.decryptedContext.roomName,
|
roomName: fakeRoomData.decryptedContext.roomName,
|
||||||
roomUrl: fakeRoomData.roomUrl,
|
roomUrl: fakeRoomData.roomUrl,
|
||||||
urls: {
|
urls: {
|
||||||
|
|||||||
Reference in New Issue
Block a user