Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

429 B
Raw Blame
import { useSyncExternalStore } from "react";
import {
    cachedCommentCount,
    subscribeToCommentCounts,
} from "services/comment-counts";

export const useCommentCount = (
    viewer: string | undefined,
    postId: number | undefined,
    initialCount = 0,
) =>
    useSyncExternalStore(
        subscribeToCommentCounts,
        () => cachedCommentCount(viewer, postId) ?? initialCount,
        () => initialCount,
    );