From 76c56c82845b4fce63c6f1cdf4ac3935bf1747e7 Mon Sep 17 00:00:00 2001 From: Jan Cernik <66427541+jancernik@users.noreply.github.com> Date: Tue, 28 May 2024 10:21:33 -0300 Subject: [PATCH] FIX: Bulk clear reminders when the reminder is expired (#27220) --- .../addon/components/bulk-select-bookmarks-dropdown.js | 2 ++ app/models/bookmark.rb | 2 +- spec/lib/bookmarks_bulk_action_spec.rb | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/select-kit/addon/components/bulk-select-bookmarks-dropdown.js b/app/assets/javascripts/select-kit/addon/components/bulk-select-bookmarks-dropdown.js index f9a30095fdd..e5fc1c59709 100644 --- a/app/assets/javascripts/select-kit/addon/components/bulk-select-bookmarks-dropdown.js +++ b/app/assets/javascripts/select-kit/addon/components/bulk-select-bookmarks-dropdown.js @@ -65,6 +65,7 @@ export default DropdownSelectBoxComponent.extend({ }) .then(() => { this.router.refresh(); + this.bulkSelectHelper.clear(); this.toasts.success({ duration: 3000, data: { message: i18n("bookmarks.bulk.reminders_cleared") }, @@ -88,6 +89,7 @@ export default DropdownSelectBoxComponent.extend({ }) .then(() => { this.router.refresh(); + this.bulkSelectHelper.clear(); this.toasts.success({ duration: 3000, data: { message: i18n("bookmarks.bulk.delete_completed") }, diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index 911fe9f1ff9..2c98fe44dcb 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -120,7 +120,7 @@ class Bookmark < ActiveRecord::Base end def clear_reminder! - update!(reminder_last_sent_at: Time.zone.now, reminder_set_at: nil) + update!(reminder_last_sent_at: Time.zone.now, reminder_set_at: nil, reminder_at: nil) end def reminder_at_in_zone(timezone) diff --git a/spec/lib/bookmarks_bulk_action_spec.rb b/spec/lib/bookmarks_bulk_action_spec.rb index 851c183c726..4f2ec49684f 100644 --- a/spec/lib/bookmarks_bulk_action_spec.rb +++ b/spec/lib/bookmarks_bulk_action_spec.rb @@ -44,7 +44,9 @@ RSpec.describe BookmarksBulkAction do expect do bba = BookmarksBulkAction.new(user, [bookmark_with_reminder.id], type: "clear_reminder") bba.perform! - end.to change { Bookmark.find_by_id(bookmark_with_reminder.id).reminder_set_at }.to(nil) + end.to change { Bookmark.find_by_id(bookmark_with_reminder.id).reminder_set_at }.to( + nil, + ).and change { Bookmark.find_by_id(bookmark_with_reminder.id).reminder_at }.to(nil) end end end