ParseReact icon indicating copy to clipboard operation
ParseReact copied to clipboard

Can't refresh user query

Open bytesandwich opened this issue 10 years ago • 7 comments

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.

bytesandwich avatar Jun 21 '15 23:06 bytesandwich

Are you observing a User query, or observing the current user with ParseReact.currentUser?

andrewimm avatar Jun 22 '15 22:06 andrewimm

I'm subscribing to ParseReact.currentUser. Is it possible to subscribe to the current user with a query?

bytesandwich avatar Jun 22 '15 23:06 bytesandwich

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.

andrewimm avatar Jun 22 '15 23:06 andrewimm

:+1:

bytesandwich avatar Jun 22 '15 23:06 bytesandwich

@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);
        }
      });

andyyou avatar Oct 29 '15 02:10 andyyou

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 avatar Feb 11 '16 09:02 maqen

@maqen I have no news and drop out Parse in my project

andyyou avatar Feb 12 '16 07:02 andyyou