Refactor first unstable_cache wrapper
This commit is contained in:
parent
b15b0ed56f
commit
10fd66591e
10
src/cache/index.ts
vendored
10
src/cache/index.ts
vendored
@ -143,13 +143,11 @@ export const getPhotosCached: typeof getPhotos = (...args) =>
|
||||
}
|
||||
)().then(parseCachedPhotosDates);
|
||||
|
||||
export const getPhotosCountCached: typeof getPhotosCount = (...args) =>
|
||||
export const getPhotosCountCached =
|
||||
unstable_cache(
|
||||
() => getPhotosCount(...args),
|
||||
[KEY_PHOTOS, KEY_PHOTOS_COUNT], {
|
||||
tags: [KEY_PHOTOS, KEY_PHOTOS_COUNT],
|
||||
}
|
||||
)();
|
||||
(...args: Parameters<typeof getPhotosCount>) => getPhotosCount(...args),
|
||||
[KEY_PHOTOS, KEY_PHOTOS_COUNT],
|
||||
);
|
||||
|
||||
export const getPhotosCountIncludingHiddenCached: typeof getPhotosCount =
|
||||
(...args) =>
|
||||
|
||||
@ -97,7 +97,7 @@ export const parseCachedPhotoDates = (photo: Photo) => ({
|
||||
takenAt: new Date(photo.takenAt),
|
||||
updatedAt: new Date(photo.updatedAt),
|
||||
createdAt: new Date(photo.createdAt),
|
||||
});
|
||||
} as Photo);
|
||||
|
||||
export const parseCachedPhotosDates = (photos: Photo[]) =>
|
||||
photos.map(parseCachedPhotoDates);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user