Skip to content

Commit

Permalink
pr #1184: addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
helloanoop committed Dec 14, 2023
1 parent 2d16e07 commit ee2295a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import React from 'react';
import { IconEraser } from '@tabler/icons';
import { useDispatch } from 'react-redux';
import StyledWrapper from './StyledWrapper';
import { responseReceived } from 'providers/ReduxStore/slices/collections/index';
import { responseCleared } from 'providers/ReduxStore/slices/collections/index';

const ResponseClear = ({ collection, item }) => {
const dispatch = useDispatch();
const response = item.response || {};

const clearResponse = () =>
dispatch(
responseReceived({
responseCleared({
itemUid: item.uid,
collectionUid: collection.uid,
response: null
Expand All @@ -19,7 +18,7 @@ const ResponseClear = ({ collection, item }) => {

return (
<StyledWrapper className="ml-2 flex items-center">
<button onClick={clearResponse} disabled={!response.dataBuffer} title="Clear response">
<button onClick={clearResponse} title="Clear response">
<IconEraser size={16} strokeWidth={1.5} />
</button>
</StyledWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ export const collectionsSlice = createSlice({
}
}
},
responseCleared: (state, action) => {
const collection = findCollectionByUid(state.collections, action.payload.collectionUid);

if (collection) {
const item = findItemInCollection(collection, action.payload.itemUid);
if (item) {
item.response = null;
}
}
},
saveRequest: (state, action) => {
const collection = findCollectionByUid(state.collections, action.payload.collectionUid);

Expand Down Expand Up @@ -1397,6 +1407,7 @@ export const {
processEnvUpdateEvent,
requestCancelled,
responseReceived,
responseCleared,
saveRequest,
deleteRequestDraft,
newEphemeralHttpRequest,
Expand Down

0 comments on commit ee2295a

Please sign in to comment.