Stop using "void " on async methods.
This commit is contained in:
parent
d658f468a5
commit
6edd037f8d
16
package.json
16
package.json
|
@ -1,34 +1,34 @@
|
||||||
{
|
{
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/eslint-parser": "^7.13.14",
|
"@babel/eslint-parser": "^7.14.2",
|
||||||
"@types/prismjs": "^1.16.5",
|
"@types/prismjs": "^1.16.5",
|
||||||
"@types/uikit": "^3.3.1",
|
"@types/uikit": "^3.3.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.22.1",
|
"@typescript-eslint/eslint-plugin": "^4.23.0",
|
||||||
"@typescript-eslint/parser": "^4.22.1",
|
"@typescript-eslint/parser": "^4.23.0",
|
||||||
"clipboard": "^2.0.8",
|
"clipboard": "^2.0.8",
|
||||||
"codejar": "^3.4.0",
|
"codejar": "^3.4.0",
|
||||||
"css-loader": "^5.2.4",
|
"css-loader": "^5.2.4",
|
||||||
"date-fns": "^2.21.3",
|
"date-fns": "^2.21.3",
|
||||||
"eslint": "^7.26.0",
|
"eslint": "^7.26.0",
|
||||||
"eslint-config-prettier": "^8.3.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-prettier": "^3.4.0",
|
||||||
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
|
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"git-revision-webpack-plugin": "^5.0.0",
|
"git-revision-webpack-plugin": "^5.0.0",
|
||||||
"html-webpack-plugin": "^5.3.1",
|
"html-webpack-plugin": "^5.3.1",
|
||||||
"i18next": "^20.2.2",
|
"i18next": "^20.2.4",
|
||||||
"mini-css-extract-plugin": "^1.6.0",
|
"mini-css-extract-plugin": "^1.6.0",
|
||||||
"node-sass": "^5.0.0",
|
"node-sass": "^6.0.0",
|
||||||
"prettier": "^2.3.0",
|
"prettier": "^2.3.0",
|
||||||
"prismjs": "^1.23.0",
|
"prismjs": "^1.23.0",
|
||||||
"qr-scanner": "^1.2.0",
|
"qr-scanner": "^1.2.0",
|
||||||
"raw-loader": "^4.0.2",
|
"raw-loader": "^4.0.2",
|
||||||
"sass-loader": "^11.0.1",
|
"sass-loader": "^11.1.1",
|
||||||
"ts-loader": "^9.1.2",
|
"ts-loader": "^9.1.2",
|
||||||
"typescript": "^4.2.4",
|
"typescript": "^4.2.4",
|
||||||
"uikit": "^3.6.21",
|
"uikit": "^3.6.21",
|
||||||
"webpack": "^5.36.2",
|
"webpack": "^5.37.0",
|
||||||
"webpack-cli": "^4.7.0",
|
"webpack-cli": "^4.7.0",
|
||||||
"webpack-dev-server": "^3.11.2",
|
"webpack-dev-server": "^3.11.2",
|
||||||
"z-pagerouter": "^1.0.1"
|
"z-pagerouter": "^1.0.1"
|
||||||
|
|
|
@ -62,7 +62,6 @@ export const allPages: pagesList = {
|
||||||
NEW_TRANSIT_ENGINE: new NewTransitEnginePage(),
|
NEW_TRANSIT_ENGINE: new NewTransitEnginePage(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// This should implement all o PageListType
|
// This should implement all o PageListType
|
||||||
class PageList {
|
class PageList {
|
||||||
constructor(pages: pagesList) {
|
constructor(pages: pagesList) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ export async function QRScanner(onScan: (code: string) => void): Promise<QRScann
|
||||||
if (lastSeenValue == value) return;
|
if (lastSeenValue == value) return;
|
||||||
onScan(value);
|
onScan(value);
|
||||||
});
|
});
|
||||||
void qrScanner.start();
|
await qrScanner.start();
|
||||||
|
|
||||||
QRInput.deinit = () => {
|
QRInput.deinit = () => {
|
||||||
try {
|
try {
|
||||||
|
|
37
src/main.ts
37
src/main.ts
|
@ -102,30 +102,27 @@ async function onLoad(): Promise<void> {
|
||||||
|
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
"DOMContentLoaded",
|
"DOMContentLoaded",
|
||||||
function () {
|
async () => {
|
||||||
console.log("Loading...");
|
console.log("Loading...");
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
console.log("Build Data:", BUILD_STRING);
|
console.log("Build Data:", BUILD_STRING);
|
||||||
void i18next
|
await i18next.init({
|
||||||
.init({
|
lng: pageState.language,
|
||||||
lng: pageState.language,
|
fallbackLng: "en",
|
||||||
fallbackLng: "en",
|
debug: true,
|
||||||
debug: true,
|
// @ts-ignore
|
||||||
// @ts-ignore
|
resources: Object.fromEntries(
|
||||||
resources: Object.fromEntries(
|
Object.entries(translations).map(([k, v]) => [k, { translation: v }]),
|
||||||
Object.entries(translations).map(([k, v]) => [k, { translation: v }]),
|
),
|
||||||
),
|
interpolation: {
|
||||||
interpolation: {
|
format: function (value: unknown, format, _): string {
|
||||||
format: function (value: unknown, format, _): string {
|
if (format === "until_date" && value instanceof Date)
|
||||||
if (format === "until_date" && value instanceof Date)
|
return formatDistance(new Date(), new Date(value), pageState.language);
|
||||||
return formatDistance(new Date(), new Date(value), pageState.language);
|
return value as string;
|
||||||
return value as string;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
.then(function (_) {
|
});
|
||||||
void onLoad();
|
await onLoad();
|
||||||
});
|
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
|
@ -30,16 +30,15 @@ export class KeyValueDeletePage extends Page {
|
||||||
tag: "button",
|
tag: "button",
|
||||||
class: ["uk-button", "uk-button-danger"],
|
class: ["uk-button", "uk-button-danger"],
|
||||||
text: i18next.t("kv_delete_btn"),
|
text: i18next.t("kv_delete_btn"),
|
||||||
onclick: () => {
|
onclick: async () => {
|
||||||
void deleteSecret(
|
await deleteSecret(
|
||||||
this.state.currentBaseMount,
|
this.state.currentBaseMount,
|
||||||
this.state.currentMountType,
|
this.state.currentMountType,
|
||||||
this.state.currentSecretPath,
|
this.state.currentSecretPath,
|
||||||
this.state.currentSecret,
|
this.state.currentSecret,
|
||||||
this.state.currentSecretVersion,
|
this.state.currentSecretVersion,
|
||||||
).then(() => {
|
);
|
||||||
void this.goBack();
|
await this.goBack();
|
||||||
});
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
|
@ -49,14 +49,14 @@ export class MePage extends Page {
|
||||||
children: makeElement({
|
children: makeElement({
|
||||||
tag: "a",
|
tag: "a",
|
||||||
text: i18next.t("renew_lease_btn"),
|
text: i18next.t("renew_lease_btn"),
|
||||||
onclick: () => {
|
onclick: async () => {
|
||||||
renewSelf()
|
try {
|
||||||
.then(() => {
|
await renewSelf();
|
||||||
void this.router.changePage("HOME");
|
await this.router.changePage("HOME");
|
||||||
})
|
} catch (e: unknown) {
|
||||||
.catch((e: Error) => {
|
const error = e as Error;
|
||||||
setErrorText(e.message);
|
setErrorText(error.message);
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -55,7 +55,7 @@ export class TOTPViewPage extends Page {
|
||||||
const totpListElement = this.makeTOTPListElement(totpKeyName);
|
const totpListElement = this.makeTOTPListElement(totpKeyName);
|
||||||
totpList.appendChild(totpListElement);
|
totpList.appendChild(totpListElement);
|
||||||
this.totpListElements[totpKeyName] = totpListElement;
|
this.totpListElements[totpKeyName] = totpListElement;
|
||||||
void this.updateTOTPElement(totpKeyName, totpListElement);
|
await this.updateTOTPElement(totpKeyName, totpListElement);
|
||||||
}
|
}
|
||||||
document.getElementById("loadingText").remove();
|
document.getElementById("loadingText").remove();
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
|
@ -76,8 +76,8 @@ export class TOTPViewPage extends Page {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
await totpRefresher();
|
await totpRefresher();
|
||||||
this.refresher = setInterval(() => {
|
this.refresher = setInterval(async () => {
|
||||||
void totpRefresher();
|
await totpRefresher();
|
||||||
}, 3000) as unknown as number;
|
}, 3000) as unknown as number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ export class UnsealPage extends Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
makeRefresher(): void {
|
makeRefresher(): void {
|
||||||
const id = setInterval(() => {
|
const id = setInterval(async () => {
|
||||||
void (this as UnsealPage).doRefresh().then(() => {});
|
await this.doRefresh();
|
||||||
return;
|
return;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
this.refresher = id as unknown as number;
|
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());
|
await this.updateSealProgress(await getSealStatus());
|
||||||
this.makeRefresher();
|
this.makeRefresher();
|
||||||
}
|
}
|
||||||
|
@ -102,18 +102,18 @@ export class UnsealPage extends Page {
|
||||||
tag: "button",
|
tag: "button",
|
||||||
class: ["uk-button", "uk-button-primary"],
|
class: ["uk-button", "uk-button-primary"],
|
||||||
text: buttonText,
|
text: buttonText,
|
||||||
onclick: () => {
|
onclick: async () => {
|
||||||
this.switchInputMode(newMethod);
|
await this.switchInputMode(newMethod);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
switchInputMode(method: string): void {
|
async switchInputMode(method: string): Promise<void> {
|
||||||
this.deinitWebcam();
|
this.deinitWebcam();
|
||||||
this.unsealInputContent.querySelectorAll("*").forEach((n) => n.remove());
|
this.unsealInputContent.querySelectorAll("*").forEach((n) => n.remove());
|
||||||
if (method == UnsealInputModes.FORM_INPUT) this.makeUnsealForm();
|
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);
|
this.setButtons(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,9 +143,9 @@ export class UnsealPage extends Page {
|
||||||
],
|
],
|
||||||
}) as HTMLFormElement;
|
}) as HTMLFormElement;
|
||||||
this.unsealInputContent.appendChild(this.unsealKeyForm);
|
this.unsealInputContent.appendChild(this.unsealKeyForm);
|
||||||
this.unsealKeyForm.addEventListener("submit", (e: Event) => {
|
this.unsealKeyForm.addEventListener("submit", async (e: Event) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
void this.handleKeySubmit();
|
await this.handleKeySubmit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue