podchat-browser
Version:
Javascript SDK to use POD's Chat Service - Browser Only
31 lines (26 loc) • 794 B
JavaScript
export default class Pin {
constructor(thread) {
this.thread = thread;
}
pinThread(threadId){
const thread = this.thread.getThreadItemById(threadId);
if (thread) {
thread.pin = true;
}
this.thread.update(threadId,thread);
}
unPinThread(threadId){
const thread = this.thread.getThreadItemById(threadId);
if (thread) {
thread.pin = false;
}
this.thread.update(threadId,thread);
}
checkThreadIsPin(threadId){
const thread = this.thread.getThreadItemById(threadId);
return thread?.pin ||false;
}
pinedMessageCount(threadId){
return this.thread.getAll().filter(data => data.pin === true)?.length || 0
}
}