Skip to content
This repository has been archived by the owner on Jul 23, 2022. It is now read-only.

Commit

Permalink
detect installations and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Feb 16, 2018
1 parent 17494cc commit 35f8303
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/app/services/services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,32 @@ environmentService.setUrlsFromStorage().then(() => {
return syncService.fullSync(true);
});

function initFactory(i18n: I18nService, platformUtils: DesktopPlatformUtilsService): Function {
function initFactory(): Function {
return async () => {
await i18n.init();
await i18nService.init();
await authService.init();
const htmlEl = window.document.documentElement;
htmlEl.classList.add('os_' + platformUtils.getDeviceString());
htmlEl.classList.add('locale_' + i18n.translationLocale);
htmlEl.classList.add('os_' + platformUtilsService.getDeviceString());
htmlEl.classList.add('locale_' + i18nService.translationLocale);
stateService.save(ConstantsService.disableFaviconKey,
await storageService.get<boolean>(ConstantsService.disableFaviconKey));

let installAction = null;
const installedVersion = await storageService.get<string>(ConstantsService.installedVersionKey);
const currentVersion = platformUtilsService.getApplicationVersion();
if (installedVersion == null) {
installAction = 'install';
} else if (installedVersion !== currentVersion) {
installAction = 'update';
}

if (installAction != null) {
await storageService.save(ConstantsService.installedVersionKey, currentVersion);
analytics.ga('send', {
hitType: 'event',
eventAction: installAction,
});
}
};
}

Expand Down Expand Up @@ -153,10 +170,7 @@ function initFactory(i18n: I18nService, platformUtils: DesktopPlatformUtilsServi
{
provide: APP_INITIALIZER,
useFactory: initFactory,
deps: [
I18nServiceAbstraction,
PlatformUtilsServiceAbstraction,
],
deps: [],
multi: true,
},
],
Expand Down

0 comments on commit 35f8303

Please sign in to comment.