refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-14 22:22:05 +08:00
parent c2797a132c
commit 65049677e4
12 changed files with 54 additions and 33 deletions
+5 -4
View File
@@ -4,7 +4,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
export interface State {
[mid: number]:
| {
[reaction: number]: number[];
[reaction: string]: number[];
}
| undefined;
}
@@ -26,7 +26,10 @@ const reactionMessageSlice = createSlice({
delete state[id];
});
},
toggleReactionMessage(state, action) {
toggleReactionMessage(
state,
action: PayloadAction<{ from_uid: number; mid: number; rid: number; action: string }>
) {
// rid: reaction's mid, mid: which message append to
const { from_uid, mid, rid, action: reaction } = action.payload;
const ridExisted = state[rid] || false;
@@ -52,8 +55,6 @@ const reactionMessageSlice = createSlice({
} else {
state[mid]![reaction] = [from_uid];
}
// todo: ???
state[rid] = true;
}
}
});