From 506a27e989f13c4871a87af6abeffac35ae70785 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 9 Aug 2023 04:28:18 +0200 Subject: [PATCH] Add `isStarred` callback to `StarredProvider` --- .../[lang]/(layout)/(contextStarred)/StarredContextData.ts | 1 + .../[lang]/(layout)/(contextStarred)/StarredProvider.tsx | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/todoblue/src/app/[lang]/(layout)/(contextStarred)/StarredContextData.ts b/todoblue/src/app/[lang]/(layout)/(contextStarred)/StarredContextData.ts index 53c4761..b095f7c 100644 --- a/todoblue/src/app/[lang]/(layout)/(contextStarred)/StarredContextData.ts +++ b/todoblue/src/app/[lang]/(layout)/(contextStarred)/StarredContextData.ts @@ -6,4 +6,5 @@ export interface StarredContextData { setStarred: Dispatch> addStarred: (key: string) => void, removeStarred: (key: string) => void, + isStarred: (key: string) => boolean, } diff --git a/todoblue/src/app/[lang]/(layout)/(contextStarred)/StarredProvider.tsx b/todoblue/src/app/[lang]/(layout)/(contextStarred)/StarredProvider.tsx index a83a1cc..297576a 100644 --- a/todoblue/src/app/[lang]/(layout)/(contextStarred)/StarredProvider.tsx +++ b/todoblue/src/app/[lang]/(layout)/(contextStarred)/StarredProvider.tsx @@ -32,8 +32,12 @@ export function StarredProvider({children}: {children: ReactNode}) { }) }, []) + const isStarred = useCallback((value: string) => { + return starred.indexOf(value) >= 0 + }, [starred]) + return ( - + {children} )