From f20e407cc3c6f8369ee66a0d12fd8dcc7bc294de Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 26 Mar 2022 12:18:38 +0100 Subject: [PATCH] Fix notifications page crashing on reactions --- app/controllers/notifications_controller.rb | 7 ++++++- app/views/notifications/index.haml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index f2569383..9d167647 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -1,8 +1,13 @@ class NotificationsController < ApplicationController before_action :authenticate_user! + TYPE_MAPPINGS = { + 'smile' => 'appendable::reaction', + 'reaction' => 'appendable::reaction', + }.freeze + def index - @type = params[:type] + @type = TYPE_MAPPINGS[params[:type]] || params[:type] @notifications = cursored_notifications_for(type: @type, last_id: params[:last_id]) @notifications_last_id = @notifications.map(&:id).min @more_data_available = !cursored_notifications_for(type: @type, last_id: @notifications_last_id, size: 1).count.zero? diff --git a/app/views/notifications/index.haml b/app/views/notifications/index.haml index 4c472f81..2f10b5e0 100644 --- a/app/views/notifications/index.haml +++ b/app/views/notifications/index.haml @@ -13,7 +13,7 @@ - @notifications.each do |notification| %li.list-group-item .media - = render "notifications/type/#{notification.target_type.downcase}", notification: notification + = render "notifications/type/#{notification.target_type.downcase.split('::').last}", notification: notification - unless @notifications.count.zero? = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @notifications_last_id, permitted_params: %i[type]