Skip to content

Commit

Permalink
FIX: don't stop youtube when liking a post
Browse files Browse the repository at this point in the history
Also fixes post action create/destroy api not to include post raw.
  • Loading branch information
SamSaffron committed Sep 25, 2014
1 parent c43f645 commit e14e8f6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
16 changes: 14 additions & 2 deletions app/assets/javascripts/discourse/models/_post.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,24 @@ Discourse.Post = Discourse.Model.extend({
updateFromJson: function(obj) {
if (!obj) return;

var skip, oldVal;

// Update all the properties
var post = this;
_.each(obj, function(val,key) {
if (key !== 'actions_summary'){
if (val) {
post.set(key, val);
oldVal = post[key];
skip = false;

if (val && val !== oldVal) {

if (key === "reply_to_user" && val && oldVal) {
skip = val.username === oldVal.username || Em.get(val, "username") === Em.get(oldVal, "username");
}

if(!skip) {
post.set(key, val);
}
}
}
});
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ def build_not_found_page(status=404, layout=false)

protected

def render_post_json(post)
def render_post_json(post, add_raw=true)
post_serializer = PostSerializer.new(post, scope: guardian, root: false)
post_serializer.add_raw = true
post_serializer.add_raw = add_raw
post_serializer.topic_slug = post.topic.slug if post.topic.present?

counts = PostAction.counts_for([post], current_user)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/post_actions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create
else
# We need to reload or otherwise we are showing the old values on the front end
@post.reload
render_post_json(@post)
render_post_json(@post, _add_raw = false)
end
end

Expand All @@ -43,7 +43,7 @@ def destroy
PostAction.remove_act(current_user, @post, post_action.post_action_type_id)

@post.reload
render_post_json(@post)
render_post_json(@post, _add_raw = false)
end

def defer_flags
Expand Down

0 comments on commit e14e8f6

Please sign in to comment.