refactor: unify chat context type
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
// import { useEffect } from "react";
|
||||
import { ChatPrefixes } from "../../../app/config";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ChatContext } from "../../../types/common";
|
||||
type Props = {
|
||||
context: "user" | "channel",
|
||||
context: ChatContext,
|
||||
name: string
|
||||
};
|
||||
const DnDTip = ({ context, name }: Props) => {
|
||||
|
||||
@@ -3,9 +3,10 @@ import clsx from 'clsx';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useAppSelector } from '../../../app/store';
|
||||
import getUnreadCount from '../utils';
|
||||
import { ChatContext } from '../../../types/common';
|
||||
|
||||
type Props = {
|
||||
context: "channel" | "user",
|
||||
context: ChatContext,
|
||||
id: number,
|
||||
scrollToBottom?: () => void
|
||||
}
|
||||
@@ -20,7 +21,7 @@ const NewMessageBottomTip = ({ context, id, scrollToBottom }: Props) => {
|
||||
} = useAppSelector((store) => {
|
||||
return {
|
||||
readIndex: context == "channel" ? store.footprint.readChannels[id] : store.footprint.readUsers[id],
|
||||
mids: context == "user" ? store.userMessage.byId[id] : store.channelMessage[id],
|
||||
mids: context == "dm" ? store.userMessage.byId[id] : store.channelMessage[id],
|
||||
selects: store.ui.selectMessages[`${context}_${id}`],
|
||||
loginUid: store.authData.user?.uid ?? 0,
|
||||
data: context == "channel" ? store.channels.byId[id] : undefined,
|
||||
|
||||
@@ -11,9 +11,10 @@ import IconClose from "../../../assets/icons/close.circle.svg";
|
||||
import ForwardModal from "../../../common/component/ForwardModal";
|
||||
import DeleteMessageConfirmModal from "../../../common/component/DeleteMessageConfirm";
|
||||
import { useAppDispatch, useAppSelector } from "../../../app/store";
|
||||
import { ChatContext } from "../../../types/common";
|
||||
|
||||
type Props = {
|
||||
context: "user" | "channel";
|
||||
context: ChatContext;
|
||||
id: number;
|
||||
};
|
||||
const Operations: FC<Props> = ({ context, id }) => {
|
||||
|
||||
@@ -12,8 +12,9 @@ import CustomList from './CustomList';
|
||||
import CustomHeader from './CustomHeader';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { updateHistoryMark } from '../../../../app/slices/footprint';
|
||||
import { ChatContext } from '../../../../types/common';
|
||||
type Props = {
|
||||
context: "user" | "channel",
|
||||
context: ChatContext,
|
||||
id: number
|
||||
}
|
||||
// const firstMsgIndex = 10000;
|
||||
@@ -36,8 +37,8 @@ const VirtualMessageFeed = ({ context, id }: Props) => {
|
||||
footprint
|
||||
} = useAppSelector((store) => {
|
||||
return {
|
||||
historyMid: context == "user" ? store.footprint.historyUsers[id] : store.footprint.historyChannels[id],
|
||||
mids: context == "user" ? store.userMessage.byId[id] : store.channelMessage[id],
|
||||
historyMid: context == "dm" ? store.footprint.historyUsers[id] : store.footprint.historyChannels[id],
|
||||
mids: context == "dm" ? store.userMessage.byId[id] : store.channelMessage[id],
|
||||
selects: store.ui.selectMessages[`${context}_${id}`],
|
||||
footprint: store.footprint,
|
||||
loginUser: store.authData.user,
|
||||
|
||||
@@ -19,6 +19,7 @@ import ImagePreview from "../../../common/component/ImagePreview";
|
||||
import VirtualMessageFeed from "./VirtualMessageFeed";
|
||||
import DMVoice from "./DMVoicing";
|
||||
import AddContactTip from "./AddContactTip";
|
||||
import { ChatContext } from "../../../types/common";
|
||||
|
||||
interface Props {
|
||||
readonly?: boolean;
|
||||
@@ -27,7 +28,7 @@ interface Props {
|
||||
users?: ReactElement | null;
|
||||
voice?: ReactElement | null;
|
||||
dropFiles?: File[];
|
||||
context: "channel" | "user";
|
||||
context: ChatContext;
|
||||
to: number;
|
||||
}
|
||||
|
||||
@@ -100,8 +101,8 @@ const Layout: FC<Props> = ({
|
||||
{header}
|
||||
<div className="w-full h-full flex items-start justify-between relative" >
|
||||
<div className="rounded-br-2xl flex flex-col absolute bottom-0 w-full h-full" ref={messagesContainer}>
|
||||
{context == "user" && <DMVoice uid={to} />}
|
||||
{context == "user" && <AddContactTip uid={to} />}
|
||||
{context == "dm" && <DMVoice uid={to} />}
|
||||
{context == "dm" && <AddContactTip uid={to} />}
|
||||
{/* 消息流 */}
|
||||
<VirtualMessageFeed key={`${context}_${to}`} context={context} id={to} />
|
||||
{/* 发送框 */}
|
||||
|
||||
Reference in New Issue
Block a user