ParseReact
ParseReact copied to clipboard
Can't refresh user query
Suppose I observe the user, and then I add fields to _User from the online gui.
I can't access those fields from react or refresh the subscription from refreshQueries because at https://github.com/ParsePlatform/ParseReact/blob/master/lib/Mixin.js#L111
refresh on queryNames[name].refresh(); is undefined.
Are you observing a User query, or observing the current user with ParseReact.currentUser?
I'm subscribing to ParseReact.currentUser. Is it possible to subscribe to the current user with a query?
This is a tricky situation, essentially we need the equivalent of Parse.Object.prototype.fetch() for this particular LocalSubscription. I think it makes sense to stick with the .refresh() method name, since that's also ideally what we'll use once I settle on a solution for subscribing to single objects and query counts.
:+1:
@andrewimm Sorry for bother you, but I really need a solution sync data to ParseReact.currentUser
in my case I have a field require to be unique, so for now I only found out this solution by Parse.Cloud that why I need a way to update data locally.
Parse.Cloud.run('setUniqueField', {
userID: this.data.user.id.objectId,
uniqueField: this.state.value,
}, {
success: function (response) {
// It doesn't work!
// ParseReact.currentUser.update();
this.props.navigator.pop();
}.bind(this),
error: function (error) {
console.log('[Parse Cloud Error]: ', error);
}
});
[UPDATE] For now I did a stupid way as follow
Parse.Cloud.run('setUniqueField', {
userID: this.data.user.id.objectId,
uniqueField: this.state.value,
}, {
success: function (response) {
ParseReact.Mutation.Set(this.data.user.id, {
uniqueField: this.state.value,
}).dispatch();
this.props.navigator.pop();
}.bind(this),
error: function (error) {
console.log('[Parse Cloud Error]: ', error);
}
});
Any news on this? Ideas on how this could be solved? Currently setting data on user similar to @andyyou in cloud function and need to refresh ParseReact.currentUser.
@maqen I have no news and drop out Parse in my project