diff --git a/app/assets/javascripts/app/pages/profile.js b/app/assets/javascripts/app/pages/profile.js index 6d07d5271..a19499848 100644 --- a/app/assets/javascripts/app/pages/profile.js +++ b/app/assets/javascripts/app/pages/profile.js @@ -14,13 +14,23 @@ app.pages.Profile = app.views.Base.extend({ tooltipSelector: '.profile_button div, .sharing_message_container', initialize: function(opts) { - if( app.hasPreload('person') ) + if( app.hasPreload('person') ) { this.model = new app.models.Person(app.parsePreload('person')); + } else if(opts && opts.person_id) { + this.model = new app.models.Person({guid: opts.person_id}); + this.model.fetch(); + } else { + throw new Error("unable to load person"); + } + if( app.hasPreload('photos') ) this.photos = app.parsePreload('photos'); // we don't interact with it, so no model if( app.hasPreload('contacts') ) this.contacts = app.parsePreload('contacts'); // we don't interact with it, so no model + this.streamCollection = _.has(opts, 'streamCollection') ? opts.streamCollection : null; + this.streamViewClass = _.has(opts, 'streamView') ? opts.streamView : null; + this.model.on('change', this.render, this); // bind to global events @@ -31,6 +41,7 @@ app.pages.Profile = app.views.Base.extend({ }, sidebarView: function() { + if( !this.model.has('profile') ) return false; return new app.views.ProfileSidebar({ model: this.model, photos: this.photos, @@ -39,10 +50,12 @@ app.pages.Profile = app.views.Base.extend({ }, headerView: function() { + if( !this.model.has('profile') ) return false; return new app.views.ProfileHeader({model: this.model}); }, streamView: function() { + if( !this.model.has('profile') ) return false; if( this.model.isBlocked() ) { $('#main_stream').empty().html( '