mirror of
https://gitlab.com/aviortheking/code-stats-vscode.git
synced 2025-04-22 10:52:13 +00:00
Reset XP counter when API call is accepted
This commit is contained in:
parent
ac731b06ed
commit
23466f311e
@ -26,7 +26,7 @@ export class CodeStatsAPI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sendUpdate(pulse: Pulse): void {
|
public sendUpdate(pulse: Pulse): axios.AxiosPromise {
|
||||||
// If we did not have API key, don't try to update
|
// If we did not have API key, don't try to update
|
||||||
if (this.axios === null) {
|
if (this.axios === null) {
|
||||||
return null;
|
return null;
|
||||||
@ -44,7 +44,7 @@ export class CodeStatsAPI {
|
|||||||
let json: string = JSON.stringify(data);
|
let json: string = JSON.stringify(data);
|
||||||
console.log(`JSON: ${json}`);
|
console.log(`JSON: ${json}`);
|
||||||
|
|
||||||
this.axios.post(this.UPDATE_URL, json)
|
return this.axios.post(this.UPDATE_URL, json)
|
||||||
.then( (response) => {
|
.then( (response) => {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
})
|
})
|
||||||
|
@ -63,7 +63,13 @@ export class XpCounter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.updateTimeout = setTimeout(() => {
|
this.updateTimeout = setTimeout(() => {
|
||||||
this.api.sendUpdate(this.pulse);
|
const promise = this.api.sendUpdate(this.pulse);
|
||||||
|
|
||||||
|
if (promise !== null) {
|
||||||
|
promise.then(() => {
|
||||||
|
this.updateStatusBar(show, `${this.pulse.getXP(document.languageId)}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
}, this.UPDATE_DELAY);
|
}, this.UPDATE_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user