fix: bugs
This commit is contained in:
@@ -2,7 +2,7 @@ import { createApi } from "@reduxjs/toolkit/query/react";
|
|||||||
// import toast from "react-hot-toast";
|
// import toast from "react-hot-toast";
|
||||||
import baseQuery from "./base.query";
|
import baseQuery from "./base.query";
|
||||||
import BASE_URL, { ContentTypes } from "../config";
|
import BASE_URL, { ContentTypes } from "../config";
|
||||||
import { updateChannel, removeChannel } from "../slices/channels";
|
import { updateChannel } from "../slices/channels";
|
||||||
import { removeMessage } from "../slices/message";
|
import { removeMessage } from "../slices/message";
|
||||||
import { removeChannelSession } from "../slices/message.channel";
|
import { removeChannelSession } from "../slices/message.channel";
|
||||||
import { removeReactionMessage } from "../slices/message.reaction";
|
import { removeReactionMessage } from "../slices/message.reaction";
|
||||||
@@ -96,7 +96,6 @@ export const channelApi = createApi({
|
|||||||
const { channelMessage } = getState();
|
const { channelMessage } = getState();
|
||||||
try {
|
try {
|
||||||
await queryFulfilled;
|
await queryFulfilled;
|
||||||
dispatch(removeChannel(id));
|
|
||||||
// 删掉该channel下的所有消息&reaction
|
// 删掉该channel下的所有消息&reaction
|
||||||
const mids = channelMessage[id];
|
const mids = channelMessage[id];
|
||||||
if (mids) {
|
if (mids) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const channelsSlice = createSlice({
|
|||||||
fullfillChannels(state, action) {
|
fullfillChannels(state, action) {
|
||||||
console.log("set channels store", state);
|
console.log("set channels store", state);
|
||||||
const chs = action.payload || [];
|
const chs = action.payload || [];
|
||||||
state.ids = chs.map(({ gid }) => gid);
|
state.ids = chs.map(({ gid }) => +gid);
|
||||||
state.byId = Object.fromEntries(
|
state.byId = Object.fromEntries(
|
||||||
chs.map((c) => {
|
chs.map((c) => {
|
||||||
const { gid } = c;
|
const { gid } = c;
|
||||||
@@ -26,11 +26,16 @@ const channelsSlice = createSlice({
|
|||||||
addChannel(state, action) {
|
addChannel(state, action) {
|
||||||
// console.log("set channels store", action);
|
// console.log("set channels store", action);
|
||||||
const ch = action.payload;
|
const ch = action.payload;
|
||||||
const { gid, ...rest } = ch;
|
const { gid, avatar_updated_at } = ch;
|
||||||
state.ids.push(gid);
|
if (!state.ids.includes(+gid)) {
|
||||||
|
state.ids.push(+gid);
|
||||||
|
}
|
||||||
state.byId[gid] = {
|
state.byId[gid] = {
|
||||||
...rest,
|
...ch,
|
||||||
icon: `${BASE_URL}/resource/group_avatar?gid=${gid}`,
|
icon:
|
||||||
|
avatar_updated_at == 0
|
||||||
|
? ""
|
||||||
|
: `${BASE_URL}/resource/group_avatar?gid=${gid}&t=${avatar_updated_at}`,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
updateChannel(state, action) {
|
updateChannel(state, action) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const StyledInput = styled.input`
|
|||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
border: 1px solid #e5e7eb;
|
border: 1px solid #e5e7eb;
|
||||||
box-shadow: 0px 1px 2px rgba(31, 41, 55, 0.08);
|
box-shadow: 0px 1px 2px rgba(31, 41, 55, 0.08);
|
||||||
border-radius: var(--br);
|
border-radius: 4px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
|
|||||||
@@ -104,14 +104,14 @@ function ResourceManagement({ fileMessages }) {
|
|||||||
content,
|
content,
|
||||||
created_at,
|
created_at,
|
||||||
from_uid,
|
from_uid,
|
||||||
properties: { name, file_type, size },
|
properties: { name, content_type, size },
|
||||||
} = data;
|
} = data;
|
||||||
return (
|
return (
|
||||||
<FileBox
|
<FileBox
|
||||||
preview={view == Views.grid}
|
preview={view == Views.grid}
|
||||||
flex={view == Views.item}
|
flex={view == Views.item}
|
||||||
key={mid}
|
key={mid}
|
||||||
file_type={file_type}
|
file_type={content_type}
|
||||||
content={content}
|
content={content}
|
||||||
created_at={created_at}
|
created_at={created_at}
|
||||||
from_uid={from_uid}
|
from_uid={from_uid}
|
||||||
|
|||||||
Reference in New Issue
Block a user