fix marking notifications as seen

This commit is contained in:
Adrian Brzeziński 2023-06-30 22:59:09 +02:00
parent 80050824ea
commit 157119eea8
1 changed files with 16 additions and 20 deletions

View File

@ -19,7 +19,6 @@ 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,
@ -95,26 +94,23 @@ const NotificationsDrawer = ({
const markAsSeen = useCallback(
async (ids: number[]) => {
try {
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,
}),
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 body = await resp.json()
const error = body.error
if (error) {
notify({
type: 'error',
title: 'Error',
description: error,
})
return
}
return
}
refetch()
} catch (e) {