fix(chat): render locked voice messages correctly
This commit is contained in:
@@ -1,12 +1,4 @@
|
||||
"use client";
|
||||
/**
|
||||
* MessageContent 消息内容容器
|
||||
*
|
||||
* 决定渲染 ImageBubble 还是 TextBubble:
|
||||
* - 有 imageUrl:渲染 ImageBubble(图片)
|
||||
* - 有 content 且非 "[图片]" 占位符:渲染 TextBubble(文字)
|
||||
* - 两者都有:图片在上,文字在下
|
||||
*/
|
||||
import { ImageBubble } from "./image-bubble";
|
||||
import { PrivateMessageCard } from "./private-message-card";
|
||||
import { TextBubble } from "./text-bubble";
|
||||
@@ -19,6 +11,8 @@ export interface MessageContentProps {
|
||||
imagePaywalled?: boolean;
|
||||
audioUrl?: string | null;
|
||||
isFromAI: boolean;
|
||||
locked?: boolean | null;
|
||||
lockReason?: string | null;
|
||||
lockedPrivate?: boolean | null;
|
||||
privateMessageHint?: string | null;
|
||||
isUnlockingPrivate?: boolean;
|
||||
@@ -35,6 +29,8 @@ export function MessageContent({
|
||||
imagePaywalled,
|
||||
audioUrl,
|
||||
isFromAI,
|
||||
locked,
|
||||
lockReason,
|
||||
lockedPrivate,
|
||||
privateMessageHint,
|
||||
isUnlockingPrivate = false,
|
||||
@@ -44,7 +40,10 @@ export function MessageContent({
|
||||
const hasImage = imageUrl != null && imageUrl.length > 0;
|
||||
const hasAudio = audioUrl != null && audioUrl.length > 0;
|
||||
const hasText = content.length > 0 && content !== IMAGE_PLACEHOLDER;
|
||||
const isLockedPrivateMessage = lockedPrivate === true;
|
||||
const isLockedPrivateMessage =
|
||||
lockedPrivate === true ||
|
||||
(locked === true && lockReason === "private_message");
|
||||
const isLockedVoiceMessage = locked === true && lockReason === "voice_message";
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -82,6 +81,14 @@ export function MessageContent({
|
||||
<VoiceBubble
|
||||
audioUrl={audioUrl}
|
||||
isFromAI={isFromAI}
|
||||
locked={isLockedVoiceMessage}
|
||||
hint={privateMessageHint}
|
||||
isUnlocking={isUnlockingPrivate}
|
||||
onUnlock={
|
||||
isLockedVoiceMessage && messageId
|
||||
? () => onUnlockPrivateMessage?.(messageId)
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{hasText && !hasAudio ? (
|
||||
|
||||
Reference in New Issue
Block a user