Skip to content

Conversation

@bromiesTM
Copy link

No description provided.

@bromiesTM bromiesTM requested a review from Copilot October 10, 2025 09:57
Copy link

Copilot AI left a 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 get function from Svelte store to access notification values
  • Modified the addNotification function 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.

@bromiesTM bromiesTM force-pushed the kh/fix/multiple-survey-notifications branch from e392cb2 to 17ad526 Compare October 10, 2025 09:58
@bromiesTM bromiesTM requested a review from Copilot October 10, 2025 09:58
Copy link

Copilot AI left a 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.

@bromiesTM bromiesTM force-pushed the kh/fix/multiple-survey-notifications branch from 17ad526 to 0213dc9 Compare October 10, 2025 10:15
@bromiesTM bromiesTM requested a review from Copilot October 10, 2025 10:16
Copy link

Copilot AI left a 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);
Copy link

Copilot AI Oct 10, 2025

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
bromiesTM and others added 9 commits October 10, 2025 18:10
Change from store.update() to removeNotification() to avoid duplicated
logic.

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
@bromiesTM bromiesTM force-pushed the kh/fix/multiple-survey-notifications branch from 0213dc9 to 05eaf2a Compare October 10, 2025 16:11
@bromiesTM bromiesTM merged commit 38dcfff into ionos-dev Oct 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants