chore: sort before insert in msg list

This commit is contained in:
Tristan Yang
2023-03-09 20:10:32 +08:00
parent 3af4cab880
commit f324e08db5
+3 -1
View File
@@ -22,7 +22,9 @@ const channelMsgSlice = createSlice({
const midExisted = state[id]!.findIndex((id) => id == mid) > -1;
const localMsgExisted = state[id]!.findIndex((id) => id == local_id) > -1;
if (midExisted || localMsgExisted) return;
state[id]!.push(+mid);
// 每次入库,都排序
const newArr = [...state[id], +mid].sort((a, b) => a - b);
state[id] = newArr;
} else {
state[id] = [+mid];
}