UNPKG

podchat-browser

Version:

Javascript SDK to use POD's Chat Service - Browser Only

28 lines (25 loc) 756 B
export default class UnRead { constructor(thread) { this.thread = thread; } increase(threadId){ const thread = this.thread.getThreadItemById(threadId); if (thread) { this.thread.update(threadId, {unreadCount: thread.unreadCount+1}) } return thread; } decrease(threadId){ const thread = this.thread.getThreadItemById(threadId); if (thread) { this.thread.update(threadId, {unreadCount: thread.unreadCount-1}) } return thread; } count(threadId){ return this.thread.get(threadId)?.unreadCount || 0 } update(threadId,value){ this.thread.update(threadId, {unreadCount: value}) } }