-
Notifications
You must be signed in to change notification settings - Fork 59
/
channelLock.ts
36 lines (32 loc) · 1009 Bytes
/
channelLock.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { getCache, saveCache } from '../../utils/cache'
import { STICKY_LOCK_PREFIX } from './stickyMessages'
/**
* Set the channel status to locked
*
* @param {string} channelId - the id of channel that want to lock
* @returns {void} set the channel set status to locked
*
*/
export function lockChannel(channelId: string): void {
saveCache(`${STICKY_LOCK_PREFIX}-${channelId}`, true)
}
/**
* Set the channel status to unlocked
*
* @param {string} channelId - the id of channel that want to unlock
* @returns {void} set the channel set status to unlocked
*
*/
export function unlockChannel(channelId: string): void {
saveCache(`${STICKY_LOCK_PREFIX}-${channelId}`, false)
}
/**
* Check the channel status is lock
*
* @param {string} channelId - the id of channel that want to check
* @returns {boolean} true if the channel is locked, false otherwise
*
*/
export function isChannelLock(channelId: string): boolean {
return getCache(`${STICKY_LOCK_PREFIX}-${channelId}`) === true
}