refactor: reaction
This commit is contained in:
@@ -20,11 +20,18 @@ const reactionMessageSlice = createSlice({
|
||||
});
|
||||
},
|
||||
toggleReactionMessage(state, action) {
|
||||
const { from_uid, mid, action: reaction } = action.payload;
|
||||
// rid: reaction's mid, mid: which message append to
|
||||
const { from_uid, mid, rid, action: reaction } = action.payload;
|
||||
console.log("msg reaction", mid, from_uid, reaction);
|
||||
const ridExisted = state[rid] || false;
|
||||
// 已经塞过了
|
||||
if (ridExisted) return;
|
||||
console.log("ssss");
|
||||
// 还未塞过任何一表情
|
||||
if (!state[mid]) {
|
||||
state[mid] = {};
|
||||
}
|
||||
// 存在该表情数据
|
||||
if (state[mid][reaction]) {
|
||||
const reactionUids = state[mid][reaction];
|
||||
const idx = reactionUids.findIndex((id) => id == from_uid);
|
||||
@@ -40,6 +47,7 @@ const reactionMessageSlice = createSlice({
|
||||
} else {
|
||||
state[mid][reaction] = [from_uid];
|
||||
}
|
||||
state[rid] = true;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user