paideiadao / paideia-app

paideia-app.vercel.app
MIT License
5 stars 6 forks source link

Notifications not marked as "read" #78

Closed esot321c closed 10 months ago

esot321c commented 11 months ago
HelixEvo commented 11 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);
  })

}