Skip to content

Commit 8458723

Browse files
author
DanielSteger
committed
[IT-2812] Refactor result selection store
1 parent 4eb70d8 commit 8458723

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

frontend/src/app/modules/result-selection/services/result-selection.store.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ export class ResultSelectionStore {
6666
selectedTimeFrameInterval: 'interval'
6767
};
6868

69-
constructor(private resultSelectionService: ResultSelectionService, route: ActivatedRoute, private router: Router) {
70-
this._resultSelectionCommand$ = new BehaviorSubject<ResultSelectionCommand>({});
69+
constructor(private resultSelectionService: ResultSelectionService, private route: ActivatedRoute, private router: Router) {
70+
this._resultSelectionCommand$ = new BehaviorSubject<ResultSelectionCommand>({caller: Caller.EventResult});
7171
this._remainingResultSelection$ = new BehaviorSubject<RemainingResultSelection>({});
72-
route.queryParams.subscribe((params: Params) => {
72+
73+
this.readQueryParams();
74+
}
75+
76+
readQueryParams(): void {
77+
this.route.queryParams.subscribe((params: Params) => {
7378
if (params) {
7479
params = this.renameParamKeys(this.oldToNewChartKeyMap, params);
7580
this.validQuery = this.checkQuery(params);
@@ -99,22 +104,9 @@ export class ResultSelectionStore {
99104
this._remainingResultSelection$.next(remainingResultSelection);
100105
}
101106
});
102-
103-
if (!this.validQuery) {
104-
let defaultFrom = new Date();
105-
let defaultTo = new Date();
106-
defaultFrom.setDate(defaultTo.getDate() - 3);
107-
108-
const resultSelectionCommand: ResultSelectionCommand = {
109-
from: defaultFrom,
110-
to: defaultTo,
111-
caller: Caller.EventResult
112-
};
113-
this._resultSelectionCommand$.next(resultSelectionCommand);
114-
}
115107
}
116108

117-
writeQueryParams(additionalParams?: Params) {
109+
writeQueryParams(additionalParams?: Params): void {
118110
this.router.navigate([], {
119111
queryParams: {
120112
from: this.resultSelectionCommand.from.toISOString(),

0 commit comments

Comments
 (0)