The question
When a cook finishes a recipeBrimfox · The appFinishing a mealThe cook picks which pantry items to keep and which to remove. Keep is the default.See it in the Brimfox build in Brimfox, the app saves the meal. Two sharingBrimfox · The serverSharingSends the post and the public review afterwards, so a failed share never undoes a saved meal.See it in the Brimfox build requests can follow. One creates a cooking post, and one asks for a public review. If the meal saves and the post fails, what should the cook be told?
What made it hard
One general error message would hide that the meal was already saved. It could push someone to enter the same meal twice. Saving has a problem of its own, which is the pantryBrimfox · The appRecipes and pantryShows recipes against what is really in the pantry, with swaps that truly cover a missing ingredient.See it in the Brimfox build. The pantry is Brimfox’s list of the ingredients on hand. Finishing a recipe does not mean every listed ingredient is gone. So the recipe alone cannot say what is left.
What I chose
So Brimfox asks the cook. For each ingredient, the cook picks a pantry action, Keep or Remove. Every action starts as Keep. A Remove names one pantry item. Brimfox then marks that item as removed but does not wipe it, which is called a soft delete. If the item is not in a pantry the cook may use, Brimfox records a skipped update. It does not remove a different item in its place.
The request that saves the meal goes to the Brimfox A technical wordAPIA set of web addresses that one program uses to ask another program for data, or to ask it to do something., the server built with Laravel. A pantry is either personal or shared by a householdBrimfox · The serverHousehold accessBefore anything is saved, the server checks which household the person belongs to. It looks up pantry items only in that household or in the person’s own pantry.See it in the Brimfox build. So Laravel first checks that the cook is a member of the household the request names. Then the records that describe the meal are saved in one A technical worddatabase transactionA group of database changes saved together, so either all of them are saved or none are., so either all of them are saved or none is. These are the pantry changes, the cook sessionBrimfox · The serverMeal completionSaves the pantry changes and the cook session together. The cooking memory and family feedback are saved in the same step, so either all of it is saved or none of it is.See it in the Brimfox build and the cooking memory. Any family feedback is saved with them. The post and the public review are not part of that step.
In the Flutter app, one piece of code, called a controller, sends these requests in order. It keeps the saved result before it sends the post. If the post or the review then fails, the app can still say the meal was saved. It can name the sharing problem separately.
What is still open
What is still open is trying the save again. The API accepts a replay key tied to the user. The key marks a request as a repeat of an earlier one. But the controller makes a new key every time it runs. So going through the steps again is not the same as repeating the first request. The next tests should start from a saved meal and then make the post or the review fail. They should check the message and what stays saved. They should also check whether a retry carries the first key.