Skip to content

Commit

Permalink
Another fix (it works this time)
Browse files Browse the repository at this point in the history
  • Loading branch information
edlu77 committed Apr 22, 2024
1 parent d489d12 commit c027b69
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions apps/a2agc/src/app/core/state/data/data.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { State } from '@ngxs/store';
import { catchError, map, Observable, of } from 'rxjs';

import { DATA_CONFIG } from '../../../../configs/config';
import { DatasetLoaderService } from '../../services/dataset-loader/dataset-loader.service';
import { DatasetLoaderService, RawData } from '../../services/dataset-loader/dataset-loader.service';
import { DatasetVariablesState } from './dataset-variables.state';
import { DatasetsState } from './datasets.state';

Expand Down Expand Up @@ -56,9 +56,9 @@ export class DataState extends NgxsImmutableDataRepository<DataStateModel> {
* @returns true if the data config datasets path is valid, otherwise returns false
*/
isPrivate(): Observable<boolean> {
const response = this.http.get<string>(DATA_CONFIG.datasetsPath);
const response = this.http.get<RawData>(DATA_CONFIG.datasetsPath);
return response.pipe(
map((result) => result.toString() === '{}'),
map((result) => this.isNotEmpty(result)),
catchError(this.handleError)
);
}
Expand All @@ -70,4 +70,13 @@ export class DataState extends NgxsImmutableDataRepository<DataStateModel> {
private handleError(): Observable<boolean> {
return of(false);
}

/**
* Checks if object is not empty
* @param input object
* @returns true if not empty
*/
private isNotEmpty(input: RawData): boolean {
return Object.keys(input).length != 0;
}
}

0 comments on commit c027b69

Please sign in to comment.