Make setNotificationsAsSeen
return a promise (#692)
This commit is contained in:
parent
64462d6ab4
commit
06948bb98b
|
@ -726,18 +726,14 @@ function NotificationItem(props: {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setNotificationsAsSeen = (notifications: Notification[]) => {
|
export const setNotificationsAsSeen = async (notifications: Notification[]) => {
|
||||||
notifications.forEach((notification) => {
|
const unseenNotifications = notifications.filter((n) => !n.isSeen)
|
||||||
if (!notification.isSeen)
|
return await Promise.all(
|
||||||
updateDoc(
|
unseenNotifications.map((n) => {
|
||||||
doc(db, `users/${notification.userId}/notifications/`, notification.id),
|
const notificationDoc = doc(db, `users/${n.userId}/notifications/`, n.id)
|
||||||
{
|
return updateDoc(notificationDoc, { isSeen: true, viewTime: new Date() })
|
||||||
isSeen: true,
|
})
|
||||||
viewTime: new Date(),
|
)
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
return notifications
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function QuestionOrGroupLink(props: {
|
function QuestionOrGroupLink(props: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user