MichielProost / Perfect-Plate

This Android application allows cheffs around the world to create, review and discover new recipes. Users can gain experience and level up in this app by completing challenges like creating a certain amount of recipes.
1 stars 2 forks source link

Delete/add recipes from/to local cache when creating or deleting a recipe #27

Open Nuytemans-Dieter opened 3 years ago

Nuytemans-Dieter commented 3 years ago

Small code adjustment with big UX improvement.

Nuytemans-Dieter commented 3 years ago

Did a first attempt at this in the commit above (that mentioned this issue). Not all fields are present in Recipe/Review at the time of creation, this should be fixed in a next update. Before committing, I made sure the new code does not interfere.

MichielProost commented 3 years ago

Okay. It's an interesting dilemma. Currently, when we create a recipe or review, unspecified fields get a default value in the ".toMap" methods. For Firestore purposes, this proved to be convenient. I understand that we need to change this to support caching.

Possible fix 1: Change the Recipe / Review constructor. Possible fix 2: Make an additional method in the Recipe and Review class. This method (e.g. getCompleteRecipe) will give a default value to fields that don't exist (null).

Personally, I think fix 1 will be better. I just don't know how yet. You can always participate in this issue. If the issue still exists after my last exam, I will most likely fix it myself. Thanks for bringing this to my attention

Nuytemans-Dieter commented 3 years ago

I absolutely agree, fix 1 is way better and can be used consistently without the need to investigate a bunch of code. It's most likely constructor syntax that you're struggling with? I could fix this or set you in the right direction when we'll be working on this again.

Note: Better fix this one before #3.

MichielProost commented 3 years ago

I would like that. For some reason, constructors confuse me tremendously. I will have to read or watch a tutorial of some sorts.

Nuytemans-Dieter commented 3 years ago

Another problem arrises: medals are not awarded immediately (neither are the points) when the user's reviews or recipes were loaded earlier. Fixing this issue will most likely resolve this problem automatically.

MichielProost commented 3 years ago

Agreed. I do want to point out that this will not occur for all medals.. Only medals that use the cache system (write reviews, receive reviews and create recipes) will be affected by this issue. The other medals work fine (e.g. save recipes, set preferences).