feat: msg sound

This commit is contained in:
Tristan Yang
2024-07-08 14:17:31 +08:00
parent 06e553f52d
commit 7b82047469
12 changed files with 8746 additions and 6978 deletions
@@ -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
View File
@@ -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;