From d3949c17e1ba5c901151c965b98f2e5d3ab1a6fc Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Wed, 14 Mar 2018 13:20:05 +0100 Subject: [PATCH] Fixed notifications --- .../notification/notification.component.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/app/shared/notifications/notification/notification.component.ts b/src/app/shared/notifications/notification/notification.component.ts index 04fadf4941..619c9b513a 100644 --- a/src/app/shared/notifications/notification/notification.component.ts +++ b/src/app/shared/notifications/notification/notification.component.ts @@ -128,11 +128,18 @@ export class NotificationComponent implements OnInit, OnDestroy { if (item instanceof TemplateRef) { this[key] = item; } else if (key === 'title' || key === 'content') { - this[key] = isNotEmpty(item) ? - typeof item === 'string' ? - Observable.of(item) - : typeof item === 'object' && isNotEmpty(item.payload) ? Observable.of(item.payload) : null - : null; + let value = null; + if (typeof item === 'string') { + value = Observable.of(item); + } else if (item instanceof Observable) { + value = item; + } else if (typeof item === 'object' && isNotEmpty(item.value)) { + // when notifications state is transferred from SSR to CSR, + // Observables Object loses the instance type and become simply object, + // so converts it again to Observable + value = Observable.of(item.value); + } + this[key] = value } else { this[key] = this.domSanitizer.bypassSecurityTrustHtml(item); }