-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for #5808: Update the cached Place Items on the successful association of Wiki Item #5864
Fix for #5808: Update the cached Place Items on the successful association of Wiki Item #5864
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it still a draft?
Fantastic code, and screencast looks great!
app/src/main/java/fr/free/nrw/commons/nearby/PlacesLocalDataSource.java
Outdated
Show resolved
Hide resolved
@nicolas-raoul, I had left the PR as draft to get your feedback on the approach I had taken. If you think this is approach is acceptable, I am happy to set this PR to ready to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great!
I am testing on my device, now going outside to actually get pictures of places and try it out in the real world. :-)
Somehow the pin stayed red in my test (screencast below)... any idea what might be happening? Maybe a server-side cache issue? Analyzing server response to our query_for_item.rq request would tell. In that case deleting the cache again every 10 seconds for 1 minute may be a workaround. screen-20241018-115915.mp4 |
Oh, that is very interesting. The only reason I can possibly attribute to is that I had added a breakpoint at the step to check whether the cache was being cleared. This could have possibly added enough delay for the server side response to be updated.
Alternatively, do you think it would be appropriate to instead directly write the updated image link to the cache, this will only be done if a |
Usually it is more elegant (even if a bit wasteful) but only clear the cache and then let the normal code load the new value from the server. But in this case I agree it is a good way to avoid server-side cache issues. Looking forward to the updated pull request, thanks a lot for the great idea! |
@nicolas-raoul Thank you for the feedback. I agree that updating the URL would be the most reliable solution at this point, without adding additional overhead. However, when inspecting the code, I realised that after a successful upload, the |
…nt. Update Success Notification to show only after the pin has been updated.
@nicolas-raoul I have updated the PR description, and also updated the code to reflect our conversation. Would you be able to review this PR ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great, thanks a lot!
When a user uploads a valid depiction of a Wiki Item which currently has no image (represented by a red pin), the pin should turn green on the successful upload and depiction of the image. However, due to caching of Nearby places, the pin colour is not updated after user's image upload.
Fixes #5808
Changes
A new method was added to thePlacesRepository
to delete a givenPlace
entity.On the successful claiming of aWikiItemEdit
, the corresponding Wiki Item is cleared from the cacheWikiItemEdit
, the corresponding Wiki Item updated in the local cache.HOME_URL + uploadResult.createCanonicalFileName()
name
of thisPlace
object is also updated from theWikiItem
. This is because there was a scenario where aPlace
fetched would have an empty name. Therefore, theNearbyParentFragment
tries to update Places without a validname
from the web, leading to a race condition. This situation was observed through logs.Tested
ProdDebug
on Pixel 7 with API level 34.https://github.com/user-attachments/assets/6328b8ca-8342-453b-815a-30f0c10d36f2