FIX: bookmark topic was not working intuitively

- explicitly call out "clear bookmarks"
- correct keyboard shortcuts
- properly remove bookmarks when toggeling
This commit is contained in:
Sam
2015-02-19 10:58:57 +11:00
parent def034cd08
commit b041b3f67f
9 changed files with 125 additions and 26 deletions

View File

@ -217,15 +217,24 @@ class TopicsController < ApplicationController
render nothing: true
end
def remove_bookmarks
topic = Topic.find(params[:topic_id].to_i)
PostAction.joins(:post)
.where(user_id: current_user.id)
.where('topic_id = ?', topic.id).each do |pa|
PostAction.remove_act(current_user, pa.post, PostActionType.types[:bookmark])
end
render nothing: true
end
def bookmark
topic = Topic.find_by(id: params[:topic_id])
topic = Topic.find(params[:topic_id].to_i)
first_post = topic.ordered_posts.first
if params[:bookmarked] == "true"
PostAction.act(current_user, first_post, PostActionType.types[:bookmark])
else
PostAction.remove_act(current_user, first_post, PostActionType.types[:bookmark])
end
PostAction.act(current_user, first_post, PostActionType.types[:bookmark])
render nothing: true
end