Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading spinner for submit button #320

Merged
merged 2 commits into from
Aug 17, 2024
Merged
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
6 changes: 6 additions & 0 deletions app/segments/drill/[id]/submission/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@
["userInfo"], //assignments
["best_attempts", { drillId }],
["all_time_records", { drillId }],
["attempts", { userId: currentUserId, drillId }],
];

const { height } = useWindowDimensions();
Expand All @@ -746,6 +747,8 @@

const [currentShot, setCurrentShot] = useState(0); //a useState hook to track current shot to be attempted

const [submitLoading, setSubmitLoading] = useState(false);

/***** Navigation Bottom Sheet stuff *****/
const navModalRef = useRef(null);

Expand Down Expand Up @@ -778,6 +781,7 @@
labelStyle={styles.buttonText}
mode="contained-tonal"
onPress={handleButtonClick}
loading={submitLoading}
>
Submit Drill
</Button>
Expand Down Expand Up @@ -844,8 +848,9 @@
}
};

const handleSubmit = useCallback(

Check warning on line 851 in app/segments/drill/[id]/submission/input.js

View workflow job for this annotation

GitHub Actions / prettier-check

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
once(async () => {
setSubmitLoading(true);
const outputData = createOutputData(
drillInfo,
inputValues,
Expand Down Expand Up @@ -875,6 +880,7 @@
console.log(e);
showDialog("Error", getErrorString(e));
}
setSubmitLoading(false);
}),
[attemptShots, currentLeaderboard, inputValues, userInfo],
);
Expand Down
Loading