Skip to content

Commit

Permalink
fixes issues when no type config is set
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Peter committed Sep 2, 2024
1 parent 44f8593 commit d8b4baa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnDestroy } from '@angular/core';
import { AlertService, HeaderService } from '@c8y/ngx-components';
import { has } from 'lodash';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BehaviorSubject, Subscription } from 'rxjs';
import {
Expand Down Expand Up @@ -132,7 +133,7 @@ export class ReminderDrawerComponent implements OnDestroy {
}

private handleConfigChange(config: ReminderConfig): void {
if (this.reminderTypeFilter !== config.filter?.reminderType) {
if (has(config.filter, 'remidnerType') && this.reminderTypeFilter !== config.filter?.reminderType) {
this.reminderTypeFilter = config.filter.reminderType;
this.filterByType();
}
Expand Down
6 changes: 4 additions & 2 deletions src/app/reminder-plugin/services/reminder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ export class ReminderService {
const config = this.config$.getValue();

// populate filters
filters[REMINDER_TYPE_FRAGMENT] = config.filter[REMINDER_TYPE_FRAGMENT];
if (has(config.filter, 'remidnerType'))
filters[REMINDER_TYPE_FRAGMENT] = config.filter[REMINDER_TYPE_FRAGMENT];

return Object.keys(filters).length > 0 ? filters : null;
}
Expand Down Expand Up @@ -387,7 +388,8 @@ export class ReminderService {
const filter = this.buildTypeFilter();
this.setConfig('filter', filter);

if (filter[REMINDER_TYPE_FRAGMENT] === '') return groups;
const config = this.config$.getValue();
if (!has(config.filter, 'remidnerType') || filter[REMINDER_TYPE_FRAGMENT] === '') return groups;

const keys = Object.keys(filter);
if (!keys.length) return groups;
Expand Down

0 comments on commit d8b4baa

Please sign in to comment.