feat: indicate read messages

This commit is contained in:
Tim
2025-07-09 18:23:24 +08:00
parent 9fdf068cd6
commit 206718640a
2 changed files with 54 additions and 7 deletions

View File

@@ -15,3 +15,21 @@ export async function fetchUnreadCount() {
return 0
}
}
export async function markNotificationsRead(ids) {
try {
const token = getToken()
if (!token || !ids || ids.length === 0) return false
const res = await fetch(`${API_BASE_URL}/api/notifications/read`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ ids })
})
return res.ok
} catch (e) {
return false
}
}