Fix notifications page crashing on reactions
This commit is contained in:
parent
0cfe5ee964
commit
f20e407cc3
|
@ -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?
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue