diff --git a/Changelog.md b/Changelog.md index 3328d4968..e35adc2cc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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) diff --git a/app/assets/javascripts/app/pages/profile.js b/app/assets/javascripts/app/pages/profile.js index b987ea387..a2b814399 100644 --- a/app/assets/javascripts/app/pages/profile.js +++ b/app/assets/javascripts/app/pages/profile.js @@ -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 diff --git a/app/assets/javascripts/app/views/profile_header_view.js b/app/assets/javascripts/app/views/profile_header_view.js index 0fc671b8e..1522b71e4 100644 --- a/app/assets/javascripts/app/views/profile_header_view.js +++ b/app/assets/javascripts/app/views/profile_header_view.js @@ -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); }, diff --git a/spec/javascripts/app/views/profile_header_view_spec.js b/spec/javascripts/app/views/profile_header_view_spec.js index 17bfecc81..ebd4ecde1 100644 --- a/spec/javascripts/app/views/profile_header_view_spec.js +++ b/spec/javascripts/app/views/profile_header_view_spec.js @@ -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("
"); + 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(""); + 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({