fix: reply with forwarded msg
This commit is contained in:
@@ -5,13 +5,15 @@ import clsx from "clsx";
|
|||||||
import { ContentTypes } from "@/app/config";
|
import { ContentTypes } from "@/app/config";
|
||||||
import { MessagePayload } from "@/app/slices/message";
|
import { MessagePayload } from "@/app/slices/message";
|
||||||
import { useAppSelector } from "@/app/store";
|
import { useAppSelector } from "@/app/store";
|
||||||
|
import { ChatContext } from "@/types/common";
|
||||||
import { getFileIcon, isImage } from "@/utils";
|
import { getFileIcon, isImage } from "@/utils";
|
||||||
import Avatar from "../Avatar";
|
import Avatar from "../Avatar";
|
||||||
import LinkifyText from "../LinkifyText";
|
import LinkifyText from "../LinkifyText";
|
||||||
import MarkdownRender from "../MarkdownRender";
|
import MarkdownRender from "../MarkdownRender";
|
||||||
|
import ForwardedMessage from "./ForwardedMessage";
|
||||||
|
|
||||||
const renderContent = (data: MessagePayload) => {
|
const renderContent = (data: MessagePayload, context: ChatContext, to: number) => {
|
||||||
const { content_type, content, thumbnail, properties } = data;
|
const { content_type, content, thumbnail, properties, created_at, from_uid = 0 } = data;
|
||||||
let res = null;
|
let res = null;
|
||||||
switch (content_type) {
|
switch (content_type) {
|
||||||
case ContentTypes.text:
|
case ContentTypes.text:
|
||||||
@@ -52,6 +54,22 @@ const renderContent = (data: MessagePayload) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ContentTypes.archive:
|
||||||
|
{
|
||||||
|
// const { size, name, file_type } = properties;
|
||||||
|
res = (
|
||||||
|
<ForwardedMessage
|
||||||
|
properties={properties}
|
||||||
|
context={context}
|
||||||
|
to={to}
|
||||||
|
from_uid={from_uid}
|
||||||
|
created_at={created_at}
|
||||||
|
id={content as string}
|
||||||
|
thumbnail={thumbnail}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -62,9 +80,11 @@ const renderContent = (data: MessagePayload) => {
|
|||||||
interface ReplyProps {
|
interface ReplyProps {
|
||||||
mid: number;
|
mid: number;
|
||||||
interactive?: boolean;
|
interactive?: boolean;
|
||||||
|
context: ChatContext;
|
||||||
|
to?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Reply: FC<ReplyProps> = ({ mid, interactive = true }) => {
|
const Reply: FC<ReplyProps> = ({ mid, interactive = true, context, to = 0 }) => {
|
||||||
const { t } = useTranslation("chat");
|
const { t } = useTranslation("chat");
|
||||||
const { data, users } = useAppSelector((store) => {
|
const { data, users } = useAppSelector((store) => {
|
||||||
return { data: store.message[mid], users: store.users.byId };
|
return { data: store.message[mid], users: store.users.byId };
|
||||||
@@ -112,7 +132,7 @@ const Reply: FC<ReplyProps> = ({ mid, interactive = true }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className={clsx("text-sm flex flex-col", interactive && "relative")}>
|
<div className={clsx("text-sm flex flex-col", interactive && "relative")}>
|
||||||
<span className="text-sm text-primary-500">{currUser.name}</span>
|
<span className="text-sm text-primary-500">{currUser.name}</span>
|
||||||
{renderContent(data)}
|
{renderContent(data, context, to)}
|
||||||
{interactive && <div className="absolute top-0 left-0 w-full h-full"></div>}
|
{interactive && <div className="absolute top-0 left-0 w-full h-full"></div>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -186,7 +186,9 @@ const Message: FC<IProps> = ({
|
|||||||
sending && "opacity-90"
|
sending && "opacity-90"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{reply_mid && <Reply key={reply_mid} mid={reply_mid} />}
|
{reply_mid && (
|
||||||
|
<Reply key={reply_mid} mid={reply_mid} context={context} to={contextId} />
|
||||||
|
)}
|
||||||
{edit ? (
|
{edit ? (
|
||||||
<EditMessage mid={mid} cancelEdit={toggleEditMessage} />
|
<EditMessage mid={mid} cancelEdit={toggleEditMessage} />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user