chore: sort first when insert new user message
This commit is contained in:
@@ -28,7 +28,9 @@ const userMsgSlice = createSlice({
|
|||||||
const midExisted = state.byId[id].findIndex((id: number) => id == mid) > -1;
|
const midExisted = state.byId[id].findIndex((id: number) => id == mid) > -1;
|
||||||
const localMsgExisted = state.byId[id].findIndex((id: number) => id == local_id) > -1;
|
const localMsgExisted = state.byId[id].findIndex((id: number) => id == local_id) > -1;
|
||||||
if (midExisted || localMsgExisted) return;
|
if (midExisted || localMsgExisted) return;
|
||||||
state.byId[id].push(+mid);
|
// 每次入库,都排序
|
||||||
|
const newArr = [...state.byId[id], +mid].sort((a, b) => a - b);
|
||||||
|
state.byId[id] = newArr;
|
||||||
// 只要有新消息,就检查下
|
// 只要有新消息,就检查下
|
||||||
if (state.ids.findIndex((uid) => uid == id) == -1) {
|
if (state.ids.findIndex((uid) => uid == id) == -1) {
|
||||||
state.ids.push(+id);
|
state.ids.push(+id);
|
||||||
|
|||||||
Reference in New Issue
Block a user