Skip to content

Commit

Permalink
Merge pull request #557 from CruGlobal/star-optimistic-response
Browse files Browse the repository at this point in the history
MPDX-7293: Add optimistic updates to starring contacts and tasks
  • Loading branch information
canac authored Nov 10, 2022
2 parents 8930c7e + b5153be commit 87cc178
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export const StarTaskIconButton: React.FC<Props> = ({
const toggleStarred = () => {
setTaskStarred({
variables: { accountListId, taskId, starred: !isStarred },
optimisticResponse: {
updateTask: {
__typename: 'TaskUpdateMutationPayload',
task: {
__typename: 'Task',
id: taskId,
starred: !isStarred,
},
},
},
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ export const StarContactIconButton: React.FC<Props> = ({
event.stopPropagation();
setContactStarred({
variables: { accountListId, contactId, starred: !isStarred },
optimisticResponse: {
updateContact: {
__typename: 'ContactUpdateMutationPayload',
contact: {
__typename: 'Contact',
id: contactId,
starred: !isStarred,
},
},
},
});
}}
>
Expand Down

0 comments on commit 87cc178

Please sign in to comment.