Skip to content

Commit

Permalink
Update Favorite UI optimistically
Browse files Browse the repository at this point in the history
Instead of waiting for the request to complete, we remove the fill state optimistically
  • Loading branch information
JacobArrow committed Nov 19, 2024
1 parent 8e38f1b commit f03f073
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/button-favourite/button-favourite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ const ButtonFavourite: React.FC<ButtonFavouriteProps> = ({
const handleClick = useCallback(
(e: React.MouseEvent<HTMLButtonElement>) => {
if (fillState) {
setFillState(false);
removeItem(
{ listId, itemId: id },
{
onSuccess: () => {
// Invalidate the query to remove any faved materials from favorites list
queryClient.invalidateQueries(getGetListQueryKey(listId));
setFillState(false);
}
}
);
Expand Down

0 comments on commit f03f073

Please sign in to comment.