diff --git a/app/assets/javascripts/app/views/conversations_form_view.js b/app/assets/javascripts/app/views/conversations_form_view.js index 74f848de3..e3b553b7a 100644 --- a/app/assets/javascripts/app/views/conversations_form_view.js +++ b/app/assets/javascripts/app/views/conversations_form_view.js @@ -1,6 +1,6 @@ // @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", events: { @@ -39,8 +39,9 @@ app.views.ConversationsForm = Backbone.View.extend({ this.conversationRecipients.push(person); this.updateContactIdsListInput(); /* 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 */ + this.setupAvatarFallback(personEl); }, prefill: function(handles) { diff --git a/app/assets/javascripts/app/views/conversations_inbox_view.js b/app/assets/javascripts/app/views/conversations_inbox_view.js index 4e301a8a0..67292cc75 100644 --- a/app/assets/javascripts/app/views/conversations_inbox_view.js +++ b/app/assets/javascripts/app/views/conversations_inbox_view.js @@ -1,6 +1,6 @@ // @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", events: { @@ -46,6 +46,7 @@ app.views.ConversationsInbox = Backbone.View.extend({ setupConversation: function() { app.helpers.timeago($(this.el)); $(".control-icons a").tooltip({placement: "bottom"}); + this.setupAvatarFallback(this.$el); var conv = $(".conversation-wrapper .stream-element.selected"), cBadge = $("#conversations-link .badge"); diff --git a/spec/javascripts/app/views/conversations_form_view_spec.js b/spec/javascripts/app/views/conversations_form_view_spec.js index 46c170f3a..232a7f7de 100644 --- a/spec/javascripts/app/views/conversations_form_view_spec.js +++ b/spec/javascripts/app/views/conversations_form_view_spec.js @@ -60,6 +60,12 @@ describe("app.views.ConversationsForm", function() { this.target.addRecipient({name: "diaspora user", handle: "diaspora-user@pod.tld"}); 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() { diff --git a/spec/javascripts/app/views/conversations_inbox_view_spec.js b/spec/javascripts/app/views/conversations_inbox_view_spec.js index 8ba41bb86..841f189f0 100644 --- a/spec/javascripts/app/views/conversations_inbox_view_spec.js +++ b/spec/javascripts/app/views/conversations_inbox_view_spec.js @@ -100,6 +100,13 @@ describe("app.views.ConversationsInbox", function() { $(".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() { expect($(".conversation-wrapper > .conversation.selected")).toHaveClass("unread"); new app.views.ConversationsInbox();