OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / keet-store / store / chat / unread / chat-unread.model.js

10 lines · javascript ref:
import { CHAT_MESSAGE_TYPE as e, LAST_MESSAGE_ALL_SEEN_SEQ as t } from "../chat.constant"
export const isOwnCallStartedOnlyUnread = (t, n) =>
  t.local && t.event?.type === e.CALL_STARTED && t.seq === n + 1
export const getMessageUnread = (e, n) =>
  e && Number.isInteger(e.seq) && Number.isInteger(n)
    ? n === t || (e.local && !e.event) || isOwnCallStartedOnlyUnread(e, n)
      ? 0
      : Math.max(e.seq - n, 0)
    : 0