Skip to content

Commit

Permalink
Conform to no-floating-promises (#27561)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Jun 12, 2024
1 parent 9039e70 commit a0eb947
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module.exports = {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-floating-promises": "off",
},
},
],
Expand Down
4 changes: 2 additions & 2 deletions src/vector/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async function start(): Promise<void> {
// error handling begins here
// ##########################
if (!acceptBrowser) {
await new Promise<void>((resolve) => {
await new Promise<void>((resolve, reject) => {
logger.error("Browser is missing required features.");
// take to a different landing page to AWOOOOOGA at the user
showIncompatibleBrowser(() => {
Expand All @@ -189,7 +189,7 @@ async function start(): Promise<void> {
}
logger.log("User accepts the compatibility risks.");
resolve();
});
}).catch(reject);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/vector/init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export async function loadLanguage(): Promise<void> {
}

export async function loadTheme(): Promise<void> {
setTheme();
return setTheme();
}

export async function loadApp(fragParams: {}): Promise<void> {
Expand Down
24 changes: 12 additions & 12 deletions src/vector/jitsi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,17 @@ const setupCompleted = (async (): Promise<string | void> => {
}
}

await widgetApi!.transport.reply(ev.detail, response);
widgetApi!.transport.reply(ev.detail, response);
});
};

handleAction(ElementWidgetActions.JoinCall, async ({ audioInput, videoInput }) => {
joinConference(audioInput as string | null, videoInput as string | null);
void joinConference(audioInput as string | null, videoInput as string | null);
});
handleAction(ElementWidgetActions.HangupCall, async ({ force }) => {
if (force === true) {
meetApi?.dispose();
notifyHangup();
void notifyHangup();
meetApi = undefined;
closeConference();
} else {
Expand Down Expand Up @@ -297,7 +297,7 @@ function toggleConferenceVisibility(inConference: boolean): void {

function skipToJitsiSplashScreen(): void {
// really just a function alias for self-documenting code
joinConference();
void joinConference();
}

/**
Expand Down Expand Up @@ -500,32 +500,32 @@ const onVideoConferenceJoined = (): void => {
if (widgetApi) {
// ignored promise because we don't care if it works
// noinspection JSIgnoredPromiseFromCall
widgetApi.setAlwaysOnScreen(true);
widgetApi.transport.send(ElementWidgetActions.JoinCall, {});
void widgetApi.setAlwaysOnScreen(true);
void widgetApi.transport.send(ElementWidgetActions.JoinCall, {});
}

// Video rooms should start in tile mode
if (isVideoChannel) meetApi?.executeCommand("setTileView", true);
};

const onVideoConferenceLeft = (): void => {
notifyHangup();
void notifyHangup();
meetApi = undefined;
};

const onErrorOccurred = ({ error }: Parameters<ExternalAPIEventCallbacks["errorOccurred"]>[0]): void => {
if (error.isFatal) {
// We got disconnected. Since Jitsi Meet might send us back to the
// prejoin screen, we're forced to act as if we hung up entirely.
notifyHangup(error.message);
void notifyHangup(error.message);
meetApi = undefined;
closeConference();
}
};

const onAudioMuteStatusChanged = ({ muted }: AudioMuteStatusChangedEvent): void => {
const action = muted ? ElementWidgetActions.MuteAudio : ElementWidgetActions.UnmuteAudio;
widgetApi?.transport.send(action, {});
void widgetApi?.transport.send(action, {});
};

const onVideoMuteStatusChanged = ({ muted }: VideoMuteStatusChangedEvent): void => {
Expand All @@ -535,15 +535,15 @@ const onVideoMuteStatusChanged = ({ muted }: VideoMuteStatusChangedEvent): void
// otherwise the React SDK will mistakenly think the user turned off
// their video by hand
setTimeout(() => {
if (meetApi) widgetApi?.transport.send(ElementWidgetActions.MuteVideo, {});
if (meetApi) void widgetApi?.transport.send(ElementWidgetActions.MuteVideo, {});
}, 200);
} else {
widgetApi?.transport.send(ElementWidgetActions.UnmuteVideo, {});
void widgetApi?.transport.send(ElementWidgetActions.UnmuteVideo, {});
}
};

const updateParticipants = (): void => {
widgetApi?.transport.send(ElementWidgetActions.CallParticipants, {
void widgetApi?.transport.send(ElementWidgetActions.CallParticipants, {
participants: meetApi?.getParticipantsInfo(),
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/vector/mobile_guide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ async function initPage(): Promise<void> {
}
}

initPage();
void initPage();
17 changes: 8 additions & 9 deletions src/vector/platform/ElectronPlatform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,14 @@ export default class ElectronPlatform extends VectorBasePlatform {
});
});

window.electron.on("openDesktopCapturerSourcePicker", () => {
window.electron.on("openDesktopCapturerSourcePicker", async () => {
const { finished } = Modal.createDialog(DesktopCapturerSourcePicker);
finished.then(([source]) => {
// getDisplayMedia promise does not return if no dummy is passed here as source
this.ipc.call("callDisplayMediaCallback", source ?? { id: "", name: "", thumbnailURL: "" });
});
const [source] = await finished;
// getDisplayMedia promise does not return if no dummy is passed here as source
await this.ipc.call("callDisplayMediaCallback", source ?? { id: "", name: "", thumbnailURL: "" });
});

this.ipc.call("startSSOFlow", this.ssoID);
void this.ipc.call("startSSOFlow", this.ssoID);

BreadcrumbsStore.instance.on(UPDATE_EVENT, this.onBreadcrumbsUpdate);
}
Expand All @@ -195,7 +194,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
),
initial: getInitialLetter(r.name),
}));
this.ipc.call("breadcrumbs", rooms);
void this.ipc.call("breadcrumbs", rooms);
};

private onUpdateDownloaded = async (ev: Event, { releaseNotes, releaseName }: SquirrelUpdate): Promise<void> => {
Expand Down Expand Up @@ -261,7 +260,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
const handler = notification.onclick as Function;
notification.onclick = (): void => {
handler?.();
this.ipc.call("focusWindow");
void this.ipc.call("focusWindow");
};

return notification;
Expand Down Expand Up @@ -399,7 +398,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
}

public navigateForwardBack(back: boolean): void {
this.ipc.call(back ? "navigateBack" : "navigateForward");
void this.ipc.call(back ? "navigateBack" : "navigateForward");
}

public overrideBrowserShortcuts(): boolean {
Expand Down
8 changes: 4 additions & 4 deletions src/vector/platform/WebPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ export default class WebPlatform extends VectorBasePlatform {
// annoyingly, the latest spec says this returns a
// promise, but this is only supported in Chrome 46
// and Firefox 47, so adapt the callback API.
return new Promise(function (resolve) {
return new Promise(function (resolve, reject) {
window.Notification.requestPermission((result) => {
resolve(result);
});
}).catch(reject);
});
}

Expand Down Expand Up @@ -148,7 +148,7 @@ export default class WebPlatform extends VectorBasePlatform {
// Ideally, loading an old copy would be impossible with the
// cache-control: nocache HTTP header set, but Firefox doesn't always obey it :/
console.log("startUpdater, current version is " + getNormalizedAppVersion(WebPlatform.VERSION));
this.pollForUpdate((version: string, newVersion: string) => {
void this.pollForUpdate((version: string, newVersion: string) => {
const query = parseQs(location);
if (query.updated) {
console.log("Update reloaded but still on an old version, stopping");
Expand Down Expand Up @@ -207,7 +207,7 @@ export default class WebPlatform extends VectorBasePlatform {

public startUpdateCheck(): void {
super.startUpdateCheck();
this.pollForUpdate(showUpdateToast, hideUpdateToast).then((updateState) => {
void this.pollForUpdate(showUpdateToast, hideUpdateToast).then((updateState) => {
dis.dispatch<CheckUpdatesPayload>({
action: Action.CheckUpdates,
...updateState,
Expand Down
4 changes: 2 additions & 2 deletions src/vector/rageshakesetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function initRageshake(): Promise<void> {
// we manually check persistence for rageshakes ourselves
const prom = rageshake.init(/*setUpPersistence=*/ false);
prom.then(
() => {
async () => {
logger.log("Initialised rageshake.");
logger.log(
"To fix line numbers in Chrome: " +
Expand All @@ -48,7 +48,7 @@ export function initRageshake(): Promise<void> {
rageshake.flush();
});

rageshake.cleanup();
await rageshake.cleanup();
},
(err) => {
logger.error("Failed to initialise rageshake: " + err);
Expand Down

0 comments on commit a0eb947

Please sign in to comment.