mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Adding new profile models when refreshing story comments.
This commit is contained in:
parent
3e2e6e272b
commit
68b69437fb
5 changed files with 26 additions and 8 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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...');
|
||||
}
|
||||
|
||||
});
|
|
@ -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();
|
||||
|
|
|
@ -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'))
|
||||
])
|
||||
]))
|
||||
])
|
||||
])
|
||||
]));
|
||||
|
|
Loading…
Add table
Reference in a new issue