Skip to content

Commit

Permalink
more fun with types
Browse files Browse the repository at this point in the history
  • Loading branch information
latin-panda committed Aug 22, 2024
1 parent 1000103 commit fdcae6a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
6 changes: 3 additions & 3 deletions webapp/src/ts/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class AppComponent implements OnInit, AfterViewInit {
unreadCount = {};
hasOldNav = false;
initialisationComplete = false;
trainingCardFormId = false;
trainingCardFormId = '';

constructor (
private dbSyncService:DBSyncService,
Expand Down Expand Up @@ -446,7 +446,7 @@ export class AppComponent implements OnInit, AfterViewInit {
]) => {
this.replicationStatus = replicationStatus;
this.androidAppVersion = androidAppVersion;
this.currentTab = currentTab;
this.currentTab = currentTab || '';

this.selectMode = selectMode;
});
Expand All @@ -462,7 +462,7 @@ export class AppComponent implements OnInit, AfterViewInit {
]) => {
this.showPrivacyPolicy = showPrivacyPolicy;
this.privacyPolicyAccepted = privacyPolicyAccepted;
this.trainingCardFormId = trainingCardFormId;
this.trainingCardFormId = trainingCardFormId || '';
this.displayTrainingCards();
});
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/ts/effects/global.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class GlobalEffects {
.toPromise();
}

private navigate(nextUrl: string, cancelCallback: () => void) {
private navigate(nextUrl: string, cancelCallback: (() => void) | null) {
try {
if (nextUrl) {
return this.router.navigateByUrl(nextUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class ContactsMoreMenuComponent implements OnInit, OnDestroy {
private hasDeletePermission = false;
private isOnlineOnly = false;
private loadingContent = true;
private snapshotData: Data | undefined;
private snapshotData: Data | null = null;
private userSettings;

selectedContactDoc;
Expand Down
1 change: 1 addition & 0 deletions webapp/src/ts/modules/messages/messages.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="filters tab-bar">
<div class="inner">
<a class="mm-icon"><span class="fa fa-fw fa-bars"></span></a>
<mm-navigation></mm-navigation>
<mm-messages-more-menu (exportMessages)="exportMessages()" [conversations]="conversations"></mm-messages-more-menu>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ReportsMoreMenuComponent implements OnInit, OnDestroy {
private hasUpdatePermission = false;
private selectMode = false;
private loadingContent?: boolean;
private snapshotData: Data | undefined;
private snapshotData: Data | null = null;
private isOnlineOnly?: boolean;
private dialogRef: MatDialogRef<any> | undefined;
private bottomSheetRef: MatBottomSheetRef<any> | undefined;
Expand Down
27 changes: 14 additions & 13 deletions webapp/src/ts/reducers/global.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createReducer, on } from '@ngrx/store';
import { Data } from '@angular/router';

import { Actions } from '@mm-actions/global';
import { SidebarMenu } from '@mm-components/sidebar-menu/sidebar-menu.component';
Expand All @@ -7,25 +8,25 @@ import { EnketoStatus } from '@mm-components/enketo/enketo.component';
import { VersionNumber } from '@mm-services/browser-detector.service';

export interface GlobalState {
androidAppVersion: VersionNumber | undefined;
androidAppVersion: VersionNumber | null;
navigation: {
cancelCallback: null|(() => void);
preventNavigation: null|boolean;
cancelTranslationKey: null|string;
recordTelemetry: null|string;
cancelCallback: (() => void) | null;
preventNavigation: null | boolean;
cancelTranslationKey: null | string;
recordTelemetry: null | string;
};
currentTab: null|string;
snapshotData: null|Record<string, any>;
currentTab: null | string;
snapshotData: Data | null;
enketoStatus: EnketoStatus;
facilities: Record<string, any>[];
filters: Record<string, any>; // Selected criteria to filter data.
sidebarFilter: {
isOpen?: boolean;
filterCount?: number;
filterCount?: Record<string, number>;
defaultFilters?: Record<string, any>;
};
sidebarMenu: SidebarMenu;
forms: null|Record<string, any>[];
forms: null | Record<string, any>[];
lastChangedDoc: boolean;
loadingContent: boolean;
processingReportVerification: boolean;
Expand All @@ -34,16 +35,16 @@ export interface GlobalState {
privacyPolicyAccepted: boolean;
showContent: boolean;
showPrivacyPolicy: boolean;
title: null|string;
title: null | string;
unreadCount: Record<string, any>;
snackbarContent: Snackbar;
translationsLoaded: boolean;
userFacilityId: null|string[];
trainingCardFormId: null|string;
userFacilityId: null | string[];
trainingCardFormId: null | string;
}

const initialState: GlobalState = {
androidAppVersion: undefined,
androidAppVersion: null,
navigation: {
cancelCallback: null,
preventNavigation: null,
Expand Down
5 changes: 3 additions & 2 deletions webapp/src/ts/services/browser-detector.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Injectable } from '@angular/core';
import * as Bowser from 'bowser';
import { Store } from '@ngrx/store';

import { Selectors } from '@mm-selectors/index';

const OUTDATED_BROWSER_VERSION_MIN = '74';
const OUTDATED_BROWSER_VERSION_MAX = '90';

type VersionSuffix = `` | `-${string}`;
export type VersionNumber = 'SNAPSHOT' | `v${string}.${string}.${string}${VersionSuffix}`;

Expand All @@ -13,7 +14,7 @@ export type VersionNumber = 'SNAPSHOT' | `v${string}.${string}.${string}${Versio
})
export class BrowserDetectorService {
private _parser?: Bowser.Parser.Parser;
private androidAppVersion: VersionNumber | undefined;
private androidAppVersion: VersionNumber | null = null;

public constructor(private store: Store) {
this.store.select(Selectors.getAndroidAppVersion).subscribe(androidAppVersion => {
Expand Down

0 comments on commit fdcae6a

Please sign in to comment.