Skip to content

Commit

Permalink
Merge branch 'next-minor' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperTux88 committed Apr 7, 2017
2 parents 82629c5 + 3971a24 commit e91a0a5
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 8 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -37,6 +37,7 @@
* Fix sharing indicator on profile page for blocked users [#7382](https://github.com/diaspora/diaspora/pull/7382)
* Remove post only after a successful deletion on the server [#7385](https://github.com/diaspora/diaspora/pull/7385)
* Fix an issue where pod admins could get logged out when using sidekiq-web [#7395](https://github.com/diaspora/diaspora/pull/7395)
* Add avatar fallback for typeahead and conversations [#7414](https://github.com/diaspora/diaspora/pull/7414)

## Features
* Add links to liked and commented pages [#5502](https://github.com/diaspora/diaspora/pull/5502)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/app/router.js
Expand Up @@ -217,6 +217,7 @@ app.Router = Backbone.Router.extend({
app.shortcuts = app.shortcuts || new app.views.StreamShortcuts({el: $(document)});
if ($("#publisher").length !== 0) {
app.publisher = app.publisher || new app.views.Publisher({collection: app.stream.items});
app.page.setupAvatarFallback($(".main-stream-publisher"));
}

$("#main_stream").html(app.page.render().el);
Expand Down
7 changes: 5 additions & 2 deletions app/assets/javascripts/app/views.js
Expand Up @@ -55,8 +55,7 @@ app.views.Base = Backbone.View.extend({
.html(this.template(presenter))
.attr("data-template", _.last(this.templateName.split("/")));

// add avatar fallback if it can't be loaded
this.$el.find(this.avatars.selector).on("error", this.avatars.fallback);
this.setupAvatarFallback(this.$el);

// add placeholder support for old browsers
this.$("input, textarea").placeholder();
Expand Down Expand Up @@ -154,6 +153,10 @@ app.views.Base = Backbone.View.extend({
$(this).attr("src", ImagePaths.get("user/default.png"));
},
selector: "img.avatar"
},

setupAvatarFallback: function(el) {
el.find(this.avatars.selector).on("error", this.avatars.fallback);
}
});

Expand Down
5 changes: 3 additions & 2 deletions 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: {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion 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: {
Expand Down Expand Up @@ -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");
Expand Down
Expand Up @@ -96,7 +96,7 @@ app.views.NotificationDropdown = app.views.Base.extend({

afterNotificationChanges: function(node) {
node.find(".unread-toggle .entypo-eye").tooltip("destroy").tooltip();
node.find(this.avatars.selector).on("error", this.avatars.fallback);
this.setupAvatarFallback(node);
},

finishLoading: function() {
Expand Down
7 changes: 7 additions & 0 deletions app/assets/javascripts/app/views/search_base_view.js
Expand Up @@ -7,6 +7,7 @@ app.views.SearchBase = app.views.Base.extend({
if(options.customSearch) { this.setupCustomSearch(); }
this.setupTypeahead();
if(options.autoselect) { this.setupAutoselect(); }
this.setupTypeaheadAvatarFallback();
},

bloodhoundTokenizer: function(str) {
Expand Down Expand Up @@ -110,6 +111,12 @@ app.views.SearchBase = app.views.Base.extend({
});
},

setupTypeaheadAvatarFallback: function() {
this.typeaheadInput.on("typeahead:render", function() {
this.setupAvatarFallback(this.$el);
}.bind(this));
},

ignorePersonForSuggestions: function(person) {
if(person.handle) { this.ignoreDiasporaIds.push(person.handle); }
}
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/app/views/tags_view.js
@@ -1,12 +1,12 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later

app.views.Tags = Backbone.View.extend({
app.views.Tags = app.views.Base.extend({
initialize: function(opts) {
if(app.publisher) {
app.publisher.setText("#"+ opts.hashtagName + " ");
}
// add avatar fallback if it can't be loaded
$(app.views.Base.prototype.avatars.selector).on("error", app.views.Base.prototype.avatars.fallback);
this.setupAvatarFallback($("#tags_show"));
}
});
// @license-end
6 changes: 6 additions & 0 deletions spec/javascripts/app/views/conversations_form_view_spec.js
Expand Up @@ -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() {
Expand Down
7 changes: 7 additions & 0 deletions spec/javascripts/app/views/conversations_inbox_view_spec.js
Expand Up @@ -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();
Expand Down
19 changes: 19 additions & 0 deletions spec/javascripts/app/views/search_base_view_spec.js
Expand Up @@ -57,6 +57,12 @@ describe("app.views.SearchBase", function() {
this.view = new app.views.SearchBase({el: "#search_people_form", typeaheadInput: $("#q"), autoselect: true});
expect(app.views.SearchBase.prototype.setupAutoselect).toHaveBeenCalled();
});

it("calls setupTypeaheadAvatarFallback", function() {
spyOn(app.views.SearchBase.prototype, "setupTypeaheadAvatarFallback");
this.view = new app.views.SearchBase({el: "#search_people_form", typeaheadInput: $("#q")});
expect(app.views.SearchBase.prototype.setupTypeaheadAvatarFallback).toHaveBeenCalled();
});
});

describe("bloodhoundTokenizer", function() {
Expand Down Expand Up @@ -261,6 +267,19 @@ describe("app.views.SearchBase", function() {
});
});

describe("setupTypeaheadAvatarFallback", function() {
beforeEach(function() {
this.view = new app.views.SearchBase({el: "#search_people_form", typeaheadInput: $("#q")});
});

it("calls setupAvatarFallback when showing the results", function() {
spyOn(this.view, "setupAvatarFallback");
this.view.setupTypeaheadAvatarFallback();
this.search(this.view, "user");
expect(this.view.setupAvatarFallback).toHaveBeenCalled();
});
});

describe("ignorePersonForSuggestions", function() {
beforeEach(function() {
this.view = new app.views.SearchBase({el: "#search_people_form", typeaheadInput: $("#q")});
Expand Down
6 changes: 6 additions & 0 deletions spec/javascripts/app/views_spec.js
Expand Up @@ -163,5 +163,11 @@ describe("app.views.Base", function(){
expect(window.autosize).toHaveBeenCalled();
expect(window.autosize.calls.mostRecent().args[0].is("textarea")).toBe(true);
});

it("calls setupAvatarFallback", function() {
spyOn(this.view, "setupAvatarFallback");
this.view.renderTemplate();
expect(this.view.setupAvatarFallback).toHaveBeenCalled();
});
});
});

0 comments on commit e91a0a5

Please sign in to comment.