Skip to content

Commit c3f9846

Browse files
Update ReplayPage.jsx
Disable "Show" button while we wait for api response. Prevents subsequent API requests until the first one has returned
1 parent 582af9c commit c3f9846

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/other/ReplayPage.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const ReplayPage = () => {
9292
const [to, setTo] = useState();
9393
const [expanded, setExpanded] = useState(true);
9494
const [playing, setPlaying] = useState(false);
95+
const [loading, setLoading] = useState(false);
9596

9697
const deviceName = useSelector((state) => {
9798
if (selectedDeviceId) {
@@ -131,6 +132,7 @@ const ReplayPage = () => {
131132
}, [setShowCard]);
132133

133134
const handleSubmit = useCatch(async ({ deviceId, from, to }) => {
135+
setLoading(true);
134136
setSelectedDeviceId(deviceId);
135137
setFrom(from);
136138
setTo(to);
@@ -140,12 +142,14 @@ const ReplayPage = () => {
140142
setIndex(0);
141143
const positions = await response.json();
142144
setPositions(positions);
145+
setLoading(false);
143146
if (positions.length) {
144147
setExpanded(false);
145148
} else {
146149
throw Error(t('sharedNoData'));
147150
}
148151
} else {
152+
setLoading(false);
149153
throw Error(await response.text());
150154
}
151155
});
@@ -213,7 +217,7 @@ const ReplayPage = () => {
213217
</div>
214218
</>
215219
) : (
216-
<ReportFilter handleSubmit={handleSubmit} fullScreen showOnly />
220+
<ReportFilter handleSubmit={handleSubmit} fullScreen showOnly loading={loading} />
217221
)}
218222
</Paper>
219223
</div>

0 commit comments

Comments
 (0)