Optimized rtk usage when deleting notifications #2347
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes in this pull request
Resolves #2236
Additional info
This pull request refactors the notification tag handling and improves the notification deletion flow, especially for optimistic updates and cache consistency. The main changes involve updating how tags are provided and invalidated for notifications, and ensuring that deleting a notification immediately updates the UI by removing it from cached collections.
Tag handling and cache management improvements:
providingTags
andinvalidatingTags
structures intags.ts
to useNOTIFICATIONS
andNOTIFICATION_DETAIL
consistently, removing the oldNOTIFICATION
tag and aligning tag usage for better cache management. [1] [2]notifications-slice-enhanced.ts
to use the new tag functions, ensuring that notification collections and details are properly tagged for cache updates.Optimistic UI and error handling enhancements:
removeNotificationFromCollectionById
method touse-optimistic-update.tsx
, which updates cached notification collections to immediately reflect deletions, improving perceived performance and user experience. [1] [2]use-notification-detail.tsx
to use the new removal method and improved error handling by distinguishing between API and general errors during deletion. [1] [2] [3]Minor UI code cleanup:
notification-detail.tsx
to align with the new notification detail hook structure. [1] [2]