Fix notification deduplication to prevent pile-up in navbar (#945)
* Fix notification deduplication to prevent pile-up in navbar (#944) When tasks/projects remained pending for multiple days, duplicate notifications accumulated in the navbar instead of showing only the most recent one. Updated notification services to properly handle existing notifications: - Delete unread notifications before creating new ones - Respect dismissed notifications (don't recreate) - Respect read notifications (don't duplicate) Changes: - Updated dueTaskService, deferredTaskService, and dueProjectService - Added comprehensive unit tests with 8 test cases Fixes #944 * Fix lint errors and add GitHub bug template reminder to docs
This commit is contained in:
parent
1d5de49b48
commit
105a913a8d
5 changed files with 355 additions and 11 deletions
|
|
@ -70,8 +70,7 @@ async function checkDueProjects() {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Check for existing notifications (including dismissed ones)
|
||||
// If a notification was dismissed, don't create it again
|
||||
// Check for existing notifications
|
||||
const recentNotifications = await Notification.findAll({
|
||||
where: {
|
||||
user_id: project.user_id,
|
||||
|
|
@ -91,9 +90,19 @@ async function checkDueProjects() {
|
|||
);
|
||||
|
||||
if (existingNotification) {
|
||||
// Skip if notification exists, even if it was dismissed
|
||||
// This prevents re-notifying users about tasks they've already dismissed
|
||||
continue;
|
||||
// If notification was dismissed, don't create it again
|
||||
if (existingNotification.dismissed_at) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If notification is unread, delete it before creating the new one
|
||||
// This prevents duplicate notifications from piling up
|
||||
if (!existingNotification.read_at) {
|
||||
await existingNotification.destroy();
|
||||
} else {
|
||||
// If it was already read, skip creating a new one
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const { title, message } = generateNotificationContent(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue