FIX: group activity's mentions infinite loading (#27070)

In 07ecbb5a3b we ensure the mentions in a group's activity page worked properly but we missed adding proper support for infinite loading.

The client is using the `before` parameter instead of the `before_post_id` to do the pagination.

This adds support for `before` as well as some tests to ensure it doesn't regress.

I also added tests to the group's activity posts as well since those were missing.

Finally I deleted some unused code (`group.messages_for`) which is not used anymore.

Context - https://meta.discourse.org/t/-/308044/9
This commit is contained in:
Régis Hanol
2024-05-18 00:26:57 +02:00
committed by GitHub
parent a1843104dd
commit bf80688cd3
3 changed files with 71 additions and 25 deletions

View File

@ -229,7 +229,10 @@ class GroupsController < ApplicationController
guardian.ensure_can_see_group_members!(group)
posts =
group.mentioned_posts_for(guardian, params.permit(:before_post_id, :category_id)).limit(20)
group.mentioned_posts_for(
guardian,
params.permit(:before_post_id, :before, :category_id),
).limit(20)
response = { posts: serialize_data(posts, GroupPostSerializer) }
@ -249,7 +252,10 @@ class GroupsController < ApplicationController
guardian.ensure_can_see_group_members!(group)
@posts =
group.mentioned_posts_for(guardian, params.permit(:before_post_id, :category_id)).limit(50)
group.mentioned_posts_for(
guardian,
params.permit(:before_post_id, :before, :category_id),
).limit(50)
@title =
"#{SiteSetting.title} - #{I18n.t("rss_description.group_mentions", group_name: group.name)}"
@link = Discourse.base_url