Skip to content

Commit

Permalink
Small Improvements (#136)
Browse files Browse the repository at this point in the history
* fix javascript error

* check if timings exists before accessing its properties

* revert status change
  • Loading branch information
yuyi-sl authored Aug 5, 2024
1 parent af736dd commit 0f758c5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
24 changes: 15 additions & 9 deletions src/Components/Import/ImportHAR.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ const DROP_FILE_CONFIG = {
multiple: false,
};

const ImportHar = ({ showButton, className }) => {
const ImportHar = ({
showButton,
className,
}) => {
const { actions } = useNetwork();
const { updateErrorMessage } = actions;

const prepareData = (newNetworkData) => (
actions.updateData({
entries: newNetworkData.log.entries,
pages: newNetworkData.log.pages,
})
);
const prepareData = (newNetworkData) => actions.updateData(newNetworkData);

const onDrop = (files) => {
const reader = new FileReader();
Expand All @@ -39,7 +37,10 @@ const ImportHar = ({ showButton, className }) => {
reader.readAsText(files[0]);
};

const { getRootProps, getInputProps } = useDropzone({
const {
getRootProps,
getInputProps,
} = useDropzone({
...DROP_FILE_CONFIG,
onDrop,
});
Expand All @@ -49,7 +50,12 @@ const ImportHar = ({ showButton, className }) => {
<input {...getInputProps()} />
{showButton ?
(<ImportHarButton />) :
(<p className={Styles['drag-drop']}>Drag and drop HAR file here, or click to select file</p>)}
(
<p className={Styles['drag-drop']}>
Drag and drop HAR file here, or click to select
file
</p>
)}
</div>
);
};
Expand Down
18 changes: 11 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,23 @@ export const sortHeaders = (current, next) => {
return current.name > next.name ? 1 : 0;
};

export const getHeaders = (entry) => ({
request: entry.request.headers.sort(sortHeaders),
response: entry.response.headers.sort(sortHeaders),
queryString: entry.request.queryString,
postData: entry.request.postData,
});
export const getHeaders = (entry) => {
const requestHeaders = [...entry.request.headers];
const responseHeaders = [...entry.response.headers];
return {
request: requestHeaders.sort(sortHeaders),
response: responseHeaders.sort(sortHeaders),
queryString: entry.request.queryString,
postData: entry.request.postData,
};
};

export const getTotalTimeOfEntry = ({
startedDateTime,
time,
timings,
}) => (
new Date(startedDateTime).getTime() + time + (timings._blocked_queueing || timings._queued || 0)
new Date(startedDateTime).getTime() + time + (timings?._blocked_queueing || timings?._queued || 0)
);

export const getInterceptError = ({ response }) => (
Expand Down

0 comments on commit 0f758c5

Please sign in to comment.