Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/feature/photo-detail/components/FooterPhotoDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export default function FooterPhotoDetail({
queryClient.invalidateQueries({
queryKey: [EP.album.albumPhotosLikers(albumId, photoId)],
});
queryClient.invalidateQueries({
queryKey: [EP.album.likedPhotos(albumId)],
});
Comment on lines +61 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

현재 '좋아요'한 사진 목록을 무효화하는 방식은 서버로부터 데이터를 다시 가져오게 만들어 약간의 지연을 유발할 수 있습니다. 사용자 경험을 향상시키기 위해, album.photos 쿼리에 대해 updateCacheAlbumPhotosLike에서 수행하는 것처럼 album.likedPhotos 쿼리에 대해서도 낙관적 업데이트(optimistic update)를 적용하는 것을 고려해 보세요. 사진을 '좋아요'하면 목록에 추가하고, '좋아요'를 취소하면 목록에서 제거하는 방식으로 즉각적인 UI 피드백을 줄 수 있습니다. 이를 구현하려면 현재 사진의 전체 데이터가 필요할 수 있는데, album.photos 쿼리 캐시에서 해당 데이터를 찾아 활용할 수 있습니다.

} catch (e) {
console.error(e);
Toast.alert(`좋에요에 실패하였습니다.`);
Expand Down
Loading