-
Notifications
You must be signed in to change notification settings - Fork 0
c/fix(notifications): check the notification is not already present w… #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in the notifications system by preventing duplicate notifications from being added. The change adds a check to verify that a notification with the same ID is not already present before adding it to the store.
- Added duplicate notification prevention logic
- Imported the
getfunction from Svelte store to access notification values - Modified the
addNotificationfunction to check for existing notifications by ID
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
e392cb2 to
17ad526
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
17ad526 to
0213dc9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| export const addNotification = (newNotificationStore: SubscribableNotification): void => { | ||
| const newNotification: Notification = get(newNotificationStore); | ||
| const currentNotifications = get(notifications); | ||
| const alreadyPresent: boolean = currentNotifications.some(n => get(n).id === newNotification.id); |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation calls get() on every notification store in the array for each duplicate check, which can be inefficient with many notifications. Consider caching the notification values or using a more efficient lookup mechanism like a Set of IDs.
| const alreadyPresent: boolean = currentNotifications.some(n => get(n).id === newNotification.id); | |
| const existingIds = new Set(currentNotifications.map(n => get(n).id)); | |
| const alreadyPresent: boolean = existingIds.has(newNotification.id); |
…n trying to add Signed-off-by: Kai Henseler <[email protected]>
Refs: PRODAI-380
Refs: PRODAI-380
It now takes the ID. Refs: PRODAI-380
Change from store.update() to removeNotification() to avoid duplicated logic. Refs: PRODAI-380
… .ts extension Refs: PRODAI-380
To fix typechecker error:
/app/src/lib/IONOS/components/notifications/NotificationBanner.svelte:23:13
Error: This comparison appears to be unintentional because the types 'NotificationType.SUCCESS | NotificationType.WARNING' and 'NotificationType.INFO' have no overlap. (ts)
<EmojiSad className="text-red-500"/>
{:else if $notification.type === NotificationType.INFO}
<Touch />
Reason FEEDBACK had the same value as INFO, thus always the first branch
was hit, never the last.
Strictly the types "PWA" or "feedback" should not belong to a
notification data type. This should be refactored in a separate commit.
Refs: PRODAI-380
…pe declaration We're iterating over SubscribableNotification. Refs: PRODAI-380
0213dc9 to
05eaf2a
Compare
No description provided.