mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 19:00:32 -06:00
c07dd0d22a
This is so users with huge amount of bookmarks do not have to wait a long time to see results. * Add a bookmark list and list serializer to server-side to be able to handle paging and load more URL * Use load-more component to load more bookmark items, 20 at a time in user activity * Change the way current user is loaded for bookmark ember models because it was breaking/losing resolvedTimezone when loading more items
27 lines
532 B
Ruby
27 lines
532 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UserBookmarkList
|
|
include ActiveModel::Serialization
|
|
|
|
PER_PAGE = 20
|
|
|
|
attr_reader :bookmarks
|
|
attr_accessor :more_bookmarks_url
|
|
|
|
def initialize(user: user, guardian: guardian, params: params)
|
|
@user = user
|
|
@guardian = guardian
|
|
@params = params.merge(per_page: PER_PAGE)
|
|
@bookmarks = []
|
|
end
|
|
|
|
def load
|
|
@bookmarks = BookmarkQuery.new(user: @user, guardian: @guardian, params: @params).list_all
|
|
@bookmarks
|
|
end
|
|
|
|
def per_page
|
|
@per_page ||= PER_PAGE
|
|
end
|
|
end
|