1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 03:33:54 +00:00

delay i18n load on edge for constants

This commit is contained in:
Kyle Spearrin
2017-12-04 09:06:32 -05:00
parent 873cb6aba6
commit 61fb18ec4b
4 changed files with 19 additions and 9 deletions

View File

@@ -3,7 +3,6 @@ import { Collection } from '../models/domain/collection';
import { CollectionData } from '../models/data/collectionData';
import ApiService from './api.service';
import CryptoService from './crypto.service';
import UserService from './user.service';
import UtilsService from './utils.service';
@@ -15,8 +14,7 @@ const Keys = {
export default class CollectionService {
decryptedCollectionCache: any[];
constructor(private cryptoService: CryptoService, private userService: UserService,
private apiService: ApiService) {
constructor(private cryptoService: CryptoService, private userService: UserService) {
}
clearCache(): void {

View File

@@ -1,3 +1,5 @@
import UtilsService from './utils.service';
export default class ConstantsService {
static readonly environmentUrlsKey: string = 'environmentUrls';
static readonly disableGaKey: string = 'disableGa';
@@ -55,9 +57,20 @@ export default class ConstantsService {
remember: 5,
};
readonly twoFactorProviderInfo: any[];
twoFactorProviderInfo: any[];
constructor(i18nService: any) {
constructor(i18nService: any, utilsService: UtilsService) {
if (utilsService.isEdge()) {
// delay for i18n fetch
setTimeout(() => {
this.bootstrap(i18nService);
}, 1000);
} else {
this.bootstrap(i18nService);
}
}
private bootstrap(i18nService: any) {
this.twoFactorProviderInfo = [
{
type: 0,

View File

@@ -1,6 +1,5 @@
export default function i18nService(utilsService) {
this.__edgeMessages = {};
const self = this;
if (utilsService.isEdge()) {
fetch('../_locales/en/messages.json').then((file) => {
@@ -8,7 +7,7 @@ export default function i18nService(utilsService) {
}).then((locales) => {
for (const prop in locales) {
if (locales.hasOwnProperty(prop)) {
self.__edgeMessages[prop] = chrome.i18n.getMessage(prop);
this.__edgeMessages[prop] = chrome.i18n.getMessage(prop);
}
}
});