feat: update channel icon

This commit is contained in:
zerosoul
2022-04-15 22:11:34 +08:00
parent a09f95342f
commit 1d9208fb61
5 changed files with 58 additions and 19 deletions
+7 -2
View File
@@ -1,4 +1,5 @@
import { createSlice } from "@reduxjs/toolkit";
import BASE_URL from "../config";
const initialState = {
ids: [],
byId: {},
@@ -17,6 +18,7 @@ const channelsSlice = createSlice({
state.byId = Object.fromEntries(
chs.map((c) => {
const { gid } = c;
c.icon = `${BASE_URL}/resource/group_avatar?gid=${gid}`;
return [gid, c];
})
);
@@ -26,7 +28,10 @@ const channelsSlice = createSlice({
const ch = action.payload;
const { gid, ...rest } = ch;
state.ids.push(gid);
state.byId[gid] = rest;
state.byId[gid] = {
...rest,
icon: `${BASE_URL}/resource/group_avatar?gid=${gid}`,
};
},
updateChannel(state, action) {
const ignoreInPublic = ["add_member", "remove_member"];
@@ -65,7 +70,7 @@ const channelsSlice = createSlice({
break;
default:
state.byId[id] = { ...state.byId[id], members, ...rest };
state.byId[id] = { ...state.byId[id], ...rest };
break;
}
},