From 680cf443f4ca52189e44e7b9e2ab8d7dea571e5d Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Mon, 18 Dec 2023 16:46:09 +0200 Subject: [PATCH] FIX: Better infinite scrolling on categories page (#24831) This commit refactor CategoryList to remove usage of EmberObject, hopefully make the code more readable and fixes various edge cases with lazy loaded categories (third level subcategories not being visible, subcategories not being visible on category page, requesting for more pages even if the last one did not return any results, etc). The problems have always been here, but were not visible because a lot of the processing was handled by the server and then the result was serialized. With more of these being moved to the client side for the lazy category loading, the problems became more obvious. --- .../discovery/categories-display.gjs | 11 +- .../discourse/app/models/category-list.js | 111 ++++++++---------- .../discourse/app/models/category.js | 6 +- .../javascripts/discourse/app/models/site.js | 10 ++ app/models/category_list.rb | 10 +- spec/models/category_list_spec.rb | 14 +++ 6 files changed, 97 insertions(+), 65 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/discovery/categories-display.gjs b/app/assets/javascripts/discourse/app/components/discovery/categories-display.gjs index 4cccf7712bd..6a9ccd8b24a 100644 --- a/app/assets/javascripts/discourse/app/components/discovery/categories-display.gjs +++ b/app/assets/javascripts/discourse/app/components/discovery/categories-display.gjs @@ -75,14 +75,21 @@ export default class CategoriesDisplay extends Component { } } + get canLoadMore() { + return this.siteSettings.lazy_load_categories && this.args.loadMore; + } +