Skip to content
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 local media id collisions #1800

Closed

Conversation

mkevins
Copy link
Contributor

@mkevins mkevins commented Jan 22, 2020

Fixes wordpress-mobile/WordPress-Android#11239

Related PR:

WordPress-Android: wordpress-mobile/WordPress-Android#11125

This PR aims to prevent local media ids from colliding with remote ids during ongoing uploads. The issue is described in more detail here: #1610 (comment). The approach used in this PR is to negate the local media id over the bridge so local ids are represented as negative integers to the JavaScript code. All interactions over the bridge involving these local ids (primarily media upload events) will negate the local id. In this way, the media models and database logic used within WordPress-Android can remain unaffected, and the React Native (JavaScript) logic will avoid id collisions.

Variable names changes:

In several places we are using names like Media_Upload_Callback. This is not always correct, since we use the same callback for media selection from the WordPress Media Library (which does not involve any uploading). I made some variable name changes to improve the clarity while working with this code.

To test:
tbd

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Since this callback is used for selection with the WordPress Media
Library (which does not involve uploading), the shorter and more
general name is less confusing.
@SergioEstevao
Copy link
Contributor

@mkevins is this PR still active, are you still planning to work on this? It will probably need to be update to the monorepo structure.

@mkevins
Copy link
Contributor Author

mkevins commented Jul 20, 2020

@mkevins is this PR still active, are you still planning to work on this? It will probably need to be update to the monorepo structure.

Not really active at the moment. I believe the possibility still exists to have id collisions, but much of this PR will have conflicts, since the interfaces have already been refactored a bit. I'll close this for now, and revisit the strategy if necessary at a later point. Thanks for the reminder!

@mkevins mkevins closed this Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Local media ids can collide with remote ids
2 participants