From 367e2f4b92a92e9ddc28ac64d20b6881706e0c0d Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 28 Jan 2023 22:24:05 +0100 Subject: [PATCH] Use a local instead of an ivar for passing services into views --- app/controllers/inbox_controller.rb | 6 +++--- app/views/inbox/_entry.html.haml | 4 ++-- app/views/inbox/show.html.haml | 2 +- app/views/inbox/show.turbo_stream.haml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 016e00c1..389411c4 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -11,13 +11,13 @@ class InboxController < ApplicationController check_for_empty_filter @delete_id = find_delete_id - @services = current_user.services @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 1b41cb7c..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 @services.count.positive? + - if services.count.positive? .row - - @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..fd14f7fe 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