2024-01-28 14:17:47 +01:00
|
|
|
import { Entity } from 'megalodon'
|
|
|
|
|
2024-01-28 10:49:20 +01:00
|
|
|
export type Marker = {
|
|
|
|
last_read_id: string
|
|
|
|
version: number
|
|
|
|
updated_at: string
|
|
|
|
unread_count?: number
|
|
|
|
}
|
2024-01-28 14:17:47 +01:00
|
|
|
|
|
|
|
export function unreadCount(marker: Marker, notifications: Array<Entity.Notification>): number {
|
|
|
|
if (marker.unread_count !== undefined) {
|
|
|
|
return marker.unread_count
|
|
|
|
}
|
|
|
|
return notifications.filter(n => parseInt(n.id) > parseInt(marker.last_read_id)).length
|
|
|
|
}
|