Skip to content

Commit

Permalink
fix remove favorite on opportunity delete (twentyhq#5686)
Browse files Browse the repository at this point in the history
- fix : twentyhq#5521

When we deleted an opportunity that had been added to the favorites
list, the opportunity was removed correctly, but it still remained in
the favorites list. The issue was due to not accounting for the removal
of the opportunity from the favorites during the deletion process.

This problem has now been fixed : 



https://github.com/twentyhq/twenty/assets/78202522/3d3cb689-3228-43fc-bf50-e824370582a7

Co-authored-by: Jeff Gasparini <[email protected]>
  • Loading branch information
JustGJ and Jeff Gasparini authored Jun 3, 2024
1 parent 0119e37 commit ccd93f7
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,22 @@ export const useRecordActionBar = ({

const handleDeleteClick = useCallback(async () => {
callback?.();
selectedRecordIds.forEach((recordId) => {
const foundFavorite = favorites?.find(
(favorite) => favorite.recordId === recordId,
);
if (foundFavorite !== undefined) {
deleteFavorite(foundFavorite.id);
}
});
await deleteManyRecords(selectedRecordIds);
}, [callback, deleteManyRecords, selectedRecordIds]);
}, [
callback,
deleteManyRecords,
selectedRecordIds,
favorites,
deleteFavorite,
]);

const handleExecuteQuickActionOnClick = useCallback(async () => {
callback?.();
Expand Down

0 comments on commit ccd93f7

Please sign in to comment.