Skip to content

Commit 390d16f

Browse files
committed
cleans up controllers for better abstraction
1 parent 266dcdd commit 390d16f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/controllers/better_together/notifications_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def index
1414
def mark_as_read # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
1515
if params[:id]
1616
mark_notification_as_read(params[:id])
17-
elsif params[:message_id]
18-
mark_message_as_read(params[:message_id])
17+
elsif params[:record_id]
18+
mark_record_notification_as_read(params[:message_id])
1919
else
2020
helpers.current_person.notifications.unread.update_all(read_at: Time.current)
2121
end
@@ -41,11 +41,11 @@ def mark_notification_as_read(id)
4141
@notification.update(read_at: Time.current)
4242
end
4343

44-
def mark_message_as_read(id)
45-
@notification = helpers.current_person.notifications.unread.includes(
44+
def mark_record_notification_as_read(id)
45+
@notifications = helpers.current_person.notifications.unread.includes(
4646
:event
4747
).references(:event).where(event: { record_id: id })
48-
@notification.update(read_at: Time.current)
48+
@notifications.update_all(read_at: Time.current)
4949
end
5050
end
5151
end

app/javascript/controllers/better_together/message_visibility_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class extends Controller {
3737
'X-CSRF-Token': this.getCSRFToken()
3838
},
3939
body: JSON.stringify({
40-
message_id: messageId
40+
record_id: messageId
4141
})
4242
})
4343
.then(response => {

0 commit comments

Comments
 (0)