Skip to content

Commit 3bbe033

Browse files
authored
Update gitapi.js
1 parent 4e4d493 commit 3bbe033

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

git/gitapi.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11

22
// change pushing state
3-
function changePushingState(to) {
3+
4+
let pendingPromise;
5+
6+
function changePushingState(to, pendingPromise) {
47

58
if (to === true) {
9+
10+
pendingPromise = pendingPromise ?? null;
611

712
window.addEventListener('beforeunload', beforeUnloadListener, {capture: true});
813

914
} else {
15+
16+
pendingPromise = null;
1017

1118
window.removeEventListener('beforeunload', beforeUnloadListener, {capture: true});
1219

@@ -202,8 +209,17 @@ let git = {
202209
auto_init: false
203210
};
204211

205-
// post the query
206-
const resp = await axios.post(query, gitToken, repoData);
212+
// create post request with query
213+
const postRequest = axios.post(query, gitToken, repoData);
214+
215+
// change pushing state
216+
changePushingState(true, postRequest);
217+
218+
// await the request
219+
const resp = await postRequest;
220+
221+
// change pushing state
222+
changePushingState(false);
207223

208224
return resp.full_name;
209225

0 commit comments

Comments
 (0)