nickslick03 / messiah-meal-planner

1 stars 0 forks source link

Synchronization with available meals #31

Closed cdrice26 closed 4 months ago

cdrice26 commented 4 months ago

Refactored the program so that userSelectedMeals and mealQueue just have references to the available meal arrays, and added memos to dereference them. Everything should now sync up with the common copy of meals, including custom meals.

nickslick03 commented 4 months ago

Wow, that's a lot of code. Unfortunately, the same thing happening in the issue I created is happening now. If you add multiple of the same meal to the MealQueue or DayEditor, the remove meal function compares the mealId, not the id (I assume that in the mealsReference interface, mealId refers to the Id of the original meal as defined in the mealsDatabase, and id refers to the id of that specific reference). Maybe instead of dereferencing the meal queue and meal day lists, change the props of the meal container, meal table, and meal row to pass the id of the meal reference to the removeMeal callback?

cdrice26 commented 4 months ago

Argh that issue keeps popping up, it's too easy to miss! I believe I fixed it by giving both the Meal and MealReference types an id (representing the id of the meal in the "database") and an instanceId (representing the specific reference). This avoids modifying so many components, and allows me to keep the AvailableMeals table as is.

nickslick03 commented 4 months ago

nice. I like "InstanceId" better