From 6afda2c190548980524579500c2cb0b6af44f90e Mon Sep 17 00:00:00 2001 From: Slava Fomin II Date: Tue, 23 Nov 2021 10:18:19 +0300 Subject: [PATCH] feat: support grammY lazy sessions (#10) * Added support for grammY lazy sessions Signed-off-by: Slava Fomin II * style: adapt to linter style Co-authored-by: EdJoPaTo --- package.json | 3 ++- source/i18n.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8cf60845..3ce8b8c6 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "url": "https://edjopato.de" }, "contributors": [ - "Vitaly Domnikov " + "Vitaly Domnikov ", + "Slava Fomin II " ], "scripts": { "build": "del-cli dist && tsc", diff --git a/source/i18n.ts b/source/i18n.ts index d88ef0d9..ed1edaea 100644 --- a/source/i18n.ts +++ b/source/i18n.ts @@ -122,7 +122,7 @@ export class I18n { // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types return async (ctx, next) => { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const session: Session | undefined = this.config.useSession && (ctx as any)[this.config.sessionName]; + const session: Session | undefined = await (this.config.useSession && (ctx as any)[this.config.sessionName]); const languageCode = session?.__language_code ?? ctx.from?.language_code ?? this.config.defaultLanguage; // @ts-expect-error writing to readonly property