mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 17:56:25 +02:00
feat: implement batch unread counts for notifications to reduce API calls and improve performance
This commit is contained in:
parent
7362da52d3
commit
403097646d
18 changed files with 450 additions and 51 deletions
|
|
@ -1,8 +1,10 @@
|
|||
import {
|
||||
type GetBatchUnreadCountResponse,
|
||||
type GetNotificationsRequest,
|
||||
type GetNotificationsResponse,
|
||||
type GetSourceTypesResponse,
|
||||
type GetUnreadCountResponse,
|
||||
getBatchUnreadCountResponse,
|
||||
getNotificationsRequest,
|
||||
getNotificationsResponse,
|
||||
getSourceTypesResponse,
|
||||
|
|
@ -149,6 +151,25 @@ class NotificationsApiService {
|
|||
getUnreadCountResponse
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get unread counts for all categories in a single request.
|
||||
* Replaces 2 separate getUnreadCount calls (comments + status).
|
||||
*/
|
||||
getBatchUnreadCounts = async (
|
||||
searchSpaceId?: number
|
||||
): Promise<GetBatchUnreadCountResponse> => {
|
||||
const params = new URLSearchParams();
|
||||
if (searchSpaceId !== undefined) {
|
||||
params.append("search_space_id", String(searchSpaceId));
|
||||
}
|
||||
const queryString = params.toString();
|
||||
|
||||
return baseApiService.get(
|
||||
`/api/v1/notifications/unread-counts-batch${queryString ? `?${queryString}` : ""}`,
|
||||
getBatchUnreadCountResponse
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export const notificationsApiService = new NotificationsApiService();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue