mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
fix: save unsaved request changes before moving to new location
This commit is contained in:
parent
59ffb0166f
commit
dd393babd9
@ -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));
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user