mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
DEV: Remove post length check to allow loading to end (#32648)
As reported: https://meta.discourse.org/t/endless-spinning-on-user-activity-of-user-without-activity/365313 If a user has no posts, their post list will show a loading spinner indefinitely  This is because if there are no posts we never set `canLoadMore` or `loading` to `false` If we always check for new posts we avoid the issue. 
This commit is contained in:
@ -52,20 +52,17 @@ export default class PostList extends Component {
|
||||
}
|
||||
this.loading = true;
|
||||
|
||||
const posts = this.args.posts;
|
||||
if (posts && posts.length) {
|
||||
try {
|
||||
const newPosts = await this.args.fetchMorePosts();
|
||||
this.args.posts.addObjects(newPosts);
|
||||
try {
|
||||
const newPosts = await this.args.fetchMorePosts();
|
||||
this.args.posts?.addObjects(newPosts);
|
||||
|
||||
if (newPosts.length === 0) {
|
||||
this.canLoadMore = false;
|
||||
}
|
||||
} catch (error) {
|
||||
popupAjaxError(error);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
if (newPosts.length === 0) {
|
||||
this.canLoadMore = false;
|
||||
}
|
||||
} catch (error) {
|
||||
popupAjaxError(error);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,8 @@ export default class GroupActivityPostsController extends Controller {
|
||||
@action
|
||||
async fetchMorePosts() {
|
||||
const posts = this.model;
|
||||
const before = posts[posts.length - 1].created_at;
|
||||
const before =
|
||||
posts.length > 0 ? posts[posts.length - 1]?.created_at : undefined;
|
||||
const group = this.group.model;
|
||||
const categoryId = this.groupActivity.category_id;
|
||||
const opts = { before, type: this.type, categoryId };
|
||||
|
Reference in New Issue
Block a user