Skip to content

Commit

Permalink
Migrate to Lens v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoginth committed Dec 8, 2024
1 parent 07c43d0 commit 4ff2ea5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
7 changes: 5 additions & 2 deletions apps/web/src/components/Post/Actions/Like.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ const Like: FC<LikeProps> = ({ post, showCount }) => {
});
cache.modify({
fields: {
reactions: () => (hasReacted ? reactions - 1 : reactions + 1)
stats: (existingData) => ({
...existingData,
reactions: hasReacted ? reactions - 1 : reactions + 1
})
},
id: cache.identify(post.stats)
id: cache.identify(post)
});
};

Expand Down
7 changes: 5 additions & 2 deletions apps/web/src/components/Post/Actions/Menu/Bookmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ const Bookmark: FC<BookmarkProps> = ({ post }) => {
});
cache.modify({
fields: {
bookmarks: () => (hasBookmarked ? bookmarks - 1 : bookmarks + 1)
stats: (existingData) => ({
...existingData,
bookmarks: hasBookmarked ? bookmarks - 1 : bookmarks + 1
})
},
id: cache.identify(post.stats)
id: cache.identify(post)
});

// Remove bookmarked post from bookmarks feed
Expand Down
9 changes: 7 additions & 2 deletions apps/web/src/components/Post/Actions/Share/Repost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ const Repost: FC<RepostProps> = ({ isLoading, post, setIsLoading }) => {
id: cache.identify(post.operations as LoggedInPostOperations)
});
cache.modify({
fields: { reposts: () => shares + 1 },
id: cache.identify(post.stats)
fields: {
stats: (existingData) => ({
...existingData,
reposts: shares + 1
})
},
id: cache.identify(post)
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ const CollectAction: FC<CollectActionProps> = ({
id: cache.identify(post)
});
cache.modify({
fields: { countOpenActions: () => countOpenActions + 1 },
id: cache.identify(post.stats)
fields: {
stats: (existingData) => ({
...existingData,
countOpenActions: countOpenActions + 1
})
},
id: cache.identify(post)
});
};

Expand Down

0 comments on commit 4ff2ea5

Please sign in to comment.