mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Polymorphic bookmarks pt. 1 (CRUD) (#16308)
This commit introduces a new use_polymorphic_bookmarks site setting that is default false and hidden, that will be used to help continuous development of polymorphic bookmarks. This setting **should not** be enabled anywhere in production yet, it is purely for local development. This commit uses the setting to enable create/update/delete actions for polymorphic bookmarks on the server and client side. The bookmark interactions on topics/posts are all usable. Listing, searching, sending bookmark reminders, and other edge cases will be handled in subsequent PRs. Comprehensive UI tests will be added in the final PR -- we already have them for regular bookmarks, so it will just be a matter of changing them to be for polymorphic bookmarks.
This commit is contained in:
@@ -413,9 +413,15 @@ class TopicView
|
||||
end
|
||||
|
||||
def bookmarks
|
||||
@bookmarks ||= @topic.bookmarks.where(user: @user).joins(:topic).select(
|
||||
:id, :post_id, "topics.id AS topic_id", :for_topic, :reminder_at, :name, :auto_delete_preference
|
||||
)
|
||||
if SiteSetting.use_polymorphic_bookmarks
|
||||
@bookmarks ||= Bookmark.for_user_in_topic(@user, @topic.id).select(
|
||||
:id, :bookmarkable_id, :bookmarkable_type, :reminder_at, :name, :auto_delete_preference
|
||||
)
|
||||
else
|
||||
@bookmarks ||= @topic.bookmarks.where(user: @user).joins(:topic).select(
|
||||
:id, :post_id, "topics.id AS topic_id", :for_topic, :reminder_at, :name, :auto_delete_preference
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
MAX_PARTICIPANTS = 24
|
||||
@@ -512,10 +518,6 @@ class TopicView
|
||||
@links ||= TopicLink.topic_map(@guardian, @topic.id)
|
||||
end
|
||||
|
||||
def user_post_bookmarks
|
||||
@user_post_bookmarks ||= @topic.bookmarks.where(user: @user)
|
||||
end
|
||||
|
||||
def reviewable_counts
|
||||
@reviewable_counts ||= begin
|
||||
sql = <<~SQL
|
||||
|
||||
Reference in New Issue
Block a user