Skip to content

Shopping list: removing a recipe unticks items shown under an aisle name #654

Closed

Description

@LeMyst

What happens

Removing a recipe from the shopping list unticks an item that is still on the list. The answer to the page's next POST /api/shopping_list already lacks it in checked: the tick is gone from .shopping-checked, not just from the page.

Steps to reproduce

With the seed (config/aisle.conf has egg | eggs):

  1. Add Easy Pancakes and Mexican Style Burrito to the shopping list. Both use @eggs; the list shows it as egg.
  2. Tick egg.
  3. Remove Easy Pancakes.
  4. egg is unticked, though the burrito still needs eggs.

With curl: checked is ["egg","butter"] before the remove, ["butter"] after. butter is written the same way in both recipes and keeps its tick.

Cause

Since 7700032 (#318), remove_from_shopping_list (and POST /api/shopping_list/compact) drops the ticks of ingredients no longer on the list, through store.compact(aggregate_current_ingredient_names(..)).

aggregate_current_ingredient_names returns the names as the recipes write them (eggs; its doc comment says so). But POST /api/shopping_list runs the list through use_common_names(&aisle, ..), so the page shows, and ticks, the aisle file's first name (egg). The case-insensitive compare finds no egg among the remaining ingredients and drops it.

Any ingredient whose recipe name is a synonym in aisle.conf is affected (eggs, sea salt, extra virgin olive oil… in the seed). Grouping entries on the aisles page (#631) makes such synonyms more common.

Fix

Compact against the names the page shows as well: the common names from the aisle file, plus the recipes' own names, so that a tick made under one of those still counts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions