small seen msgs request impro

This commit is contained in:
Adrian Brzeziński 2023-06-30 14:38:38 +02:00
parent 50e40aee90
commit 80050824ea
1 changed files with 20 additions and 16 deletions

View File

@ -19,6 +19,7 @@ import NotificationCookieStore from '@store/notificationCookieStore'
import dayjs from 'dayjs'
import { useTranslation } from 'next-i18next'
import { notify } from 'utils/notifications'
import { chunk } from 'lodash'
export const createSolanaMessage = (
wallet: WalletContextState,
@ -94,23 +95,26 @@ const NotificationsDrawer = ({
const markAsSeen = useCallback(
async (ids: number[]) => {
try {
const resp = await fetch(`${NOTIFICATION_API}notifications/seen`, {
method: 'POST',
headers: headers.headers,
body: JSON.stringify({
ids: ids,
seen: true,
}),
})
const body = await resp.json()
const error = body.error
if (error) {
notify({
type: 'error',
title: 'Error',
description: error,
const idsChunk = chunk(ids, 200)
for (const c of idsChunk) {
const resp = await fetch(`${NOTIFICATION_API}notifications/seen`, {
method: 'POST',
headers: headers.headers,
body: JSON.stringify({
ids: c,
seen: true,
}),
})
return
const body = await resp.json()
const error = body.error
if (error) {
notify({
type: 'error',
title: 'Error',
description: error,
})
return
}
}
refetch()
} catch (e) {