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

@ -98,7 +98,7 @@ var bg_isBackground = true,
// init services // init services
window.bg_utilsService = bg_utilsService = new UtilsService(); window.bg_utilsService = bg_utilsService = new UtilsService();
window.bg_i18nService = bg_i18nService = new i18nService(bg_utilsService); window.bg_i18nService = bg_i18nService = new i18nService(bg_utilsService);
window.bg_constantsService = bg_constantsService = new ConstantsService(bg_i18nService); window.bg_constantsService = bg_constantsService = new ConstantsService(bg_i18nService, bg_utilsService);
window.bg_cryptoService = bg_cryptoService = new CryptoService(); window.bg_cryptoService = bg_cryptoService = new CryptoService();
window.bg_tokenService = bg_tokenService = new TokenService(); window.bg_tokenService = bg_tokenService = new TokenService();
window.bg_appIdService = bg_appIdService = new AppIdService(); window.bg_appIdService = bg_appIdService = new AppIdService();
@ -108,7 +108,7 @@ var bg_isBackground = true,
window.bg_settingsService = bg_settingsService = new SettingsService(bg_userService); window.bg_settingsService = bg_settingsService = new SettingsService(bg_userService);
window.bg_cipherService = bg_cipherService = new CipherService(bg_cryptoService, bg_userService, bg_settingsService, bg_apiService); window.bg_cipherService = bg_cipherService = new CipherService(bg_cryptoService, bg_userService, bg_settingsService, bg_apiService);
window.bg_folderService = bg_folderService = new FolderService(bg_cryptoService, bg_userService, bg_i18nService, bg_apiService); window.bg_folderService = bg_folderService = new FolderService(bg_cryptoService, bg_userService, bg_i18nService, bg_apiService);
window.bg_collectionService = bg_collectionService = new CollectionService(bg_cryptoService, bg_userService, bg_i18nService, bg_apiService); window.bg_collectionService = bg_collectionService = new CollectionService(bg_cryptoService, bg_userService);
window.bg_lockService = bg_lockService = new LockService(bg_cipherService, bg_folderService, bg_collectionService, bg_cryptoService, bg_utilsService, setIcon, refreshBadgeAndMenu); window.bg_lockService = bg_lockService = new LockService(bg_cipherService, bg_folderService, bg_collectionService, bg_cryptoService, bg_utilsService, setIcon, refreshBadgeAndMenu);
window.bg_syncService = bg_syncService = new SyncService(bg_userService, bg_apiService, bg_settingsService, bg_folderService, bg_cipherService, bg_cryptoService, bg_collectionService, logout); window.bg_syncService = bg_syncService = new SyncService(bg_userService, bg_apiService, bg_settingsService, bg_folderService, bg_cipherService, bg_cryptoService, bg_collectionService, logout);
window.bg_passwordGenerationService = bg_passwordGenerationService = new PasswordGenerationService(bg_cryptoService); window.bg_passwordGenerationService = bg_passwordGenerationService = new PasswordGenerationService(bg_cryptoService);

View File

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

View File

@ -1,3 +1,5 @@
import UtilsService from './utils.service';
export default class ConstantsService { export default class ConstantsService {
static readonly environmentUrlsKey: string = 'environmentUrls'; static readonly environmentUrlsKey: string = 'environmentUrls';
static readonly disableGaKey: string = 'disableGa'; static readonly disableGaKey: string = 'disableGa';
@ -55,9 +57,20 @@ export default class ConstantsService {
remember: 5, 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 = [ this.twoFactorProviderInfo = [
{ {
type: 0, type: 0,

View File

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