From f56ede452c8e7c2bd29f8e093dbfd1a8cc42f89c Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 26 Feb 2025 22:17:12 +0800 Subject: [PATCH] fix(mobile): grid footer unread status updating --- .../src/modules/entry-content/EntryGridFooter.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/mobile/src/modules/entry-content/EntryGridFooter.tsx b/apps/mobile/src/modules/entry-content/EntryGridFooter.tsx index 5d3cdf5ad..8ce665809 100644 --- a/apps/mobile/src/modules/entry-content/EntryGridFooter.tsx +++ b/apps/mobile/src/modules/entry-content/EntryGridFooter.tsx @@ -1,9 +1,11 @@ import { cn } from "@follow/utils" +import { useEffect } from "react" import { Text, View } from "react-native" -import ReAnimated, { useAnimatedStyle, useSharedValue } from "react-native-reanimated" +import ReAnimated, { useAnimatedStyle, useSharedValue, withSpring } from "react-native-reanimated" import { RelativeDateTime } from "@/src/components/ui/datetime/RelativeDateTime" import { FeedIcon } from "@/src/components/ui/icon/feed-icon" +import { gentleSpringPreset } from "@/src/constants/spring" import { useEntry } from "@/src/store/entry/hooks" import { useFeed } from "@/src/store/feed/hooks" @@ -19,6 +21,16 @@ export const EntryGridFooter = ({ const unreadZoomSharedValue = useSharedValue(entry?.read ? 0 : 1) + useEffect(() => { + if (!entry) return + + if (entry.read) { + unreadZoomSharedValue.value = withSpring(0, gentleSpringPreset) + } else { + unreadZoomSharedValue.value = withSpring(1, gentleSpringPreset) + } + }, [entry, entry?.read, unreadZoomSharedValue]) + const unreadIndicatorStyle = useAnimatedStyle(() => { return { width: unreadZoomSharedValue.value * 8,