From dd393babd932e0a205adf164f2c00fbc9b142c2c Mon Sep 17 00:00:00 2001 From: therealrinku Date: Sat, 20 Apr 2024 22:04:29 +0545 Subject: [PATCH] fix: save unsaved request changes before moving to new location --- .../Collections/Collection/CollectionItem/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js index bf84b8289..573ac77f3 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js @@ -6,7 +6,7 @@ import { useDrag, useDrop } from 'react-dnd'; import { IconChevronRight, IconDots } from '@tabler/icons'; import { useSelector, useDispatch } from 'react-redux'; import { addTab, focusTab } from 'providers/ReduxStore/slices/tabs'; -import { moveItem, sendRequest } from 'providers/ReduxStore/slices/collections/actions'; +import { moveItem, sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions'; import { collectionFolderClicked } from 'providers/ReduxStore/slices/collections'; import Dropdown from 'components/Dropdown'; import NewRequest from 'components/Sidebar/NewRequest'; @@ -50,8 +50,12 @@ const CollectionItem = ({ item, collection, searchText }) => { const [{ isOver }, drop] = useDrop({ accept: `COLLECTION_ITEM_${collection.uid}`, - drop: (draggedItem) => { + drop: async (draggedItem) => { if (draggedItem.uid !== item.uid) { + // save unsaved request changes before moving the request item + if (draggedItem.draft) { + await dispatch(saveRequest(draggedItem.uid, collection.uid, true)); + } dispatch(moveItem(collection.uid, draggedItem.uid, item.uid)); } },