Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Use for categories, the first picture found in recipes and not the picture of the first recipe #173

Open
zorglubu opened this issue Jan 24, 2023 · 4 comments
Labels
enhancement New feature or request long-term Goal that will take a long time to achieve

Comments

@zorglubu
Copy link

When I add a recipe without any picture, if this recipe becomes the first one in alphabetic order, the category has not anymore any picture.
It would be nice to look after the first picture found in this category, or to be able to choose a recipe for this category's picture.
Thanks. .

@Leptopoda
Copy link
Collaborator

I also hate the current behavior but sadly there is nothing we can do with the current api implementation.

The cookbook api only gives us a category name and a recipe count.
We then need to fetch all recipes in that category and can only guess wich one to chose.

Sadly a recipe always has an image (even the default one) and there is no way for us to easily find out wich one has a real picture without fetching it.
And I think you can get why fetching all pictures of the recipes until we find one isn't the best for performance.

I'm going to raise it on the upstream cookbook issue tracker (if it doesn't already exist) and request some better options although they might take a time to be implemented.

@Teifun2
Copy link
Owner

Teifun2 commented Apr 4, 2023

@Leptopoda What i dont understand is why they provide the default svg from backend. The backend should just send a recipe with NO image. Then the frontend (or client) can handle how this image should be replaced, possibly with an svg or maybe something different.

This already caused so much headache because the image libraray tries to fetch and decode the image but receives an svg and then crashes terribly without any good way to catch the error. (you most likely already have seen to error log spam due to it)
:(

@Leptopoda
Copy link
Collaborator

I think #171 handles this quite elegantly by just checking if the returned bytes can be decoded into a String thus indicating it is an svg => the fallback.

But yeas those are just hacky workarrounds. I mean I understand that not having to deal with null image fields is easier but maybe the server could just make the default image url static so we can at least check before fetching.

Also on a side note the category object should jsut contain the image url. I mean in a browser this might not make a difference but on a mobile device not having to do 2(n+2) fetches (n = number of category) can save quite a bit of load time.

@zorglubu
Copy link
Author

zorglubu commented Apr 4, 2023

Waiting for a more elegant option, what do you think about storing in the phone a "favorite" recipe for storing the image of a category ?

@Leptopoda Leptopoda added feedback Need feedback otherwise the issue will be closed long-term Goal that will take a long time to achieve enhancement New feature or request and removed feedback Need feedback otherwise the issue will be closed labels Apr 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request long-term Goal that will take a long time to achieve
Projects
None yet
Development

No branches or pull requests

3 participants