fix marking notifications as seen
This commit is contained in:
parent
80050824ea
commit
157119eea8
|
@ -19,7 +19,6 @@ import NotificationCookieStore from '@store/notificationCookieStore'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
import { notify } from 'utils/notifications'
|
import { notify } from 'utils/notifications'
|
||||||
import { chunk } from 'lodash'
|
|
||||||
|
|
||||||
export const createSolanaMessage = (
|
export const createSolanaMessage = (
|
||||||
wallet: WalletContextState,
|
wallet: WalletContextState,
|
||||||
|
@ -95,26 +94,23 @@ const NotificationsDrawer = ({
|
||||||
const markAsSeen = useCallback(
|
const markAsSeen = useCallback(
|
||||||
async (ids: number[]) => {
|
async (ids: number[]) => {
|
||||||
try {
|
try {
|
||||||
const idsChunk = chunk(ids, 200)
|
const resp = await fetch(`${NOTIFICATION_API}notifications/seen`, {
|
||||||
for (const c of idsChunk) {
|
method: 'POST',
|
||||||
const resp = await fetch(`${NOTIFICATION_API}notifications/seen`, {
|
headers: headers.headers,
|
||||||
method: 'POST',
|
body: JSON.stringify({
|
||||||
headers: headers.headers,
|
ids: ids,
|
||||||
body: JSON.stringify({
|
seen: true,
|
||||||
ids: c,
|
}),
|
||||||
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()
|
return
|
||||||
const error = body.error
|
|
||||||
if (error) {
|
|
||||||
notify({
|
|
||||||
type: 'error',
|
|
||||||
title: 'Error',
|
|
||||||
description: error,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
refetch()
|
refetch()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue