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

Function getOptimisticBookmarkCount

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

Source from the content-addressed store, hash-verified

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

Callers 2

defaultOnMutateFunction · 0.85
mutationHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected