-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Framework: add schema for posts #3487
Conversation
@@ -114,7 +147,7 @@ describe( 'reducer', () => { | |||
} | |||
} ); | |||
} ); | |||
it( 'never persists state because this is not implemented', () => { | |||
it( 'never persists state', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we not persist this? Or at the very least, we could repopulate the mapping from the set of loaded posts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can persist this provided that the selectors can handle items and sitePosts potentially not being in sync. This is the same data consistency issue we saw in #3357, though this doesn't happen to trigger an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to take a bit of time to play with memoized selectors: http://redux.js.org/docs/recipes/ComputingDerivedData.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created #3522 to address this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
posts.sitePosts were removed in #3602
f7b5a9b
to
9e2f544
Compare
@aduth I think |
@@ -205,7 +238,7 @@ describe( 'reducer', () => { | |||
} ); | |||
} ); | |||
|
|||
it( 'never persists state because this is not implemented', () => { | |||
it( 'never persists state', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were these purposeful changes or did they just come in from your last PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, probably bad copy pasta. I'll clean this up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, or is it that these are things that should not be persisted (rather than just haven't been implemented yet), so the previous language wasn't quite accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to persist queries in the future, but not the other temporary fetch state, so posts/siteRequests and posts/queriesLastPage should not be persisted, while posts/queries will be in the future.
This looks good to me... had one question about changes to the description, and I'm also not sure about the schema being so restrictive as to disallow additionalProperties. I think that's probably a bigger discussion though and should not hold this up. 👍 |
Thanks for the reviews! I'll merge this in tomorrow morning. |
This PR adds a schema for posts/items so we can avoid data shape changes as described in #3101.
posts/siteRequests and posts/queriesLastPage are not persisted, since this is mostly transient data.
Testing Instructions
ENABLE_FEATURES=persist-redux make run
calypso:state
To Validate that we can't get into an inconsistent state:
itemsSchema
, likefoo
:cc @aduth @rralian @artpi @retrofox @mtias