1
0
Fork 0

Stop using "void " on async methods.

This commit is contained in:
Kitteh 2021-05-16 12:37:23 +01:00
parent d658f468a5
commit 6edd037f8d
9 changed files with 50 additions and 55 deletions

View file

View file

@ -1,34 +1,34 @@
{
"devDependencies": {
"@babel/eslint-parser": "^7.13.14",
"@babel/eslint-parser": "^7.14.2",
"@types/prismjs": "^1.16.5",
"@types/uikit": "^3.3.1",
"@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"clipboard": "^2.0.8",
"codejar": "^3.4.0",
"css-loader": "^5.2.4",
"date-fns": "^2.21.3",
"eslint": "^7.26.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-import": "^2.23.2",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
"file-saver": "^2.0.5",
"git-revision-webpack-plugin": "^5.0.0",
"html-webpack-plugin": "^5.3.1",
"i18next": "^20.2.2",
"i18next": "^20.2.4",
"mini-css-extract-plugin": "^1.6.0",
"node-sass": "^5.0.0",
"node-sass": "^6.0.0",
"prettier": "^2.3.0",
"prismjs": "^1.23.0",
"qr-scanner": "^1.2.0",
"raw-loader": "^4.0.2",
"sass-loader": "^11.0.1",
"sass-loader": "^11.1.1",
"ts-loader": "^9.1.2",
"typescript": "^4.2.4",
"uikit": "^3.6.21",
"webpack": "^5.36.2",
"webpack": "^5.37.0",
"webpack-cli": "^4.7.0",
"webpack-dev-server": "^3.11.2",
"z-pagerouter": "^1.0.1"

View file

@ -62,7 +62,6 @@ export const allPages: pagesList = {
NEW_TRANSIT_ENGINE: new NewTransitEnginePage(),
};
// This should implement all o PageListType
class PageList {
constructor(pages: pagesList) {

View file

@ -33,7 +33,7 @@ export async function QRScanner(onScan: (code: string) => void): Promise<QRScann
if (lastSeenValue == value) return;
onScan(value);
});
void qrScanner.start();
await qrScanner.start();
QRInput.deinit = () => {
try {

View file

@ -102,30 +102,27 @@ async function onLoad(): Promise<void> {
document.addEventListener(
"DOMContentLoaded",
function () {
async () => {
console.log("Loading...");
// @ts-expect-error
console.log("Build Data:", BUILD_STRING);
void i18next
.init({
lng: pageState.language,
fallbackLng: "en",
debug: true,
// @ts-ignore
resources: Object.fromEntries(
Object.entries(translations).map(([k, v]) => [k, { translation: v }]),
),
interpolation: {
format: function (value: unknown, format, _): string {
if (format === "until_date" && value instanceof Date)
return formatDistance(new Date(), new Date(value), pageState.language);
return value as string;
},
await i18next.init({
lng: pageState.language,
fallbackLng: "en",
debug: true,
// @ts-ignore
resources: Object.fromEntries(
Object.entries(translations).map(([k, v]) => [k, { translation: v }]),
),
interpolation: {
format: function (value: unknown, format, _): string {
if (format === "until_date" && value instanceof Date)
return formatDistance(new Date(), new Date(value), pageState.language);
return value as string;
},
})
.then(function (_) {
void onLoad();
});
},
});
await onLoad();
},
false,
);

View file

@ -30,16 +30,15 @@ export class KeyValueDeletePage extends Page {
tag: "button",
class: ["uk-button", "uk-button-danger"],
text: i18next.t("kv_delete_btn"),
onclick: () => {
void deleteSecret(
onclick: async () => {
await deleteSecret(
this.state.currentBaseMount,
this.state.currentMountType,
this.state.currentSecretPath,
this.state.currentSecret,
this.state.currentSecretVersion,
).then(() => {
void this.goBack();
});
);
await this.goBack();
},
}),
],

View file

@ -49,14 +49,14 @@ export class MePage extends Page {
children: makeElement({
tag: "a",
text: i18next.t("renew_lease_btn"),
onclick: () => {
renewSelf()
.then(() => {
void this.router.changePage("HOME");
})
.catch((e: Error) => {
setErrorText(e.message);
});
onclick: async () => {
try {
await renewSelf();
await this.router.changePage("HOME");
} catch (e: unknown) {
const error = e as Error;
setErrorText(error.message);
}
},
}),
}),

View file

@ -55,7 +55,7 @@ export class TOTPViewPage extends Page {
const totpListElement = this.makeTOTPListElement(totpKeyName);
totpList.appendChild(totpListElement);
this.totpListElements[totpKeyName] = totpListElement;
void this.updateTOTPElement(totpKeyName, totpListElement);
await this.updateTOTPElement(totpKeyName, totpListElement);
}
document.getElementById("loadingText").remove();
} catch (e: unknown) {
@ -76,8 +76,8 @@ export class TOTPViewPage extends Page {
);
};
await totpRefresher();
this.refresher = setInterval(() => {
void totpRefresher();
this.refresher = setInterval(async () => {
await totpRefresher();
}, 3000) as unknown as number;
}

View file

@ -40,8 +40,8 @@ export class UnsealPage extends Page {
}
makeRefresher(): void {
const id = setInterval(() => {
void (this as UnsealPage).doRefresh().then(() => {});
const id = setInterval(async () => {
await this.doRefresh();
return;
}, 1000);
this.refresher = id as unknown as number;
@ -83,7 +83,7 @@ export class UnsealPage extends Page {
],
}),
);
this.switchInputMode(this.mode);
await this.switchInputMode(this.mode);
await this.updateSealProgress(await getSealStatus());
this.makeRefresher();
}
@ -102,18 +102,18 @@ export class UnsealPage extends Page {
tag: "button",
class: ["uk-button", "uk-button-primary"],
text: buttonText,
onclick: () => {
this.switchInputMode(newMethod);
onclick: async () => {
await this.switchInputMode(newMethod);
},
}),
);
}
switchInputMode(method: string): void {
async switchInputMode(method: string): Promise<void> {
this.deinitWebcam();
this.unsealInputContent.querySelectorAll("*").forEach((n) => n.remove());
if (method == UnsealInputModes.FORM_INPUT) this.makeUnsealForm();
if (method == UnsealInputModes.QR_INPUT) void this.makeQRInput();
if (method == UnsealInputModes.QR_INPUT) await this.makeQRInput();
this.setButtons(method);
}
@ -143,9 +143,9 @@ export class UnsealPage extends Page {
],
}) as HTMLFormElement;
this.unsealInputContent.appendChild(this.unsealKeyForm);
this.unsealKeyForm.addEventListener("submit", (e: Event) => {
this.unsealKeyForm.addEventListener("submit", async (e: Event) => {
e.preventDefault();
void this.handleKeySubmit();
await this.handleKeySubmit();
});
}