Skip to content

Commit

Permalink
chore: code tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismclarke committed Feb 27, 2025
1 parent a0d5c93 commit df425a3
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<picsa-configuration-summary style="margin-top: auto; padding: 4px" (click)="drawer.close()" />
<footer>
<a routerLink="/privacy">{{ 'Privacy Policy' | translate }}</a>
<div>v{{ version.number }}</div>
<div>v{{ version }}</div>
</footer>
</div>
</mat-drawer>
Expand Down
2 changes: 1 addition & 1 deletion apps/picsa-apps/extension-app/src/app/components/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class AppLayoutComponent {
)
);
public userType = computed(() => this.configurationService.userSettings().user_type);
public version = APP_VERSION;
public version = APP_VERSION.semver;

constructor(
private router: Router,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
import { arrayToHashmap } from '../../../../../../libs/utils';

const MW_DISTRICTS = [
{ id: 'balaka', label: 'Balaka' },
{ id: 'blantyre', label: 'Blantyre' },
{ id: 'chikwawa', label: 'Chikwawa' },
{ id: 'chiradzulu', label: 'Chiradzulu' },
{ id: 'chitipa', label: 'Chitipa' },
{ id: 'dedza', label: 'Dedza' },
{ id: 'dowa', label: 'Dowa' },
{ id: 'karonga', label: 'Karonga' },
{ id: 'kasungu', label: 'Kasungu' },
{ id: 'likoma', label: 'Likoma' },
{ id: 'lilongwe', label: 'Lilongwe' },
{ id: 'machinga', label: 'Machinga' },
{ id: 'mangochi', label: 'Mangochi' },
{ id: 'mchinji', label: 'Mchinji' },
{ id: 'mulanje', label: 'Mulanje' },
{ id: 'mwanza', label: 'Mwanza' },
{ id: 'mzimba', label: 'Mzimba' },
{ id: 'neno', label: 'Neno' },
{ id: 'nkhata_bay', label: 'Nkhata Bay' },
{ id: 'nkhotakota', label: 'Nkhotakota' },
{ id: 'nsanje', label: 'Nsanje' },
{ id: 'ntcheu', label: 'Ntcheu' },
{ id: 'ntchisi', label: 'Ntchisi' },
{ id: 'phalombe', label: 'Phalombe' },
{ id: 'rumphi', label: 'Rumphi' },
{ id: 'salima', label: 'Salima' },
{ id: 'thyolo', label: 'Thyolo' },
{ id: 'zomba', label: 'Zomba' },
];
import MW_DISTRICTS from '../../../../../../libs/data/geoLocation/mw/districts';

export const DISTRICTS = {
mw: arrayToHashmap(MW_DISTRICTS, 'label'),
Expand Down
6 changes: 3 additions & 3 deletions apps/picsa-tools/budget-tool/src/app/store/budget.store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { effect, Injectable, OnDestroy } from '@angular/core';
import { effect, Injectable } from '@angular/core';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { ConfigurationService } from '@picsa/configuration';
import { IDeploymentSettings, MONTH_DATA } from '@picsa/data';
Expand Down Expand Up @@ -305,10 +305,10 @@ export class BudgetStore {
// attempt to reload any hardcoded data present in the app
private async checkForUpdates() {
const version = await this.db.getDoc<IAppMeta>('_appMeta', 'VERSION');
const updateRequired = !version || version.value !== APP_VERSION.number;
const updateRequired = !version || version.value !== APP_VERSION.semver;
if (updateRequired) {
await this.setHardcodedData();
const update: IAppMeta = { _key: 'VERSION', value: APP_VERSION.number };
const update: IAppMeta = { _key: 'VERSION', value: APP_VERSION.semver };
this.db.setDoc('_appMeta', update);
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/picsa-tools/budget-tool/src/app/store/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const PERIOD_DATA_TEMPLATE: IBudgetPeriodData = {
// don't assert type so missing _key field picked up in create new budget from store
export const NEW_BUDGET_TEMPLATE: IBudget = {
apiVersion: BUDGET_API_VERSION,
_appVersion: APP_VERSION.number,
_appVersion: APP_VERSION.semver,
data: [],
meta: {
title: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ <h2 class="section-header">
<footer>
<picsa-configuration-summary></picsa-configuration-summary>
<a routerLink="/privacy" class="privacy-policy">{{ 'Privacy Policy' | translate }}</a>
<div class="version-info">v{{ version.number }}</div>
<div class="version-info">v{{ version }}</div>
</footer>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class ExtensionHomeComponent implements AfterViewInit, OnDestroy {
/** List of home page display links, filtered when running in production */
public picsaLinks = PAGE_LINKS;
public additionalLinks = ADDITIONAL_LINKS;
public version = APP_VERSION;
public version = APP_VERSION.semver;

@ViewChild('headerContent')
headerContent: ElementRef<HTMLElement>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class ResourcesToolService extends PicsaAsyncService {

// Use caching system to only populate once per app version launch in production
const assetsCacheVersion = this.getAssetResourcesVersion();
if (ENVIRONMENT.production && assetsCacheVersion === APP_VERSION.number) {
if (ENVIRONMENT.production && assetsCacheVersion === APP_VERSION.semver) {
return;
}
// Update DB with hardcoded entries
Expand Down Expand Up @@ -235,7 +235,7 @@ export class ResourcesToolService extends PicsaAsyncService {
}

private setAssetResourcesVersion() {
return localStorage.setItem(`picsa-resources-tool||assets-cache-version`, APP_VERSION.number);
return localStorage.setItem(`picsa-resources-tool||assets-cache-version`, APP_VERSION.semver);
}

public async shareLink(url: string) {
Expand Down
4 changes: 2 additions & 2 deletions libs/environments/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// tslint:disable no-var-requires
import packageJson from '../../../package.json';
// e.g. 1.0.1 - even though called a number is stored as a string

export const APP_VERSION = {
number: packageJson.version,
/** Semver code for current app version, e.g. 3.26.0 */
semver: packageJson.version,
date: '2025-02-15',
};
2 changes: 1 addition & 1 deletion libs/migrations/migrations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class PicsaMigrationService {
// HACK - As first install only tracked from v3.52, fallback to v3.0.0 if the user is not
// a first-time user but does not have accurate first install version
const previousUser = localStorage.getItem('picsa_user_settings');
firstInstallVersion = previousUser ? '3.0.0' : APP_VERSION.number;
firstInstallVersion = previousUser ? '3.0.0' : APP_VERSION.semver;
localStorage.setItem('picsa_app_first_install_version', firstInstallVersion);
return firstInstallVersion;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/src/services/core/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class AnalyticsService {
this.firebaseAnalytics.setScreenName({ screenName: location.pathname });
this.firebaseAnalytics.logEvent({
name: 'picsa_screen_view',
params: { screen_name: location.pathname, app_version: APP_VERSION },
params: { screen_name: location.pathname, app_version: APP_VERSION.semver },
});
}
});
Expand Down

0 comments on commit df425a3

Please sign in to comment.