diff --git a/src/lib/services/toaster.service.ts b/src/lib/services/toaster.service.ts index 75d44fb..55b2bc5 100644 --- a/src/lib/services/toaster.service.ts +++ b/src/lib/services/toaster.service.ts @@ -7,6 +7,7 @@ import { ActiveToast, ToastrService } from 'ngx-toastr'; import { IndividualConfig } from 'ngx-toastr/toastr/toastr-config'; import { filter, tap } from 'rxjs/operators'; import { ErrorMessageService } from './error-message.service'; +import { isIqserDevMode } from './iqser-user-preference.service'; const enum NotificationType { SUCCESS = 'SUCCESS', @@ -36,10 +37,19 @@ export interface ErrorToasterOptions extends ToasterOptions { readonly error?: HttpErrorResponse; } +const defaultDevToastOptions: Partial = { + timeOut: 10000, + easing: 'ease-in-out', + easeTime: 500, + useRaw: true, +}; + @Injectable({ providedIn: 'root', }) export class Toaster { + readonly #isIqserDevMode = isIqserDevMode(); + constructor( router: Router, private readonly _toastr: ToastrService, @@ -74,6 +84,14 @@ export class Toaster { return this.#showToastNotification(message, NotificationType.INFO, options); } + devInfo(message: string): ActiveToast | undefined { + if (!this.#isIqserDevMode) { + return; + } + + return this.info(message, defaultDevToastOptions); + } + success(message: string, options?: Partial): ActiveToast { return this.#showToastNotification(message, NotificationType.SUCCESS, options); }