Skip to content

Commit

Permalink
Update ReplayPage.jsx
Browse files Browse the repository at this point in the history
setLoading in a try>finally rather than referencing multiple times
  • Loading branch information
geelongmicrosoldering authored Dec 27, 2024
1 parent 5e0d235 commit 712de60
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/other/ReplayPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,22 @@ const ReplayPage = () => {
setFrom(from);
setTo(to);
const query = new URLSearchParams({ deviceId, from, to });
const response = await fetch(`/api/positions?${query.toString()}`);
if (response.ok) {
setIndex(0);
const positions = await response.json();
setPositions(positions);
setLoading(false);
if (positions.length) {
setExpanded(false);
try {
const response = await fetch(`/api/positions?${query.toString()}`);
if (response.ok) {
setIndex(0);
const positions = await response.json();
setPositions(positions);
if (positions.length) {
setExpanded(false);
} else {
throw Error(t('sharedNoData'));
}
} else {
throw Error(t('sharedNoData'));
throw Error(await response.text());
}
} else {
} finally {
setLoading(false);
throw Error(await response.text());
}
});

Expand Down

0 comments on commit 712de60

Please sign in to comment.