Starting fixing unhandled promises

This commit is contained in:
David Négrier 2021-12-16 18:18:55 +01:00
parent bade2b41b6
commit 6e27ffb2d5
7 changed files with 18 additions and 19 deletions

View file

@ -35,7 +35,6 @@ module.exports = {
"no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "error",
// TODO: remove those ignored rules and write a stronger code!
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/no-unsafe-assignment": "off",

View file

@ -20,62 +20,62 @@ class AnalyticsClient {
identifyUser(uuid: string, email: string | null) {
this.posthogPromise?.then((posthog) => {
posthog.identify(uuid, { uuid, email, wa: true });
});
}).catch(e => console.error(e));
}
loggedWithSso() {
this.posthogPromise?.then((posthog) => {
posthog.capture("wa-logged-sso");
});
}).catch(e => console.error(e));
}
loggedWithToken() {
this.posthogPromise?.then((posthog) => {
posthog.capture("wa-logged-token");
});
}).catch(e => console.error(e));
}
enteredRoom(roomId: string, roomGroup: string | null) {
this.posthogPromise?.then((posthog) => {
posthog.capture("$pageView", { roomId, roomGroup });
posthog.capture("enteredRoom");
});
}).catch(e => console.error(e));
}
openedMenu() {
this.posthogPromise?.then((posthog) => {
posthog.capture("wa-opened-menu");
});
}).catch(e => console.error(e));
}
launchEmote(emote: string) {
this.posthogPromise?.then((posthog) => {
posthog.capture("wa-emote-launch", { emote });
});
}).catch(e => console.error(e));
}
enteredJitsi(roomName: string, roomId: string) {
this.posthogPromise?.then((posthog) => {
posthog.capture("wa-entered-jitsi", { roomName, roomId });
});
}).catch(e => console.error(e));
}
validationName() {
this.posthogPromise?.then((posthog) => {
posthog.capture("wa-name-validation");
});
}).catch(e => console.error(e));
}
validationWoka(scene: string) {
this.posthogPromise?.then((posthog) => {
posthog.capture("wa-woka-validation", { scene });
});
}).catch(e => console.error(e));
}
validationVideo() {
this.posthogPromise?.then((posthog) => {
posthog.capture("wa-video-validation");
});
}).catch(e => console.error(e));
}
}
export const analyticsClient = new AnalyticsClient();

View file

@ -26,7 +26,7 @@ export class ActionMessage {
this.message = actionMessageOptions.message;
this.type = actionMessageOptions.type ?? "message";
this.callback = actionMessageOptions.callback;
this.create();
this.create().catch(e => console.error(e));
}
private async create() {

View file

@ -95,7 +95,7 @@ export function createState(target: "global" | "player"): WorkadventureStateComm
set(target: WorkadventureStateCommands, p: PropertyKey, value: unknown, receiver: unknown): boolean {
// Note: when using "set", there is no way to wait, so we ignore the return of the promise.
// User must use WA.state.saveVariable to have error message.
target.saveVariable(p.toString(), value);
target.saveVariable(p.toString(), value).catch(e => console.error(e));
return true;
},
has(target: WorkadventureStateCommands, p: PropertyKey): boolean {

View file

@ -25,7 +25,7 @@
HTMLAudioPlayer.loop = get(audioManagerVolumeStore).loop;
HTMLAudioPlayer.volume = get(audioManagerVolumeStore).volume;
HTMLAudioPlayer.muted = get(audioManagerVolumeStore).muted;
HTMLAudioPlayer.play();
void HTMLAudioPlayer.play();
});
unsubscriberVolumeStore = audioManagerVolumeStore.subscribe((audioManager: audioManagerVolume) => {
const reduceVolume = audioManager.talking && audioManager.decreaseWhileTalking;

View file

@ -19,12 +19,12 @@
uploadAudioActive = true;
}
function send() {
async function send(): Promise<void> {
if (inputSendTextActive) {
handleSendText.sendTextMessage(broadcastToWorld);
return handleSendText.sendTextMessage(broadcastToWorld);
}
if (uploadAudioActive) {
handleSendAudio.sendAudioMessage(broadcastToWorld);
return handleSendAudio.sendAudioMessage(broadcastToWorld);
}
}
</script>

View file

@ -41,10 +41,10 @@
gameManager.leaveGame(SelectCharacterSceneName, new SelectCharacterScene());
}
function logOut() {
async function logOut() {
disableMenuStores();
loginSceneVisibleStore.set(true);
connectionManager.logout();
return connectionManager.logout();
}
function getProfileUrl() {