fix null refs when no background (ff private mode)

This commit is contained in:
Kyle Spearrin 2018-03-27 12:51:07 -04:00
parent 6b42c1a16d
commit 72cb2772a6
3 changed files with 18 additions and 10 deletions

View File

@ -33,13 +33,16 @@ import { U2f } from '../../scripts/u2f';
window.U2f = U2f;
import { Analytics } from '../../../jslib/src/misc/analytics';
new Analytics(window, () => BrowserApi.gaFilter(), null, null, null, () => {
const bgPage = BrowserApi.getBackgroundPage();
if (!bgPage || !bgPage.bitwardenMain) {
throw 'Cannot resolve background page main.';
}
return bgPage.bitwardenMain;
});
if (BrowserApi.getBackgroundPage()) {
new Analytics(window, () => BrowserApi.gaFilter(), null, null, null, () => {
const bgPage = BrowserApi.getBackgroundPage();
if (!bgPage || !bgPage.bitwardenMain) {
throw 'Cannot resolve background page main.';
}
return bgPage.bitwardenMain;
});
}
// Model imports
import { Attachment } from '../../../jslib/src/models/domain/attachment';

View File

@ -13,7 +13,10 @@ const authService = new AuthService(backgroundServices.cryptoService(), backgrou
backgroundServices.userService(), backgroundServices.tokenService(), backgroundServices.appIdService(),
backgroundServices.i18n2Service(), backgroundServices.platformUtilsService(),
backgroundServices.constantsService(), messagingService);
authService.init();
if (backgroundServices.i18n2Service()) {
authService.init();
}
export default angular
.module('bit.services', ['toastr'])

View File

@ -9,8 +9,10 @@ export class StateService {
}
async init() {
const iconsDisabled = await this.storageService.get<boolean>(this.constantsService.disableFaviconKey);
this.saveState('faviconEnabled', !iconsDisabled);
if (this.storageService != null) {
const iconsDisabled = await this.storageService.get<boolean>(this.constantsService.disableFaviconKey);
this.saveState('faviconEnabled', !iconsDisabled);
}
}
saveState(key: string, data: any) {