discourse/app/helpers/topic_post_bookmarkable_helper.rb
Martin Brennan 907adce1cb
FIX: Use registered bookmarkables for BookmarkManager (#16695)
These validate/after_create/after_destroy methods were added
back in b8828d4a2d before
the RegisteredBookmarkable API and pattern was nailed down.
This commit updates BookmarkManager to call out to the
relevant bookmarkable for these and bookmark_metadata for
consistency.
2022-05-11 09:51:03 +10:00

17 lines
392 B
Ruby

# frozen_string_literal: true
module TopicPostBookmarkableHelper
extend ActiveSupport::Concern
module ClassMethods
def sync_topic_user_bookmarked(user, topic, opts)
return if opts.key?(:auto_track) && !opts[:auto_track]
TopicUser.change(
user.id,
topic.id,
bookmarked: Bookmark.for_user_in_topic(user.id, topic).exists?
)
end
end
end