Use a local instead of an ivar for passing services into views

This commit is contained in:
Karina Kwiatek 2023-01-28 22:24:05 +01:00
parent 3e2b65d7b8
commit 367e2f4b92
4 changed files with 7 additions and 7 deletions

View file

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

View file

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

View file

@ -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")

View file

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