Refactor first unstable_cache wrapper

This commit is contained in:
Sam Becker 2023-11-14 22:43:29 -06:00
parent b15b0ed56f
commit 10fd66591e
2 changed files with 5 additions and 7 deletions

10
src/cache/index.ts vendored
View File

@ -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) =>

View File

@ -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);