Closed esot321c closed 10 months ago
File notifications/index
import useSWR, { mutate } from 'swr';
onClick={() => globalContext.api ?.markNotificationsAsRead(notifications ? notifications[0].id : 0) .then(() => { globalContext.metadata.setMetadata({ ...globalContext.metadata.metadata, unreadNotificationCount: 0, });
// Manually updating without re-fetching:
const updatedNotifications = notifications.map(notification => ({
...notification,
is_read: true
}));
mutate(`/notificatons/${globalContext.api?.daoUserData?.id}`, updatedNotifications, false);
})
.catch((err) => {
console.log(err);
})
}