fix meal list delete and copy, and allow editing of name #93

Closed
opened 2025-10-09 09:20:46 +11:00 by Ghost · 0 comments
Ghost commented 2025-10-09 09:20:46 +11:00 (Migrated from codeberg.org)

delete and copy weren't working because they were adding to the wrong session id, and probably deleting from as well.

in this func, need to set the session after extracting meal data, cos it would get id from old record.

const addMeal = async (mealToCopy?: SessionMeal) => {
    const data = mealToCopy ? extractMealData(mealToCopy) : { session: props.sessionID, name: "Meal" };

    addRowAtIndex(props.meals.length, undefined, data);
    setShowCopyMeal(false);
  };

the deleting is due to the order, session is set before extracting id, need to await the delete first, or grab the id before removing the row:

 props.setSession("session", "expand", "sessionMeals_via_session", newMeals);
      await pb.collection("sessionMeals").delete(props.meals[index].id);
delete and copy weren't working because they were adding to the wrong session id, and probably deleting from as well. in this func, need to set the session after extracting meal data, cos it would get id from old record. ``` const addMeal = async (mealToCopy?: SessionMeal) => { const data = mealToCopy ? extractMealData(mealToCopy) : { session: props.sessionID, name: "Meal" }; addRowAtIndex(props.meals.length, undefined, data); setShowCopyMeal(false); }; ``` the deleting is due to the order, session is set before extracting id, need to await the delete first, or grab the id before removing the row: ``` props.setSession("session", "expand", "sessionMeals_via_session", newMeals); await pb.collection("sessionMeals").delete(props.meals[index].id); ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
davenh99/progressa#93
No description provided.