feat: msg sound
This commit is contained in:
@@ -11,6 +11,12 @@ export default async function handler({ operation, data = {} }: Params) {
|
||||
return;
|
||||
}
|
||||
switch (operation) {
|
||||
case "updateMsgSoundSetting":
|
||||
{
|
||||
// console.log("cache the toggleMenuExpand");
|
||||
await table?.setItem("msgSound", data.msgSound);
|
||||
}
|
||||
break;
|
||||
case "toggleMenuExpand":
|
||||
{
|
||||
// console.log("cache the toggleMenuExpand");
|
||||
|
||||
+11
-3
@@ -9,6 +9,7 @@ export interface UIState {
|
||||
SSEStatus: SSEStatus;
|
||||
online: boolean;
|
||||
ready: boolean;
|
||||
msgSound: boolean;
|
||||
inputMode: InputMode;
|
||||
menuExpand: boolean;
|
||||
// todo
|
||||
@@ -28,6 +29,7 @@ export interface UIState {
|
||||
const initialState: UIState = {
|
||||
SSEStatus: "disconnected",
|
||||
online: true,
|
||||
msgSound: true,
|
||||
ready: false,
|
||||
inputMode: "text",
|
||||
menuExpand: false,
|
||||
@@ -48,8 +50,9 @@ const uiSlice = createSlice({
|
||||
initialState,
|
||||
reducers: {
|
||||
fillUI(state, action: PayloadAction<Partial<UIState>>) {
|
||||
const { SSEStatus, ready, online, ...rest } = action.payload;
|
||||
return { ...state, ...rest };
|
||||
const { SSEStatus, ready, online, msgSound = true, ...rest } = action.payload;
|
||||
window.MSG_SOUND = msgSound;
|
||||
return { ...state, msgSound, ...rest };
|
||||
},
|
||||
setReady(state, action: PayloadAction<boolean>) {
|
||||
state.ready = action.payload;
|
||||
@@ -57,6 +60,10 @@ const uiSlice = createSlice({
|
||||
updateSSEStatus(state, action: PayloadAction<SSEStatus>) {
|
||||
state.SSEStatus = action.payload;
|
||||
},
|
||||
updateMsgSoundSetting(state, action: PayloadAction<boolean>) {
|
||||
window.MSG_SOUND = action.payload;
|
||||
state.msgSound = action.payload;
|
||||
},
|
||||
updateOnline(state, action: PayloadAction<boolean>) {
|
||||
state.online = action.payload;
|
||||
},
|
||||
@@ -190,7 +197,8 @@ export const {
|
||||
updateSelectMessages,
|
||||
updateDraftMarkdown,
|
||||
updateDraftMixedText,
|
||||
updateRememberedNavs
|
||||
updateRememberedNavs,
|
||||
updateMsgSoundSetting
|
||||
} = uiSlice.actions;
|
||||
|
||||
export default uiSlice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user