Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/_helpers/service.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function handleResponse(response: Response) {
isJson = false;
}

if (!response.ok) {
if (!response.ok || !isJson) {
if (response.status === 401) {
// auto logout if 401 response returned from api
usersService.logout();
Expand All @@ -41,15 +41,15 @@ export function handleResponse(response: Response) {
}
}

const error = data?.message || response.statusText;
// a successful status with a body that is not JSON is no answer either
const error =
data?.message ||
(response.ok ? "Unexpected response from the server" : "") ||
response.statusText;

return Promise.reject(error);
}

if (!isJson) {
return Promise.reject("Unexpected response from the server");
}

return data;
});
}
21 changes: 11 additions & 10 deletions src/components/TestDetailsDialog/TestDetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,17 @@ const TestDetailsModal: React.FunctionComponent<TestDetailsModalProps> = ({

// returned, so a failure reaches the catch below: the progress bar
// stayed up for good and nobody heard about the error
return testRunService.addIgnoreAreas(data).then(() => {
setProcessing(false);
setSelectedRectId(undefined);
enqueueSnackbar(
"Ignore areas are updated in all images in this build.",
{
variant: "success",
},
);
});
return testRunService.addIgnoreAreas(data);
})
.then(() => {
setProcessing(false);
setSelectedRectId(undefined);
enqueueSnackbar(
"Ignore areas are updated in all images in this build.",
{
variant: "success",
},
);
})
.catch((error) => {
enqueueSnackbar(`There was an error : ${error}`, {
Expand Down
4 changes: 3 additions & 1 deletion src/services/static.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ async function downloadAsZip(
const taken = new Set<string>();
const entryNames = items.map((item) => {
let entryName = `${item.filename}.png`;
for (let copy = 2; taken.has(entryName); copy++) {
let copy = 1;
while (taken.has(entryName)) {
copy += 1;
entryName = `${item.filename} (${copy}).png`;
}
taken.add(entryName);
Expand Down
Loading