Add avatar fallback for conversations view

Fixes #4991
This commit is contained in:
Steffen van Bergerem 2017-04-06 15:03:11 +02:00 committed by Benjamin Neff
parent 1c1af74e9f
commit bcb75e3082
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
4 changed files with 18 additions and 3 deletions

View file

@ -1,6 +1,6 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
app.views.ConversationsForm = Backbone.View.extend({ app.views.ConversationsForm = app.views.Base.extend({
el: ".conversations-form-container", el: ".conversations-form-container",
events: { events: {
@ -39,8 +39,9 @@ app.views.ConversationsForm = Backbone.View.extend({
this.conversationRecipients.push(person); this.conversationRecipients.push(person);
this.updateContactIdsListInput(); this.updateContactIdsListInput();
/* eslint-disable camelcase */ /* eslint-disable camelcase */
this.tagListElement.append(HandlebarsTemplates.conversation_recipient_tag_tpl(person)); var personEl = $(HandlebarsTemplates.conversation_recipient_tag_tpl(person)).appendTo(this.tagListElement);
/* eslint-enable camelcase */ /* eslint-enable camelcase */
this.setupAvatarFallback(personEl);
}, },
prefill: function(handles) { prefill: function(handles) {

View file

@ -1,6 +1,6 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
app.views.ConversationsInbox = Backbone.View.extend({ app.views.ConversationsInbox = app.views.Base.extend({
el: "#conversations-container", el: "#conversations-container",
events: { events: {
@ -46,6 +46,7 @@ app.views.ConversationsInbox = Backbone.View.extend({
setupConversation: function() { setupConversation: function() {
app.helpers.timeago($(this.el)); app.helpers.timeago($(this.el));
$(".control-icons a").tooltip({placement: "bottom"}); $(".control-icons a").tooltip({placement: "bottom"});
this.setupAvatarFallback(this.$el);
var conv = $(".conversation-wrapper .stream-element.selected"), var conv = $(".conversation-wrapper .stream-element.selected"),
cBadge = $("#conversations-link .badge"); cBadge = $("#conversations-link .badge");

View file

@ -60,6 +60,12 @@ describe("app.views.ConversationsForm", function() {
this.target.addRecipient({name: "diaspora user", handle: "diaspora-user@pod.tld"}); this.target.addRecipient({name: "diaspora user", handle: "diaspora-user@pod.tld"});
expect($(".conversation-recipient-tag").length).toBe(1); expect($(".conversation-recipient-tag").length).toBe(1);
}); });
it("calls setupAvatarFallback", function() {
spyOn(this.target, "setupAvatarFallback");
this.target.addRecipient({name: "diaspora user", handle: "diaspora-user@pod.tld"});
expect(this.target.setupAvatarFallback).toHaveBeenCalled();
});
}); });
describe("prefill", function() { describe("prefill", function() {

View file

@ -100,6 +100,13 @@ describe("app.views.ConversationsInbox", function() {
$(".conversation-wrapper > .conversation.unread").addClass("selected"); $(".conversation-wrapper > .conversation.unread").addClass("selected");
}); });
it("calls setupAvatarFallback", function() {
this.view = new app.views.ConversationsInbox();
spyOn(this.view, "setupAvatarFallback");
this.view.setupConversation();
expect(this.view.setupAvatarFallback).toHaveBeenCalled();
});
it("removes the unread class from the conversation", function() { it("removes the unread class from the conversation", function() {
expect($(".conversation-wrapper > .conversation.selected")).toHaveClass("unread"); expect($(".conversation-wrapper > .conversation.selected")).toHaveClass("unread");
new app.views.ConversationsInbox(); new app.views.ConversationsInbox();