MCPcopy Create free account
hub / github.com/dailydotdev/apps / getOptimisticBookmarkCount

Function getOptimisticBookmarkCount

packages/shared/src/hooks/useBookmarkPost.ts:78–84  ·  view source on GitHub ↗
(
  currentBookmarks: number | null | undefined,
  isCurrentlyBookmarked: boolean | null | undefined,
)

Source from the content-addressed store, hash-verified

76};
77
78export const getOptimisticBookmarkCount = (
79 currentBookmarks: number | null | undefined,
80 isCurrentlyBookmarked: boolean | null | undefined,
81): number => {
82 const delta = isCurrentlyBookmarked ? -1 : 1;
83 return Math.max(0, (currentBookmarks ?? 0) + delta);
84};
85
86export type UseBookmarkPost = {
87 toggleBookmark: (props: ToggleBookmarkProps) => Promise<void>;

Callers 3

defaultOnMutateFunction · 0.85
mutationHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected