mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Minor bookmark tweaks for polymorphism (#16728)
* Make the modal for bookmarks display more consistently * Make sure bookmark query can handle empty results for certain bookmarkable queries
This commit is contained in:
@@ -72,6 +72,11 @@ class BookmarkQuery
|
||||
queries = Bookmark.registered_bookmarkables.map do |bookmarkable|
|
||||
interim_results = bookmarkable.perform_list_query(@user, @guardian)
|
||||
|
||||
# this could occur if there is some security reason that the user cannot
|
||||
# access the bookmarkables that they have bookmarked, e.g. if they had 1 bookmark
|
||||
# on a topic and that topic was moved into a private category
|
||||
next if interim_results.blank?
|
||||
|
||||
if search_term.present?
|
||||
interim_results = bookmarkable.perform_search_query(
|
||||
interim_results, search_term_wildcard, ts_query
|
||||
@@ -81,7 +86,12 @@ class BookmarkQuery
|
||||
# this is purely to make the query easy to read and debug, otherwise it's
|
||||
# all mashed up into a massive ball in MiniProfiler :)
|
||||
"---- #{bookmarkable.model.to_s} bookmarkable ---\n\n #{interim_results.to_sql}"
|
||||
end
|
||||
end.compact
|
||||
|
||||
# same for interim results being blank, the user might have been locked out
|
||||
# from all their various bookmarks, in which case they will see nothing and
|
||||
# no further pagination/ordering/etc is required
|
||||
return [] if queries.empty?
|
||||
|
||||
union_sql = queries.join("\n\nUNION\n\n")
|
||||
results = Bookmark.select("bookmarks.*").from("(\n\n#{union_sql}\n\n) as bookmarks")
|
||||
|
||||
Reference in New Issue
Block a user