DEV: Add bookmarks tab to the new user menu (#17814)

Some of the changes in this commit are extracted from https://github.com/discourse/discourse/pull/17379.

The bookmarks tab in the new user menu is different from the other tabs in that it can display a mixture of notifications and bookmarks. When there are unread bookmark reminder notifications, the tab displays all of these notifications at the top and fills the remaining space in the menu with the rest of the bookmarks. The bubble/badge count on the bookmarks tab indicates how many unread bookmark reminder notifications there are.

On the technical aspect, since this commit introduces a new `bookmark-item` component, we've done some refactoring so that all 3 "item" components (`notification-item`, `reviewable-item` and the new `bookmark-item`) inherit from a base component and get identical HTML structure so they all look consistent.

Internal tickets: t70584 and t65045.
This commit is contained in:
Osama Sayegh
2022-08-08 17:24:04 +03:00
committed by GitHub
parent 94ac8611f4
commit 4fdb275683
47 changed files with 1024 additions and 135 deletions

View File

@@ -34,7 +34,7 @@ class BookmarkQuery
@limit = @params[:limit].present? ? @params[:limit].to_i : @params[:per_page]
end
def list_all
def list_all(&blk)
search_term = @params[:q]
ts_query = search_term.present? ? Search.ts_query(term: search_term) : nil
search_term_wildcard = search_term.present? ? "%#{search_term}%" : nil
@@ -75,6 +75,10 @@ class BookmarkQuery
results = results.offset(@page * @params[:per_page])
end
if updated_results = blk&.call(results)
results = updated_results
end
results = results.limit(@limit).to_a
BookmarkQuery.preload(results, self)
results