I'm using Parse SDK's localDataStore
to implement offline-capable Android app.
When users create new objects, they're pinned locally with a special label. When it's time to sync offline changes to the server, I search for all objects pinned with that label and save
them. At that point, after the object is synced to the server, I want to remove the label, but keep the object pinned locally. The only way I found to achieve that is this:
parseObject.save();
parseObject.unpin(ParsePinLabels.MODIFIED_OFFLINE);
parseObject.pin();
Two problems with this approach:
- Takes too long
- Ugly
My intuition says that in this scenario it should be enough to just remove the label from the already pinned ParseObject
, but I can't find a way to do that without full unpin
. What do I miss?
Eventually, I couldn't find a way to just remove the label from a pinned object, without unpinning it.
So, we either need to pin the object after unpinning:
Or, as suggested by Davi in the comments, we could pin the object with two different labels to begin with, and then just keep one of them forever:
However, when using the second approach, you might run into this nasty unresolved bug when using
ParseObject.unpinAll()
. Therefore, if you use the second approach, you'll need to remember to unpin all objects in this manner: