diff --git a/apps/social/views.py b/apps/social/views.py index c219c2b56..4ebb8bf4a 100644 --- a/apps/social/views.py +++ b/apps/social/views.py @@ -207,7 +207,7 @@ def mark_story_as_shared(request): stories, profiles = MSharedStory.stories_with_comments_and_profiles([story], request.user) story = stories[0] - return {'code': code, 'story': story, 'profiles': profiles} + return {'code': code, 'story': story, 'user_profiles': profiles} def shared_stories_public(request, username): try: @@ -246,7 +246,7 @@ def profile(request): current_profile = MSocialProfile.objects.get(user_id=request.user.pk) followers_youknow, followers_everybody = current_profile.common_follows(user_id, direction='followers') following_youknow, following_everybody = current_profile.common_follows(user_id, direction='following') - + logging.user(request, "~BB~FRLoading social profile: %s" % user_profile.username) payload = { diff --git a/media/js/newsblur/common/assetmodel.js b/media/js/newsblur/common/assetmodel.js index ce651e2cd..16038d7be 100644 --- a/media/js/newsblur/common/assetmodel.js +++ b/media/js/newsblur/common/assetmodel.js @@ -243,11 +243,21 @@ NEWSBLUR.AssetModel.Reader.prototype = { }, mark_story_as_shared: function(story_id, feed_id, comments, callback, error_callback) { + var pre_callback = _.bind(function(data) { + if (data.user_profiles) { + var profiles = _.reject(data.user_profiles, _.bind(function(profile) { + return profile.user_id in this.user_profiles._byId; + }, this)); + this.user_profiles.add(profiles); + } + callback(data); + }, this); + this.make_request('/social/share_story', { story_id: story_id, feed_id: feed_id, comments: comments - }, callback, error_callback); + }, pre_callback, error_callback); }, reset_feeds: function() { diff --git a/media/js/newsblur/reader/reader_friends.js b/media/js/newsblur/reader/reader_friends.js index f21bbdd4c..ccc852fbd 100644 --- a/media/js/newsblur/reader/reader_friends.js +++ b/media/js/newsblur/reader/reader_friends.js @@ -486,11 +486,17 @@ _.extend(NEWSBLUR.ReaderFriends.prototype, { }, enable_save: function() { - $('.NB-profile-save-button', this.$modal).addClass('NB-modal-submit-green').text('Save My Profile'); + $('.NB-profile-save-button', this.$modal) + .removeClass('NB-modal-submit-close') + .addClass('NB-modal-submit-green') + .text('Save My Profile'); }, disable_save: function() { - $('.NB-profile-save-button', this.$modal).removeClass('NB-modal-submit-green').text('Change what you like above...'); + $('.NB-profile-save-button', this.$modal) + .addClass('NB-modal-submit-close') + .removeClass('NB-modal-submit-green') + .text('Change what you like above...'); } }); \ No newline at end of file diff --git a/media/js/newsblur/reader/reader_social_profile.js b/media/js/newsblur/reader/reader_social_profile.js index 0e587ffb1..3a61e08ae 100644 --- a/media/js/newsblur/reader/reader_social_profile.js +++ b/media/js/newsblur/reader/reader_social_profile.js @@ -15,7 +15,7 @@ NEWSBLUR.ReaderSocialProfile.prototype = new NEWSBLUR.Modal; _.extend(NEWSBLUR.ReaderSocialProfile.prototype, { runner: function(user_id) { - this.profile = new NEWSBLUR.Models.User(); + this.profile = this.model.user_profiles.get(user_id); this.make_modal(); this.open_modal(); _.defer(_.bind(this.fetch_profile, this, user_id)); @@ -31,6 +31,7 @@ _.extend(NEWSBLUR.ReaderSocialProfile.prototype, { }); this.$modal = $.make('div', { className: 'NB-modal NB-modal-profile' }, [ + $.make('div', { className: 'NB-modal-loading' }), $.make('div', { className: 'NB-profile-info-header' }, $(profile)), $.make('div', { className: 'NB-profile-section' }, [ $.make('h3', 'Following'), @@ -61,6 +62,7 @@ _.extend(NEWSBLUR.ReaderSocialProfile.prototype, { $('.NB-modal-loading', this.$modal).addClass('NB-active'); this.model.fetch_user_profile(user_id, _.bind(function(data) { + $('.NB-modal-loading', this.$modal).removeClass('NB-active'); this.profile.set(data.user_profile); this.populate_friends(data); callback && callback(); diff --git a/media/js/newsblur/views/social_profile_badge.js b/media/js/newsblur/views/social_profile_badge.js index 03c323713..cdf5b196d 100644 --- a/media/js/newsblur/views/social_profile_badge.js +++ b/media/js/newsblur/views/social_profile_badge.js @@ -37,14 +37,14 @@ NEWSBLUR.Views.SocialProfileBadge = Backbone.View.extend({ className: 'NB-profile-badge-website NB-splash-link' }, profile.get('website').replace('http://', ''))), $.make('div', { className: 'NB-profile-badge-bio' }, profile.get('bio')), - $.make('div', { className: 'NB-profile-badge-stats' }, [ + (_.isNumber(profile.get('shared_stories_count')) && $.make('div', { className: 'NB-profile-badge-stats' }, [ $.make('span', { className: 'NB-count' }, profile.get('shared_stories_count')), 'shared ', Inflector.pluralize('story', profile.get('shared_stories_count')), ' · ', $.make('span', { className: 'NB-count' }, profile.get('follower_count')), Inflector.pluralize('follower', profile.get('follower_count')) - ]) + ])) ]) ]) ]));