diff --git a/src/lib/IONOS/components/notifications/NotificationBanner.svelte b/src/lib/IONOS/components/notifications/NotificationBanner.svelte
index 4f8fd3dee71..d6ad4da8d91 100644
--- a/src/lib/IONOS/components/notifications/NotificationBanner.svelte
+++ b/src/lib/IONOS/components/notifications/NotificationBanner.svelte
@@ -1,17 +1,14 @@
diff --git a/src/lib/IONOS/components/notifications/NotificationManager.svelte b/src/lib/IONOS/components/notifications/NotificationManager.svelte
index 3f1f2a7c37d..2d79c272dc1 100644
--- a/src/lib/IONOS/components/notifications/NotificationManager.svelte
+++ b/src/lib/IONOS/components/notifications/NotificationManager.svelte
@@ -17,13 +17,12 @@
isIOSDevice,
isSafari
} from '$lib/IONOS/services/pwa';
- import { deferredPrompt, isPWAInstallable, setupGlobalPWAListener, clearDeferredPrompt } from '$lib/IONOS/stores/pwa-prompt';
+ import { deferredPrompt, isPWAInstallable, clearDeferredPrompt } from '$lib/IONOS/stores/pwa-prompt';
const i18n = getContext>('i18n');
const DAYS = 24 * 60 * 60 * 1000;
let showPWADialog = false;
- let cleanupPWAListeners: (() => void) | null = null;
const unsubscribeChats = chats.subscribe(async (chats: Chat[]|null) => {
const userSettings = await getUserSettings(localStorage.token);
@@ -67,13 +66,13 @@
};
const dismissHandler = (event: CustomEvent) => {
- const notification = event.detail.notification;
+ const notification: SubscribableNotification = event.detail.notification as SubscribableNotification;
if (get(notification).type === NotificationType.PWA_INSTALL) {
dismissPWAPrompt();
}
- removeNotification(notification);
+ removeNotification("pwa");
};
onDestroy(() => {
@@ -92,9 +91,7 @@
$: if (!$isPWAInstallable && !$deferredPrompt) {
showPWADialog = false;
- notifications.update((currentNotifications: Notification[]) =>
- currentNotifications.filter(n => n.type !== NotificationType.PWA_INSTALL)
- );
+ removeNotification("pwa");
}
const addPWANotification = () => {
diff --git a/src/lib/IONOS/components/notifications/PWAInstallDialog.svelte b/src/lib/IONOS/components/notifications/PWAInstallDialog.svelte
index bd9dc936053..71f89717ccd 100644
--- a/src/lib/IONOS/components/notifications/PWAInstallDialog.svelte
+++ b/src/lib/IONOS/components/notifications/PWAInstallDialog.svelte
@@ -5,7 +5,7 @@
import Touch from '$lib/IONOS/components/icons/Touch.svelte';
import Share from '$lib/IONOS/components/icons/Share.svelte';
import Button from '$lib/IONOS/components/common/Button.svelte';
- import { ButtonType } from '$lib/IONOS/components/common/buttons.ts';
+ import { ButtonType } from '$lib/IONOS/components/common/buttons';
import { getContext } from 'svelte';
import { createEventDispatcher } from 'svelte';
import { isIOSDevice, isSafari } from '$lib/IONOS/services/pwa';
diff --git a/src/lib/IONOS/stores/notifications.ts b/src/lib/IONOS/stores/notifications.ts
index ecd66b5368e..298ca61d9ba 100644
--- a/src/lib/IONOS/stores/notifications.ts
+++ b/src/lib/IONOS/stores/notifications.ts
@@ -1,12 +1,12 @@
-import { type Writable, writable, type Readable } from 'svelte/store';
+import { get, writable, type Writable, type Readable } from 'svelte/store';
export enum NotificationType {
- INFO = 'bg-blue-100 text-blue-800',
+ INFO = 'bg-blue-100 text-blue-800 info',
SUCCESS = 'success',
- ERROR = 'bg-red-100 text-blue-800',
+ ERROR = 'bg-red-100 text-blue-800 error',
WARNING = 'warning',
- FEEDBACK = NotificationType.INFO,
- PWA_INSTALL = NotificationType.INFO,
+ FEEDBACK = 'bg-blue-100 text-blue-800 feedback',
+ PWA_INSTALL = 'bg-blue-100 text-blue-800 pwa-install',
}
export type NotificationActionBase = {
@@ -42,14 +42,18 @@ export type SubscribableNotification = Readable;
export const notifications: Writable = writable([]);
-export const addNotification = (notification: SubscribableNotification): void => {
- notifications.update((currentNotifications: SubscribableNotification[]) => {
- return [...currentNotifications, notification];
- });
+export const addNotification = (newNotificationStore: SubscribableNotification): void => {
+ const newNotification: Notification = get(newNotificationStore);
+ const currentNotifications: SubscribableNotification[] = get(notifications);
+ const alreadyPresent = currentNotifications.some(n => get(n).id === newNotification.id);
+
+ if (!alreadyPresent) {
+ notifications.update((current: SubscribableNotification[]) => [...current, newNotificationStore]);
+ }
};
export const removeNotification = (id: string): void => {
- notifications.update((currentNotifications: Notification[]) =>
- currentNotifications.filter(n => n.id !== id)
+ notifications.update((currentNotifications: SubscribableNotification[]) =>
+ currentNotifications.filter(n => get(n).id !== id)
);
};