Merge branch 'next-minor' into develop

This commit is contained in:
Benjamin Neff 2017-04-08 00:00:56 +02:00
commit e91a0a57a3
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
12 changed files with 60 additions and 8 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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();
@ -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);
}
});

View file

@ -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) {

View file

@ -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");

View file

@ -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() {

View file

@ -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) {
@ -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); }
}

View file

@ -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

View file

@ -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() {

View file

@ -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();

View file

@ -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() {
@ -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")});

View file

@ -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();
});
});
});