Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/UI i18n #438

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions src/modules/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
import { BigNumber } from "bignumber.js";
import { cloneDeep, merge, omit } from "lodash-es";
import log from "loglevel";
import { useI18n } from "vue-i18n";
// import { useI18n } from "vue-i18n";
import { Action, getModule, Module, Mutation, VuexModule } from "vuex-module-decorators";

import OpenLoginFactory from "@/auth/OpenLogin";
import TorusController, { DEFAULT_CONFIG, DEFAULT_STATE, EPHERMAL_KEY } from "@/controllers/TorusController";
import { i18n } from "@/plugins/i18nPlugin";
import installStorePlugin from "@/plugins/persistPlugin";
import { WALLET_SUPPORTED_NETWORKS } from "@/utils/const";
import { CONTROLLER_MODULE_KEY, LOCAL_STORAGE_KEY, TorusControllerState } from "@/utils/enums";
Expand Down Expand Up @@ -223,7 +224,7 @@
return this.userTokens
.reduce((acc: SolanaToken[], current: SolanaToken) => {
const data = this.torusState.TokenInfoState.tokenInfoMap[current.mintAddress];
if (data?.address === "So11111111111111111111111111111111111111112") (data as any).symbol = "WSOL";

Check warning on line 227 in src/modules/controllers.ts

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-latest)

Unexpected any. Specify a different type
if (current.balance?.decimals !== 0 && current.balance?.uiAmount && data) {
return [
...acc,
Expand Down Expand Up @@ -288,15 +289,15 @@

@Action
public async setCrashReport(status: boolean): Promise<void> {
const { t } = useI18n({ useScope: "global" });
const { rt } = i18n.global;
const isSet = await this.torus.setCrashReport(status);
if (isSet) {
if (storageAvailable("localStorage")) {
localStorage.setItem("torus-enable-crash-reporter", String(status));
}
this.handleSuccess(t(NAVBAR_MESSAGES.success.CRASH_REPORT_SUCCESS));
this.handleSuccess(rt(NAVBAR_MESSAGES.success.CRASH_REPORT_SUCCESS));
} else {
this.handleError(t(NAVBAR_MESSAGES.error.CRASH_REPORT_FAILED));
this.handleError(rt(NAVBAR_MESSAGES.error.CRASH_REPORT_FAILED));
}
}

Expand Down Expand Up @@ -340,23 +341,25 @@

@Action
public async addContact(contactPayload: ContactPayload): Promise<void> {
const { t } = useI18n({ useScope: "global" });
const { rt } = i18n.global;
// const { t } = useI18n({ useScope: "global" });
const isDeleted = await this.torus.addContact(contactPayload);
if (isDeleted) {
this.handleSuccess(t(NAVBAR_MESSAGES.success.ADD_CONTACT_SUCCESS));
this.handleSuccess(rt(NAVBAR_MESSAGES.success.ADD_CONTACT_SUCCESS));
} else {
this.handleError(t(NAVBAR_MESSAGES.error.ADD_CONTACT_FAILED));
this.handleError(rt(NAVBAR_MESSAGES.error.ADD_CONTACT_FAILED));
}
}

@Action
public async deleteContact(contactId: number): Promise<void> {
const { t } = useI18n({ useScope: "global" });
const { rt } = i18n.global;
// const { t } = useI18n({ useScope: "global" });
const isDeleted = await this.torus.deleteContact(contactId);
if (isDeleted) {
this.handleSuccess(t(NAVBAR_MESSAGES.success.DELETE_CONTACT_SUCCESS));
this.handleSuccess(rt(NAVBAR_MESSAGES.success.DELETE_CONTACT_SUCCESS));
} else {
this.handleError(t(NAVBAR_MESSAGES.error.DELETE_CONTACT_FAILED));
this.handleError(rt(NAVBAR_MESSAGES.error.DELETE_CONTACT_FAILED));
}
}

Expand All @@ -381,23 +384,23 @@

@Action
public async setCurrency(currency: string): Promise<void> {
const { t } = useI18n({ useScope: "global" });
const { rt } = i18n.global;
const isSet = await this.torus.setDefaultCurrency(currency);
if (isSet) {
this.handleSuccess(t(NAVBAR_MESSAGES.success.SET_CURRENCY_SUCCESS));
this.handleSuccess(rt(NAVBAR_MESSAGES.success.SET_CURRENCY_SUCCESS));
} else {
this.handleError(t(NAVBAR_MESSAGES.error.SET_CURRENCY_FAILED));
this.handleError(rt(NAVBAR_MESSAGES.error.SET_CURRENCY_FAILED));
}
}

@Action
public async setLocale(locale: string): Promise<void> {
const { t } = useI18n({ useScope: "global" });
const { rt } = i18n.global;
const isSet = await this.torus.setLocale(locale);
if (isSet) {
this.handleSuccess(t(NAVBAR_MESSAGES.success.SET_LOCALE_SUCCESS));
this.handleSuccess(rt(NAVBAR_MESSAGES.success.SET_LOCALE_SUCCESS));
} else {
this.handleError(t(NAVBAR_MESSAGES.error.SET_LOCALE_FAILED));
this.handleError(rt(NAVBAR_MESSAGES.error.SET_LOCALE_FAILED));
}
}

Expand Down Expand Up @@ -504,7 +507,7 @@
const openLoginInstance = await OpenLoginFactory.getInstance();
// if (openLoginInstance.state.support3PC) {

openLoginInstance.logout();
await openLoginInstance.logout();
} catch (error) {
log.warn(error, "unable to logout with openlogin");
}
Expand Down Expand Up @@ -625,7 +628,7 @@
}

@Action
async handleRedirectFlow({ method, params, resolveRoute }: { method: string; params: { [keyof: string]: any }; resolveRoute: string }) {

Check warning on line 631 in src/modules/controllers.ts

View workflow job for this annotation

GitHub Actions / build (20.x, ubuntu-latest)

Unexpected any. Specify a different type
let res;
switch (method) {
case "topup":
Expand Down
Loading