Fix notifications page crashing on reactions

This commit is contained in:
Karina Kwiatek 2022-03-26 12:18:38 +01:00 committed by Karina Kwiatek
parent 0cfe5ee964
commit f20e407cc3
2 changed files with 7 additions and 2 deletions

View File

@ -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?

View File

@ -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]