rjwignar / AIChefBot

Your AI-Powered Recipe Generator
https://ai-chef-bot.vercel.app
3 stars 0 forks source link

Saved status of recipes is preserved on refresh #167

Closed kpunno closed 7 months ago

kpunno commented 7 months ago

Fixes #159

Modified cacheing such that the cache will update when a recipe is saved.

The cached recipe will receive an _id property which is detected when recipe cards are generated, thus giving the recipe card knowledge that this recipe has been saved.

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai-chef-bot ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 9, 2024 8:59pm
kpunno commented 7 months ago

I see the issue. Looking at it now. It's making some real spaghetti trying to use RecipeCard over these two contexts. Making things graceful becomes more difficult as we add more features.

@rjwignar

rjwignar commented 7 months ago

I see the issue. Looking at it now. It's making some real spaghetti trying to use RecipeCard over these two contexts. Making things graceful becomes more difficult as we add more features.

@rjwignar

I agree :/. Perhaps we can modify that if statement to execute only if there's a _id property AND there's no cache (maybe we can check this using getCache(). I'm not completely familiar with the caching code yet, but if there's a way we could do the above we could try and out and see how it works out

kpunno commented 7 months ago

@rjwignar

Solution using URL path to determine what the context is... Check it out.

rjwignar commented 7 months ago

@rjwignar

Solution using URL path to determine what the context is... Check it out.

Clever solution @kpunno...I like it.

When testing I found one more bug, similar to the original bug your PR tackles. If a user removes a recipe they just saved and refresh/return to their cache, the UI will suggest that recipe is still saved even though it's been removed: deleteRecipeFromCacheBug2

This can be misleading to users. To fix this, we just need to update the cache when a recipe is unsaved.

kpunno commented 7 months ago

@rjwignar

Nice, makes sense. I pushed a fix. Remove the recipe id from the cache when the recipe is unsaved... Thanks for your keen eyes.