feat(mobile): edit text messages
This commit is contained in:
@@ -2,6 +2,7 @@ import { useEffect, useRef } from "react";
|
||||
import { ScrollView, Text, View } from "react-native";
|
||||
import type { Particle } from "@/api/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { RelativeTimestamp } from "@/components/RelativeTimestamp";
|
||||
import { useStreamSafeArea } from "./stream-safe-area";
|
||||
|
||||
type TextParticle = Extract<Particle, { type: "text" }>;
|
||||
@@ -43,10 +44,19 @@ export function TextParticleView({
|
||||
onProgress,
|
||||
}: TextParticleViewProps) {
|
||||
const content = particle.properties.content;
|
||||
const editedAt = particle.properties.edited_at;
|
||||
const durationS = computeReadDuration(content);
|
||||
const elapsedRef = useRef(0);
|
||||
const safe = useStreamSafeArea();
|
||||
|
||||
const editedLabel = editedAt ? (
|
||||
<View className="mt-3 items-center">
|
||||
<Text className="text-white/40 text-xs">
|
||||
edited <RelativeTimestamp date={editedAt} />
|
||||
</Text>
|
||||
</View>
|
||||
) : null;
|
||||
|
||||
// Reset when the particle changes.
|
||||
useEffect(() => {
|
||||
elapsedRef.current = 0;
|
||||
@@ -85,6 +95,7 @@ export function TextParticleView({
|
||||
>
|
||||
{content}
|
||||
</Text>
|
||||
{editedLabel}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -108,6 +119,7 @@ export function TextParticleView({
|
||||
indicatorStyle="white"
|
||||
>
|
||||
<Text className="text-white text-lg leading-relaxed">{content}</Text>
|
||||
{editedLabel}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user