Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ Warning: you are accessing the variable "translate_error" inside a LiveView template. #176

Closed
nelsonic opened this issue Oct 13, 2022 · 6 comments
Assignees
Labels
chore a tedious but necessary task often paying technical debt help wanted If you can help make progress with this issue, please comment! priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

When running the items-list branch I'm getting a few of these warnings:

==> petal_components
Compiling 25 files (.ex)
warning: you are accessing the variable "translate_error" inside a LiveView template.

Using variables in HEEx templates are discouraged as they disable change tracking. You are only allowed to access variables defined by Elixir control-flow structures, such as if/case/for, or those defined by the special attributes :let/:if/:for. If you are shadowing a variable defined outside of the template using a control-flow structure, you must choose a unique variable name within the template.

Instead of:

    def add(assigns) do
      result = assigns.a + assigns.b
      ~H"the result is: <%= result %>"
    end

You must do:

    def add(assigns) do
      assigns = assign(assigns, :result, assigns.a + assigns.b)
      ~H"the result is: <%= @result %>"
    end

  lib/petal_components/form.ex:412: PetalComponents.Form.form_field_error/1

We need to do whatever it takes to not have these kinds of warnings in our app. 🙏

@nelsonic nelsonic added help wanted If you can help make progress with this issue, please comment! technical A technical issue that requires understanding of the code, infrastructure or dependencies priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished chore a tedious but necessary task often paying technical debt tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written labels Oct 13, 2022
@nelsonic nelsonic mentioned this issue Oct 13, 2022
10 tasks
@nelsonic
Copy link
Member Author

@LuchoTurtle can you please confirm if you are still seeing this warning when running the MVP on your localhost #190 💭 🙏

@LuchoTurtle
Copy link
Member

@nelsonic In the items_list branch, yes, this warning still pops up.

Screenshot 2022-10-27 at 11 08 53

This branch's dependencies are outdated when compared to the main branch.

@nelsonic
Copy link
Member Author

OK. Let's review this when I'm back at my desk. for now ...

@nelsonic nelsonic reopened this Oct 27, 2022
@nelsonic
Copy link
Member Author

Derp! 🤦‍♂️ Sorry that was an unintentional close. 🤦‍♂️
For now ... #195

@LuchoTurtle
Copy link
Member

I'm trying to get this fixed but to tackle this, I had to make #165 up-to-date with the main branch, which involved fixing loads of merging conflicts.

Although the PR is still in progress, the reason I'm a bit "stuck" is that the original PR (#165) uses the person table, which no longer exists. So to get this PR up to speed with the current changes of the main branch, the database schema definitions need to be reworked to make it work.

Originally, the PR introduced two new tables: ListItem (bridge table between Item and List) and List (which has a name, person_id referencing the Person table and lists_name_person_id_index, which forced uniqueness in the table - see https://github.com/dwyl/mvp/pull/165/files#r991038501).

Now that the Person table was removed, person_id can't be a field in this table. This will affect operations like "fetching a user's lists". How should we manage the lists for each person now?

I've created #351 which will hopefully be merged into the items-list branch in #165. It fixes compile-time errors however, even though I could remove any instances of a person_id in the List schema definition and change the way we fetch a user's list, I thought it'd be better to get some feedback first.

My intention was to, at first, remove the person_id field completely from Lists and hopefully get this merged so we have #165 up-to-date and then focus on adding groups and lists for different people. But I prefer to leave it to the pros first.

@LuchoTurtle
Copy link
Member

LuchoTurtle commented Sep 25, 2023

Closing this issue because the items-list branch is not tossing errors now when running mix phx.server, mix compile or mix c. 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore a tedious but necessary task often paying technical debt help wanted If you can help make progress with this issue, please comment! priority-2 Second highest priority, should be worked on as soon as the Priority-1 issues are finished tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants