test: stabilize channel mode and discussion coverage
This commit is contained in:
43
plugin/core/channel-modes.js
Normal file
43
plugin/core/channel-modes.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const channelStates = new Map();
|
||||
|
||||
export function getChannelState(channelId) {
|
||||
if (!channelStates.has(channelId)) {
|
||||
channelStates.set(channelId, {
|
||||
mode: "normal",
|
||||
shuffling: false,
|
||||
});
|
||||
}
|
||||
return channelStates.get(channelId);
|
||||
}
|
||||
|
||||
export function enterMultiMessageMode(channelId) {
|
||||
const state = getChannelState(channelId);
|
||||
state.mode = "multi-message";
|
||||
channelStates.set(channelId, state);
|
||||
}
|
||||
|
||||
export function exitMultiMessageMode(channelId) {
|
||||
const state = getChannelState(channelId);
|
||||
state.mode = "normal";
|
||||
channelStates.set(channelId, state);
|
||||
}
|
||||
|
||||
export function isMultiMessageMode(channelId) {
|
||||
return getChannelState(channelId).mode === "multi-message";
|
||||
}
|
||||
|
||||
export function setChannelShuffling(channelId, enabled) {
|
||||
const state = getChannelState(channelId);
|
||||
state.shuffling = enabled;
|
||||
channelStates.set(channelId, state);
|
||||
}
|
||||
|
||||
export function getChannelShuffling(channelId) {
|
||||
return getChannelState(channelId).shuffling;
|
||||
}
|
||||
|
||||
export function markLastShuffled(channelId) {
|
||||
const state = getChannelState(channelId);
|
||||
state.lastShuffledAt = Date.now();
|
||||
channelStates.set(channelId, state);
|
||||
}
|
||||
Reference in New Issue
Block a user