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

Function getOptimisticBookmarkCount

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

Source from the content-addressed store, hash-verified

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

Callers 3

defaultOnMutateFunction · 0.85
mutationHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected