feat: add favorites state and buttons

This commit is contained in:
TerryM
2026-06-02 00:36:11 +08:00
parent 43700d9fdc
commit 337e8f7e67
16 changed files with 491 additions and 93 deletions

View File

@@ -9,6 +9,7 @@ import { FilterChips } from "./FilterChips";
import { MessageBubble } from "./MessageBubble";
import { useGroupedByDay } from "./hooks/useGroupedByDay";
import { usePostStream } from "./hooks/usePostStream";
import { useFavorites } from "../../favorites/FavoritesProvider";
export type MessageStreamProps = {
scope: PostScope;
@@ -30,9 +31,14 @@ export function MessageStream({ scope }: MessageStreamProps) {
const { items, isLoading, error, hasMore, loadMore, reset } =
usePostStream(params);
const { ensureFavoriteIds } = useFavorites();
const groups = useGroupedByDay(items, lang);
const retryLabel = lang === "zh-CN" ? "重试" : "Retry";
useEffect(() => {
void ensureFavoriteIds(items.map((item) => item.id)).catch(() => undefined);
}, [ensureFavoriteIds, items]);
const sentinelRef = useRef<HTMLDivElement>(null);
const filterBarRef = useRef<HTMLDivElement>(null);
const hasMoreRef = useRef(hasMore);