DEV: add API endpoint to destroy_timings only of last post

Previously API only allowed you to nuke all timings from a topic,
new API is less punishing and allows you just to remove 1 post.
This commit is contained in:
Sam
2018-11-13 16:07:48 +11:00
parent 296928ec04
commit 80ceb57c76
3 changed files with 63 additions and 1 deletions

View File

@ -250,7 +250,12 @@ class TopicsController < ApplicationController
end
def destroy_timings
PostTiming.destroy_for(current_user.id, [params[:topic_id].to_i])
if params[:last].to_s == "1"
PostTiming.destroy_last_for(current_user, params[:topic_id])
else
PostTiming.destroy_for(current_user.id, [params[:topic_id].to_i])
end
render body: nil
end