Bug 1198841 - Brief message to invite someone to join when joining a room with someone already there [r=Standard8]

This commit is contained in:
Ed Lee 2015-08-28 01:39:59 -07:00
Родитель 4e38c09086
Коммит 40e617bca3
5 изменённых файлов: 113 добавлений и 4 удалений

Просмотреть файл

@ -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() {
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() {
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 = {
urls: "roomContextUrls",
description: "roomDescription",
participants: "participants",
roomInfoFailure: "roomInfoFailure",
roomName: "roomName",
roomState: "roomState"
@ -296,6 +297,7 @@ loop.store.ActiveRoomStore = (function() {
}
this.dispatchAction(new sharedActions.SetupRoomInfo({
participants: roomData.participants,
roomToken: actionData.roomToken,
roomContextUrls: roomData.decryptedContext.urls,
roomDescription: roomData.decryptedContext.description,
@ -418,6 +420,7 @@ loop.store.ActiveRoomStore = (function() {
}
this.setStoreState({
participants: actionData.participants,
roomContextUrls: actionData.roomContextUrls,
roomDescription: actionData.roomDescription,
roomName: actionData.roomName,
@ -449,7 +452,7 @@ loop.store.ActiveRoomStore = (function() {
// Iterate over the optional fields that _may_ be present on the actionData
// object.
Object.keys(OPTIONAL_ROOMINFO_FIELDS).forEach(function(field) {
if (actionData[field]) {
if (actionData[field] !== undefined) {
newState[OPTIONAL_ROOMINFO_FIELDS[field]] = actionData[field];
}
});
@ -478,6 +481,7 @@ loop.store.ActiveRoomStore = (function() {
this.dispatchAction(new sharedActions.UpdateRoomInfo({
urls: roomData.decryptedContext.urls,
description: roomData.decryptedContext.description,
participants: roomData.participants,
roomName: roomData.decryptedContext.roomName,
roomUrl: roomData.roomUrl
}));
@ -792,7 +796,16 @@ loop.store.ActiveRoomStore = (function() {
* one participantleaves.
*/
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({
participants: participants,
roomState: ROOM_STATES.SESSION_CONNECTED,
remoteSrcVideoObject: null
});

Просмотреть файл

@ -470,8 +470,51 @@ describe("loop.roomViews", function () {
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,
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`",
@ -482,6 +525,8 @@ describe("loop.roomViews", function () {
TestUtils.findRenderedComponentWithType(view,
loop.roomViews.DesktopRoomConversationView);
expect(TestUtils.findRenderedComponentWithType(view,
loop.roomViews.DesktopRoomInvitationView).getDOMNode()).to.eql(null);
});
it("should call onCallTerminated when the call ended", function() {

Просмотреть файл

@ -310,6 +310,7 @@ describe("loop.store.ActiveRoomStore", function () {
decryptedContext: {
roomName: "Monkeys"
},
participants: [],
roomUrl: "http://invalid"
};
@ -350,6 +351,7 @@ describe("loop.store.ActiveRoomStore", function () {
new sharedActions.SetupRoomInfo({
roomContextUrls: undefined,
roomDescription: undefined,
participants: [],
roomToken: fakeToken,
roomName: fakeRoomData.decryptedContext.roomName,
roomUrl: fakeRoomData.roomUrl,
@ -1277,6 +1279,30 @@ describe("loop.store.ActiveRoomStore", function () {
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() {
@ -1518,6 +1544,7 @@ describe("loop.store.ActiveRoomStore", function () {
sinon.assert.calledWithExactly(dispatcher.dispatch,
new sharedActions.UpdateRoomInfo({
description: "fakeDescription",
participants: undefined,
roomName: fakeRoomData.decryptedContext.roomName,
roomUrl: fakeRoomData.roomUrl,
urls: {