diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 48cc5675..ff23f8c6 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -5,7 +5,7 @@ class InboxController < ApplicationController after_action :mark_inbox_entries_as_read, only: %i[show] - def show + def show # rubocop:disable Metrics/MethodLength, Metrics/AbcSize find_author find_inbox_entries @@ -13,15 +13,17 @@ class InboxController < ApplicationController # rubocop disabled because of a false positive flash[:info] = t(".author.info", author: @author) # rubocop:disable Rails/ActionControllerFlashBeforeRender redirect_to inbox_path(last_id: params[:last_id]) + return end @delete_id = find_delete_id - @disabled = true if @inbox.empty? + services = current_user.services + respond_to do |format| - format.html + format.html { render "show", locals: { services: } } format.turbo_stream do - render "show", layout: false, status: :see_other + render "show", locals: { services: }, layout: false, status: :see_other # rubocop disabled as just flipping a flag doesn't need to have validations to be run @inbox.update_all(new: false) # rubocop:disable Rails/SkipsModelValidations diff --git a/app/views/inbox/_entry.html.haml b/app/views/inbox/_entry.html.haml index e761af4f..f630d80c 100644 --- a/app/views/inbox/_entry.html.haml +++ b/app/views/inbox/_entry.html.haml @@ -40,9 +40,9 @@ = render "shared/format_link" .card-footer.d-none{ id: "ib-options-#{i.id}" } %h4= t(".sharing.heading") - - if current_user.services.count.positive? + - if services.count.positive? .row - - current_user.services.each do |service| + - services.each do |service| .col-md-3.col-sm-4.col-xs-6 %label %input{ type: "checkbox", name: "ib-share", checked: :checked, data: { ib_id: i.id, service: service.provider } } diff --git a/app/views/inbox/show.html.haml b/app/views/inbox/show.html.haml index 5c5de4e4..94d7d883 100644 --- a/app/views/inbox/show.html.haml +++ b/app/views/inbox/show.html.haml @@ -1,6 +1,6 @@ #entries - @inbox.each do |i| - = render "inbox/entry", i: + = render "inbox/entry", services:, i: - if @inbox.empty? %p.empty= t(".empty") diff --git a/app/views/inbox/show.turbo_stream.haml b/app/views/inbox/show.turbo_stream.haml index fffc48fc..ce09c7da 100644 --- a/app/views/inbox/show.turbo_stream.haml +++ b/app/views/inbox/show.turbo_stream.haml @@ -1,6 +1,6 @@ = turbo_stream.append "entries" do - @inbox.each do |i| - = render "inbox/entry", i: + = render "inbox/entry", services:, i: = turbo_stream.update "paginator" do - if @more_data_available diff --git a/spec/controllers/inbox_controller_spec.rb b/spec/controllers/inbox_controller_spec.rb index bc0ba2ad..f2ec2c9f 100644 --- a/spec/controllers/inbox_controller_spec.rb +++ b/spec/controllers/inbox_controller_spec.rb @@ -179,9 +179,7 @@ describe InboxController, type: :controller do inbox: [], inbox_last_id: nil, more_data_available: false, - inbox_count: 0, - delete_id: "ib-delete-all", - disabled: true + inbox_count: 0 } end end @@ -213,9 +211,7 @@ describe InboxController, type: :controller do inbox: [], inbox_last_id: nil, more_data_available: false, - inbox_count: 0, - delete_id: "ib-delete-all", - disabled: true + inbox_count: 0 } end end