From 6e27ffb2d55ae4113458e25732adff07b192a038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 16 Dec 2021 18:18:55 +0100 Subject: [PATCH] Starting fixing unhandled promises --- front/.eslintrc.js | 1 - front/src/Administration/AnalyticsClient.ts | 20 +++++++++---------- front/src/Api/iframe/Ui/ActionMessage.ts | 2 +- front/src/Api/iframe/state.ts | 2 +- .../AudioManager/AudioManager.svelte | 2 +- .../Menu/GlobalMessagesSubMenu.svelte | 6 +++--- .../src/Components/Menu/ProfileSubMenu.svelte | 4 ++-- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/front/.eslintrc.js b/front/.eslintrc.js index 117cb7e6..dc2b6bd6 100644 --- a/front/.eslintrc.js +++ b/front/.eslintrc.js @@ -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", diff --git a/front/src/Administration/AnalyticsClient.ts b/front/src/Administration/AnalyticsClient.ts index fb2b604b..4248339b 100644 --- a/front/src/Administration/AnalyticsClient.ts +++ b/front/src/Administration/AnalyticsClient.ts @@ -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(); diff --git a/front/src/Api/iframe/Ui/ActionMessage.ts b/front/src/Api/iframe/Ui/ActionMessage.ts index 912603b9..f4e6a937 100644 --- a/front/src/Api/iframe/Ui/ActionMessage.ts +++ b/front/src/Api/iframe/Ui/ActionMessage.ts @@ -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() { diff --git a/front/src/Api/iframe/state.ts b/front/src/Api/iframe/state.ts index 7021b251..ccc671f6 100644 --- a/front/src/Api/iframe/state.ts +++ b/front/src/Api/iframe/state.ts @@ -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 { diff --git a/front/src/Components/AudioManager/AudioManager.svelte b/front/src/Components/AudioManager/AudioManager.svelte index c4ca44f9..b62d8fbe 100644 --- a/front/src/Components/AudioManager/AudioManager.svelte +++ b/front/src/Components/AudioManager/AudioManager.svelte @@ -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; diff --git a/front/src/Components/Menu/GlobalMessagesSubMenu.svelte b/front/src/Components/Menu/GlobalMessagesSubMenu.svelte index 524e5e50..e755a243 100644 --- a/front/src/Components/Menu/GlobalMessagesSubMenu.svelte +++ b/front/src/Components/Menu/GlobalMessagesSubMenu.svelte @@ -19,12 +19,12 @@ uploadAudioActive = true; } - function send() { + async function send(): Promise { if (inputSendTextActive) { - handleSendText.sendTextMessage(broadcastToWorld); + return handleSendText.sendTextMessage(broadcastToWorld); } if (uploadAudioActive) { - handleSendAudio.sendAudioMessage(broadcastToWorld); + return handleSendAudio.sendAudioMessage(broadcastToWorld); } } diff --git a/front/src/Components/Menu/ProfileSubMenu.svelte b/front/src/Components/Menu/ProfileSubMenu.svelte index 07356f6c..87bf57c9 100644 --- a/front/src/Components/Menu/ProfileSubMenu.svelte +++ b/front/src/Components/Menu/ProfileSubMenu.svelte @@ -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() {