Skip to content

Commit

Permalink
Only reload profile header when changing aspect memberships
Browse files Browse the repository at this point in the history
closes #7183

fixes #7072
  • Loading branch information
svbergerem authored and SuperTux88 committed Nov 15, 2016
1 parent 3930069 commit a951c40
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -6,6 +6,7 @@
## Bug fixes
* Fix fetching comments after fetching likes [#7167](https://github.com/diaspora/diaspora/pull/7167)
* Hide 'reshare' button on already reshared posts [#7169](https://github.com/diaspora/diaspora/pull/7169)
* Only reload profile header when changing aspect memberships [#7183](https://github.com/diaspora/diaspora/pull/7183)

## Features
* Show spinner when loading comments in the stream [#7170](https://github.com/diaspora/diaspora/pull/7170)
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/app/pages/profile.js
Expand Up @@ -31,7 +31,6 @@ app.pages.Profile = app.views.Base.extend({
this.streamCollection = _.has(opts, "streamCollection") ? opts.streamCollection : null;
this.streamViewClass = _.has(opts, "streamView") ? opts.streamView : null;

this.model.on("change", this.render, this);
this.model.on("sync", this._done, this);

// bind to global events
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/app/views/profile_header_view.js
Expand Up @@ -15,6 +15,7 @@ app.views.ProfileHeader = app.views.Base.extend({
initialize: function(opts) {
this.photos = _.has(opts, 'photos') ? opts.photos : null;
this.contacts = _.has(opts, 'contacts') ? opts.contacts : null;
this.model.on("change", this.render, this);
$("#mentionModal").on("modal:loaded", this.mentionModalLoaded.bind(this));
$("#mentionModal").on("hidden.bs.modal", this.mentionModalHidden);
},
Expand Down
28 changes: 28 additions & 0 deletions spec/javascripts/app/views/profile_header_view_spec.js
Expand Up @@ -11,6 +11,34 @@ describe("app.views.ProfileHeader", function() {
loginAs(factory.userAttrs());
});

describe("initialize", function() {
it("calls #render when the model changes", function() {
spyOn(app.views.ProfileHeader.prototype, "render");
this.view.initialize();
expect(app.views.ProfileHeader.prototype.render).not.toHaveBeenCalled();
this.view.model.trigger("change");
expect(app.views.ProfileHeader.prototype.render).toHaveBeenCalled();
});

it("calls #mentionModalLoaded on modal:loaded", function() {
spec.content().append("<div id='mentionModal'></div>");
spyOn(app.views.ProfileHeader.prototype, "mentionModalLoaded");
this.view.initialize();
expect(app.views.ProfileHeader.prototype.mentionModalLoaded).not.toHaveBeenCalled();
$("#mentionModal").trigger("modal:loaded");
expect(app.views.ProfileHeader.prototype.mentionModalLoaded).toHaveBeenCalled();
});

it("calls #mentionModalHidden on hidden.bs.modal", function() {
spec.content().append("<div id='mentionModal'></div>");
spyOn(app.views.ProfileHeader.prototype, "mentionModalHidden");
this.view.initialize();
expect(app.views.ProfileHeader.prototype.mentionModalHidden).not.toHaveBeenCalled();
$("#mentionModal").trigger("hidden.bs.modal");
expect(app.views.ProfileHeader.prototype.mentionModalHidden).toHaveBeenCalled();
});
});

context("#presenter", function() {
it("contains necessary elements", function() {
expect(this.view.presenter()).toEqual(jasmine.objectContaining({
Expand Down

0 comments on commit a951c40

Please sign in to comment.