From dc9df5c18c4623f7f00737a9de0a3b542b7f0ddb Mon Sep 17 00:00:00 2001 From: zerosoul Date: Fri, 22 Apr 2022 17:08:26 +0800 Subject: [PATCH] fix: bugs --- src/app/services/channel.js | 3 +-- src/app/slices/channels.js | 15 ++++++++++----- src/common/component/styled/Input.js | 2 +- src/routes/resources/index.js | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/app/services/channel.js b/src/app/services/channel.js index 027895fb..0c2a869b 100644 --- a/src/app/services/channel.js +++ b/src/app/services/channel.js @@ -2,7 +2,7 @@ import { createApi } from "@reduxjs/toolkit/query/react"; // import toast from "react-hot-toast"; import baseQuery from "./base.query"; import BASE_URL, { ContentTypes } from "../config"; -import { updateChannel, removeChannel } from "../slices/channels"; +import { updateChannel } from "../slices/channels"; import { removeMessage } from "../slices/message"; import { removeChannelSession } from "../slices/message.channel"; import { removeReactionMessage } from "../slices/message.reaction"; @@ -96,7 +96,6 @@ export const channelApi = createApi({ const { channelMessage } = getState(); try { await queryFulfilled; - dispatch(removeChannel(id)); // 删掉该channel下的所有消息&reaction const mids = channelMessage[id]; if (mids) { diff --git a/src/app/slices/channels.js b/src/app/slices/channels.js index f4de6db7..3ebdfc10 100644 --- a/src/app/slices/channels.js +++ b/src/app/slices/channels.js @@ -14,7 +14,7 @@ const channelsSlice = createSlice({ fullfillChannels(state, action) { console.log("set channels store", state); const chs = action.payload || []; - state.ids = chs.map(({ gid }) => gid); + state.ids = chs.map(({ gid }) => +gid); state.byId = Object.fromEntries( chs.map((c) => { const { gid } = c; @@ -26,11 +26,16 @@ const channelsSlice = createSlice({ addChannel(state, action) { // console.log("set channels store", action); const ch = action.payload; - const { gid, ...rest } = ch; - state.ids.push(gid); + const { gid, avatar_updated_at } = ch; + if (!state.ids.includes(+gid)) { + state.ids.push(+gid); + } state.byId[gid] = { - ...rest, - icon: `${BASE_URL}/resource/group_avatar?gid=${gid}`, + ...ch, + icon: + avatar_updated_at == 0 + ? "" + : `${BASE_URL}/resource/group_avatar?gid=${gid}&t=${avatar_updated_at}`, }; }, updateChannel(state, action) { diff --git a/src/common/component/styled/Input.js b/src/common/component/styled/Input.js index 10596031..a414e6e8 100644 --- a/src/common/component/styled/Input.js +++ b/src/common/component/styled/Input.js @@ -17,7 +17,7 @@ const StyledInput = styled.input` background: #ffffff; border: 1px solid #e5e7eb; box-shadow: 0px 1px 2px rgba(31, 41, 55, 0.08); - border-radius: var(--br); + border-radius: 4px; font-weight: normal; font-size: 14px; line-height: 20px; diff --git a/src/routes/resources/index.js b/src/routes/resources/index.js index 3ea37405..36939095 100644 --- a/src/routes/resources/index.js +++ b/src/routes/resources/index.js @@ -104,14 +104,14 @@ function ResourceManagement({ fileMessages }) { content, created_at, from_uid, - properties: { name, file_type, size }, + properties: { name, content_type, size }, } = data; return (