Skip to content

Commit

Permalink
Merge pull request #440 from torusresearch/fix/rt-to-t
Browse files Browse the repository at this point in the history
fix: rt to t
  • Loading branch information
guru-web3 authored Sep 22, 2023
2 parents c858c22 + 5df71a9 commit ba0a504
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
31 changes: 16 additions & 15 deletions src/modules/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ExtendedAddressPreferences, LoadingState, NFTInfo, SolanaToken, SolanaT
import { BigNumber } from "bignumber.js";
import { cloneDeep, merge, omit } from "lodash-es";
import log from "loglevel";
import { VueI18nTranslation } from "vue-i18n";
// import { useI18n } from "vue-i18n";
import { Action, getModule, Module, Mutation, VuexModule } from "vuex-module-decorators";

Expand Down Expand Up @@ -289,15 +290,15 @@ class ControllerModule extends VuexModule {

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

Expand Down Expand Up @@ -341,25 +342,25 @@ class ControllerModule extends VuexModule {

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

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

Expand All @@ -384,23 +385,23 @@ class ControllerModule extends VuexModule {

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

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

Expand Down
2 changes: 1 addition & 1 deletion tests/controller/controllerModule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ describe("Controller Module", () => {
assert.deepStrictEqual(theme, "light");
});

it.skip("setCrashReport", async () => {
it("setCrashReport", async () => {
await controllerModule.setCrashReport(true);
const { crashReport } = controllerModule.torusState.PreferencesControllerState.identities[sKeyPair[0].publicKey.toBase58()];
assert.deepStrictEqual(crashReport, true);
Expand Down

0 comments on commit ba0a504

Please sign in to comment.