nicolium: this should never be reachable
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -34,6 +34,7 @@ import { minifyGroupedNotifications } from '../utils/minify-list';
|
||||
|
||||
import type {
|
||||
GetGroupedNotificationsParams,
|
||||
Marker,
|
||||
Notification,
|
||||
NotificationGroup,
|
||||
PaginatedResponse,
|
||||
@ -243,6 +244,11 @@ const useMarkNotificationsReadMutation = () => {
|
||||
mutationFn: async (lastReadId?: string | null) => {
|
||||
if (!lastReadId) return;
|
||||
|
||||
const currentMarker = queryClient.getQueryData<Marker>(['markers', 'notifications']);
|
||||
if (currentMarker && compareId(currentMarker.last_read_id, lastReadId) >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
return await client.timelines.saveMarkers({
|
||||
notifications: {
|
||||
last_read_id: lastReadId,
|
||||
@ -252,18 +258,7 @@ const useMarkNotificationsReadMutation = () => {
|
||||
onSuccess: (markers, lastReadId) => {
|
||||
if (markers?.notifications) {
|
||||
queryClient.setQueryData(['markers', 'notifications'], markers.notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lastReadId) return;
|
||||
|
||||
queryClient.setQueryData(['markers', 'notifications'], (marker) => {
|
||||
if (!marker) return undefined;
|
||||
return {
|
||||
...marker,
|
||||
last_read_id: lastReadId,
|
||||
};
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user