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

Properly store User Subclass in Storage #978

Merged
merged 6 commits into from
Nov 5, 2019
Merged

Properly store User Subclass in Storage #978

merged 6 commits into from
Nov 5, 2019

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Nov 4, 2019

@taivo Let me know if any changes can be made to replicate your issue

@codecov
Copy link

codecov bot commented Nov 4, 2019

Codecov Report

Merging #978 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #978   +/-   ##
=======================================
  Coverage   91.86%   91.86%           
=======================================
  Files          54       54           
  Lines        5086     5086           
  Branches     1146     1147    +1     
=======================================
  Hits         4672     4672           
  Misses        414      414
Impacted Files Coverage Δ
src/ParseUser.js 82.08% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5245daa...7e6d9b4. Read the comment docs.

@dplewis
Copy link
Member Author

dplewis commented Nov 5, 2019

@acinader This is the easiest fix I can come up with.

The issue here is that subclass users don't automatically have a className (must be explicitly set or passed in here somehow). The second issue is that even if a className exist, it's hardcoded before it saves to disk.

@dplewis dplewis changed the title Failing test for subclass.current() Properly store User Subclass in Storage Nov 5, 2019
Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment

src/ParseUser.js Outdated
@@ -869,7 +869,7 @@ const DefaultController = {
updateUserOnDisk(user) {
const path = Storage.generatePath(CURRENT_USER_KEY);
const json = user.toJSON();
json.className = '_User';
json.className = user.className || '_User';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about

json.className = this.constructor.name === 'ParseUser' ? '_User' : this.constructor.name;

i think that'll work and then you don't have to worry about setting this.className.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

Copy link
Member Author

@dplewis dplewis Nov 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we have a flaky test. I can't restart the build the button is missing, can you?

Edit: Works now

@taivo
Copy link

taivo commented Nov 5, 2019

This is good. When you guys have it merged, I can switch my use case to this and test for a few days.

@dplewis dplewis requested a review from acinader November 5, 2019 14:49
@dplewis dplewis merged commit d42cd14 into master Nov 5, 2019
@dplewis dplewis deleted the subclass-current branch November 5, 2019 17:23
dplewis added a commit that referenced this pull request Nov 14, 2019
Revert #978
@dplewis dplewis mentioned this pull request Nov 14, 2019
dplewis added a commit that referenced this pull request Nov 14, 2019
* Fix #992

Revert #978

* remove static ParseUser class name
dplewis added a commit that referenced this pull request Dec 2, 2019
After much discussion the proper way to subclass is a user is `Parse.Object.registerSubclass('_User', CustomUser);`

Revert ##978
@dplewis dplewis mentioned this pull request Dec 2, 2019
davimacedo pushed a commit that referenced this pull request Dec 2, 2019
After much discussion the proper way to subclass is a user is `Parse.Object.registerSubclass('_User', CustomUser);`

Revert ##978
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.

3 participants