mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2024-12-28 09:41:09 +01:00
16 lines
415 B
TypeScript
16 lines
415 B
TypeScript
import { Entity } from 'megalodon'
|
|
|
|
export type Marker = {
|
|
last_read_id: string
|
|
version: number
|
|
updated_at: string
|
|
unread_count?: number
|
|
}
|
|
|
|
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
|
|
}
|