Skip to content

Commit

Permalink
Comment update implies annotation update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frodo161 committed Oct 5, 2023
1 parent 7e77f80 commit 4bb2844
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion app/controllers/annotations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class AnnotationsController < ApplicationController


before_action :update_comments, only: [:edit, :update_annotations]

authorize_resource

def new
Expand Down Expand Up @@ -141,4 +143,19 @@ def comment_html(medium, total_seconds, comment)
'?time=' + total_seconds + '">' + timestamp + '</a>'
end

def update_comments
for annotation in Annotation.where(medium: params[:mediumId])
# find comment
unless annotation.public_comment_id == nil
comment = Commontator::Comment.find_by(id: annotation.public_comment_id).body

# remove "Thymestamp: H:MM:SS" at the end of the string
index = comment.rindex("\nThymestamp")
comment = comment[0 .. index - 1]

annotation.update(comment: comment)
end
end
end

end

0 comments on commit 4bb2844

Please sign in to comment.