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

feat: Filter Recipes By Household (and a ton of bug fixes) #4207

Conversation

michael-genson
Copy link
Collaborator

@michael-genson michael-genson commented Sep 14, 2024

Malcom in the Middle Changing a Lightbulb

What type of PR is this?

(REQUIRED)

  • bug
  • cleanup
  • feature

What this PR does / why we need it:

(REQUIRED)

This PR adds a household filter to the recipe search. It's a radio select, so you can only select one household or no households. This lets users find recipes based on a specific household (e.g. show me only my household's recipes):
image

Note there's a new "Clear Selection" button there too. You can click on the radio button a second time to deselect it, but I thought an explicit clear button would be easier to understand. This households filter only appears if there's two or more households to choose from (otherwise the filter would be useless). As expected, on public instances, only non-private households are shown here.

You wouldn't think this would be a pain to implement... but boy howdy did I uncover so many layers of jank. In addition to implementing the filter on the recipes page, here are all the things I changed on the frontend:

  • Stores (food store, unit store, etc.) are now generic, so we can easily add more of them with little code reuse (consequently this fixed a reactivity bug on the food data management page)
  • Data management tables use explicit initial sorting (because the generic stores made changes look jank)
  • Fixed household actions mixing admin and non-admin routes
  • Fixed filter reactivity
    • filters were getting overwritten if you tried changing them while recipes were loading from a previous filter change
    • recipes seem to jump around after selecting new filters, before they're all fully loaded
  • Fixed infinite scroll breaking when you change filters (try adding filters such that there are only a few recipes, then change back to no filters; you can't get past the first page of recipes anymore)
  • Converted the recipe favorites page to use lazy recipes like the rest of the app does

And on the backend:

  • re-organized some household routes to make more sense (i.e. match the store/actions pattern)
  • added a households filter to recipe get_all routes
  • fixed cookbooks returning recipes from multiple households (they should be limited to only their own household)

Which issue(s) this PR fixes:

(REQUIRED)

Partially implements #4081

Special notes for your reviewer:

(fill-in or delete this section)

I swear this PR wasn't supposed to be very big

Testing

(fill-in or delete this section)

Frontend manual testing; added a bunch to pytest

Copy link
Collaborator

@Kuchenpirat Kuchenpirat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i managed to have my review match the randomness of the gif.

Frontend is all i manage today. Will try to finish the rest tomorrow.

Its all just little comments. No obvious bugs yet. But will do some real world testing as well and see what i find.

@Kuchenpirat Kuchenpirat self-requested a review September 22, 2024 08:19
Copy link
Collaborator

@Kuchenpirat Kuchenpirat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took me a bit longer than a day but i have no blocking comments.

Will leave it up to you to merge 🚀

@michael-genson michael-genson enabled auto-merge (squash) September 22, 2024 14:51
@michael-genson michael-genson merged commit 7c274de into mealie-recipes:mealie-next Sep 22, 2024
13 checks passed
@michael-genson michael-genson deleted the feat/filter-recipes-by-household branch September 22, 2024 15:31
boc-the-git pushed a commit to boc-the-git/mealie that referenced this pull request Sep 28, 2024
…cipes#4207)

Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
boc-the-git pushed a commit to boc-the-git/mealie that referenced this pull request Sep 28, 2024
…cipes#4207)

Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
Choromanski pushed a commit to Choromanski/mealie that referenced this pull request Oct 1, 2024
…cipes#4207)

Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants