feat: lots updates

This commit is contained in:
zerosoul
2022-03-22 16:10:49 +08:00
parent eef55e5cb3
commit a23800b042
40 changed files with 504 additions and 415 deletions
+1
View File
@@ -48,6 +48,7 @@ const authDataSlice = createSlice({
setUid(state, action) {
const uid = action.payload;
state.uid = uid;
console.log("set uid orginal");
},
updateToken(state, action) {
const { token, refresh_token, expired_in } = action.payload;
+9 -3
View File
@@ -12,9 +12,12 @@ const channelMsgSlice = createSlice({
return action.payload;
},
addChannelMsg(state, action) {
const { id, mid } = action.payload;
const { id, mid, local_id = null } = action.payload;
if (state[id]) {
if (state[id].findIndex((id) => id == mid) > -1) return;
const midExsited = state[id].findIndex((id) => id == mid) > -1;
const localMsgExsited =
state[id].findIndex((id) => id == local_id) > -1;
if (midExsited || localMsgExsited) return;
state[id].push(+mid);
} else {
state[id] = [+mid];
@@ -24,7 +27,10 @@ const channelMsgSlice = createSlice({
const { id, mid } = action.payload;
if (state[id]) {
const idx = state[id].findIndex((i) => i == mid);
state[id].splice(idx, 1);
if (idx > -1) {
// 存在 则再删除
state[id].splice(idx, 1);
}
}
},
removeChannelSession(state, action) {
+1 -1
View File
@@ -3,7 +3,7 @@ import { createSlice } from "@reduxjs/toolkit";
const initialState = {
online: true,
ready: false,
menuExpand: true,
menuExpand: false,
setting: false,
channelSetting: null,
};