Bug 1219600 - Add a fallback method for handling Hello room titles, r=Mardak

This commit is contained in:
David Critchley 2015-11-13 16:59:26 -08:00
Родитель 504fa4aba6
Коммит a136f8e183
5 изменённых файлов: 130 добавлений и 6 удалений

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

@ -441,10 +441,10 @@ loop.panel = (function(_, mozL10n) {
"room-active": this._isActive(),
"room-opened": this.props.isOpenedRoom
});
var urlData = (this.props.room.decryptedContext.urls || [])[0] || {};
var roomTitle = this.props.room.decryptedContext.roomName ||
this.props.room.decryptedContext.urls[0].description ||
this.props.room.decryptedContext.urls[0].location;
urlData.description || urlData.location ||
mozL10n.get("room_name_untitled_page");
return (
React.createElement("div", {className: roomClasses,

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

@ -441,10 +441,10 @@ loop.panel = (function(_, mozL10n) {
"room-active": this._isActive(),
"room-opened": this.props.isOpenedRoom
});
var urlData = (this.props.room.decryptedContext.urls || [])[0] || {};
var roomTitle = this.props.room.decryptedContext.roomName ||
this.props.room.decryptedContext.urls[0].description ||
this.props.room.decryptedContext.urls[0].location;
urlData.description || urlData.location ||
mozL10n.get("room_name_untitled_page");
return (
<div className={roomClasses}

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

@ -956,6 +956,93 @@ describe("loop.panel", function() {
expect(node.querySelectorAll(".room-entry").length).to.eql(1);
expect(node.querySelectorAll(".room-opened h2")[0].textContent).to.equal(roomName);
});
it("should show Page Title as Room Name if a Room Name is not given", function() {
var urlsRoomData = {
roomToken: "QzBbvGmIZWU",
roomUrl: "http://sample/QzBbvGmIZWU",
decryptedContext: {
urls: [{
description: "Page Title",
location: "http://example.com"
}]
},
maxSize: 2,
participants: [{
displayName: "Alexis",
account: "alexis@example.com",
roomConnectionId: "2a1787a6-4a73-43b5-ae3e-906ec1e763cb"
}, {
displayName: "Adam",
roomConnectionId: "781f012b-f1ea-4ce1-9105-7cfc36fb4ec7"
}],
ctime: 1405517418
};
roomStore.setStoreState({ rooms: [new loop.store.Room(urlsRoomData)] });
var view = createTestComponent();
var node = view.getDOMNode();
expect(node.querySelector(".room-entry h2").textContent).to.equal("Page Title");
});
it("should show Page URL as Room Name if a Room Name and Page Title are not available", function() {
var urlsRoomData = {
roomToken: "QzBbvGmIZWU",
roomUrl: "http://sample/QzBbvGmIZWU",
decryptedContext: {
urls: [{
description: "",
location: "http://example.com"
}]
},
maxSize: 2,
participants: [{
displayName: "Alexis",
account: "alexis@example.com",
roomConnectionId: "2a1787a6-4a73-43b5-ae3e-906ec1e763cb"
}, {
displayName: "Adam",
roomConnectionId: "781f012b-f1ea-4ce1-9105-7cfc36fb4ec7"
}],
ctime: 1405517418
};
roomStore.setStoreState({ rooms: [new loop.store.Room(urlsRoomData)] });
var view = createTestComponent();
var node = view.getDOMNode();
expect(node.querySelector(".room-entry h2").textContent).to.equal("http://example.com");
});
it("should show Fallback Title as Room Name if a Room Name,Page Title and Page Url are not available", function() {
var urlsRoomData = {
roomToken: "QzBbvGmIZWU",
roomUrl: "http://sample/QzBbvGmIZWU",
decryptedContext: {
urls: [{
description: "",
location: ""
}]
},
maxSize: 2,
participants: [{
displayName: "Alexis",
account: "alexis@example.com",
roomConnectionId: "2a1787a6-4a73-43b5-ae3e-906ec1e763cb"
}, {
displayName: "Adam",
roomConnectionId: "781f012b-f1ea-4ce1-9105-7cfc36fb4ec7"
}],
ctime: 1405517418
};
roomStore.setStoreState({ rooms: [new loop.store.Room(urlsRoomData)] });
var view = createTestComponent();
var node = view.getDOMNode();
expect(node.querySelector(".room-entry h2").textContent).to.equal("Fake title");
});
});
describe("loop.panel.NewRoomView", function() {

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

@ -100,6 +100,42 @@ var fakeRooms = [
"ctime": 1405576934,
"expiresAt": 1405614180,
"participants": []
},
{
"roomToken": "preFLighdfso",
"decryptedContext": {
"roomName": "",
"urls": [
{
"description": "Page Title as Room Name",
"location": "http://mozilla.com"
}
]
},
"roomUrl": "http://localhost:3000/rooms/preFLighdfso",
"roomOwner": "Alexis",
"maxSize": 2,
"creationTime": 1405576934,
"ctime": 1405576934,
"expiresAt": 1405614180,
"participants": []
},
{
"roomToken": "preFLighdfsi",
"decryptedContext": {
"roomName": "",
"urls": [{
"description": "",
"location": "http://mozilla.com/Url_As_Room_Name"
}]
},
"roomUrl": "http://localhost:3000/rooms/preFLighdfsi",
"roomOwner": "Alexis",
"maxSize": 2,
"creationTime": 1405576934,
"ctime": 1405576934,
"expiresAt": 1405614180,
"participants": []
}
];

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

@ -194,6 +194,7 @@ rooms_room_full_call_to_action_label=Learn more about {{clientShortname}} »
rooms_room_joined_label=Someone has joined the conversation!
rooms_room_join_label=Join the conversation
rooms_signout_alert=Open conversations will be closed
room_name_untitled_page=Untitled Page
# Infobar strings