mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 23:06:57 +08:00
4fdb275683
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.
32 lines
716 B
Ruby
32 lines
716 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UserBookmarkList
|
|
include ActiveModel::Serialization
|
|
|
|
PER_PAGE = 20
|
|
|
|
attr_reader :bookmarks, :per_page
|
|
attr_accessor :more_bookmarks_url, :bookmark_serializer_opts
|
|
|
|
def initialize(user:, guardian:, params:)
|
|
@user = user
|
|
@guardian = guardian
|
|
@params = params
|
|
|
|
@params.merge!(per_page: PER_PAGE) if params[:per_page].blank?
|
|
@params[:per_page] = PER_PAGE if @params[:per_page] > PER_PAGE
|
|
|
|
@bookmarks = []
|
|
@bookmark_serializer_opts = {}
|
|
end
|
|
|
|
def load(&blk)
|
|
@bookmarks = BookmarkQuery.new(user: @user, guardian: @guardian, params: @params).list_all(&blk)
|
|
@bookmarks
|
|
end
|
|
|
|
def per_page
|
|
@per_page ||= @params[:per_page]
|
|
end
|
|
end
|