Skip to content

Commit

Permalink
Merge pull request #1893 from anth-volk/fix/1883-queue-none
Browse files Browse the repository at this point in the history
Properly display queue message
  • Loading branch information
MaxGhenis authored Jun 20, 2024
2 parents 07e8e29 + 3648a0b commit 22fa28c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/pages/policy/output/Display.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ export function DisplayError(props) {
* @returns component for displaying a progress bar that fills up over time
*/
export function DisplayWait(props) {
const { secondsElapsed, averageImpactTime, queueMsg } = props;
const { secondsElapsed, averageImpactTime, queuePos } = props;

let queueMsg = "";
if (Number(queuePos) === 0) {
queueMsg = "We are currently running your simulation.";
} else {
queueMsg = `Your position in the queue is ${queuePos}.`;
}

return (
<div style={{ textAlign: "center", paddingTop: 50 }}>
<LoadingCentered message="Simulating the impact of your policy..." />
Expand Down
9 changes: 7 additions & 2 deletions src/pages/policy/output/FetchAndDisplayImpact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function FetchAndDisplayImpact(props) {
const [error, setError] = useState(null);
const [averageImpactTime, setAverageImpactTime] = useState(20);
const [secondsElapsed, setSecondsElapsed] = useState(0);
const [queueMsg, setQueueMsg] = useState("");
const [queuePos, setQueuePos] = useState("");

const policyRef = useRef(null);
const countryId = useCountryId();
Expand All @@ -56,9 +56,14 @@ export function FetchAndDisplayImpact(props) {
function computingCallback(data) {
// Position in queue message only occurs with average_time
// in the response object; if this is present, enable message
/*
if (data.average_time && data.message) {
setQueueMsg(data.message);
}
*/
if (data.queue_position) {
setQueuePos(data.queue_position);
}
}

useEffect(() => {
Expand Down Expand Up @@ -178,7 +183,7 @@ export function FetchAndDisplayImpact(props) {
<DisplayWait
averageImpactTime={averageImpactTime}
secondsElapsed={secondsElapsed}
queueMsg={queueMsg}
queuePos={queuePos}
/>
);
}
Expand Down

0 comments on commit 22fa28c

Please sign in to comment.