From e08959a1b5db1384456bb9fa3f97a664eea415a3 Mon Sep 17 00:00:00 2001 From: Michael Barrett Date: Thu, 19 Dec 2024 13:19:26 +0000 Subject: [PATCH] Increased the number of notifications retrieved in `admin-x-activitypub` (#21925) refs [AP-626](https://linear.app/ghost/issue/AP-626/wrong-posts-showing-up-in-notifications) Increased the number of notifications retrieved in `admin-x-activitypub` to account for notifications being grouped and reduce the amount of time waiting on requests to finish (by making fewer requests) --- apps/admin-x-activitypub/package.json | 2 +- apps/admin-x-activitypub/src/api/activitypub.ts | 7 ++++--- apps/admin-x-activitypub/src/components/Activities.tsx | 1 + .../admin-x-activitypub/src/hooks/useActivityPubQueries.ts | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/admin-x-activitypub/package.json b/apps/admin-x-activitypub/package.json index fa09ee4c44..f5457d5ba7 100644 --- a/apps/admin-x-activitypub/package.json +++ b/apps/admin-x-activitypub/package.json @@ -1,6 +1,6 @@ { "name": "@tryghost/admin-x-activitypub", - "version": "0.3.40", + "version": "0.3.41", "license": "MIT", "repository": { "type": "git", diff --git a/apps/admin-x-activitypub/src/api/activitypub.ts b/apps/admin-x-activitypub/src/api/activitypub.ts index 9fa797aee1..74eecb43a9 100644 --- a/apps/admin-x-activitypub/src/api/activitypub.ts +++ b/apps/admin-x-activitypub/src/api/activitypub.ts @@ -214,12 +214,13 @@ export class ActivityPubAPI { includeOwn: boolean = false, includeReplies: boolean = false, filter: {type?: string[]} | null = null, + limit: number = 50, cursor?: string ): Promise<{data: Activity[], next: string | null}> { - const LIMIT = 50; - const url = new URL(this.activitiesApiUrl); - url.searchParams.set('limit', LIMIT.toString()); + + url.searchParams.set('limit', limit.toString()); + if (includeOwn) { url.searchParams.set('includeOwn', includeOwn.toString()); } diff --git a/apps/admin-x-activitypub/src/components/Activities.tsx b/apps/admin-x-activitypub/src/components/Activities.tsx index 34f19c278c..a5cdf7d8f2 100644 --- a/apps/admin-x-activitypub/src/components/Activities.tsx +++ b/apps/admin-x-activitypub/src/components/Activities.tsx @@ -185,6 +185,7 @@ const Activities: React.FC = ({}) => { filter: { type: ['Follow', 'Like', `Create:Note`] }, + limit: 250, key: GET_ACTIVITIES_QUERY_KEY_NOTIFICATIONS }); diff --git a/apps/admin-x-activitypub/src/hooks/useActivityPubQueries.ts b/apps/admin-x-activitypub/src/hooks/useActivityPubQueries.ts index c9c9c0ee4e..a8f18b3764 100644 --- a/apps/admin-x-activitypub/src/hooks/useActivityPubQueries.ts +++ b/apps/admin-x-activitypub/src/hooks/useActivityPubQueries.ts @@ -267,12 +267,14 @@ export function useActivitiesForUser({ includeOwn = false, includeReplies = false, filter = null, + limit = undefined, key = null }: { handle: string; includeOwn?: boolean; includeReplies?: boolean; filter?: {type?: string[]} | null; + limit?: number; key?: string | null; }) { const queryKey = [`activities:${handle}`, key, {includeOwn, includeReplies, filter}]; @@ -283,7 +285,7 @@ export function useActivitiesForUser({ async queryFn({pageParam}: {pageParam?: string}) { const siteUrl = await getSiteUrl(); const api = createActivityPubAPI(handle, siteUrl); - return api.getActivities(includeOwn, includeReplies, filter, pageParam); + return api.getActivities(includeOwn, includeReplies, filter, limit, pageParam); }, getNextPageParam(prevPage) { return prevPage.next;