Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Pages: Add "Set as posts page" action #67650
Pages: Add "Set as posts page" action #67650
Changes from 9 commits
57ec70f
fbc91d7
d42e0c1
4a90867
4b29bcb
d892300
f68a189
4ac3a3c
2cc8058
61c7d48
711f65c
30a7f2a
7a775e4
8ef850c
bc1b218
2cfd817
f60fa36
35cea15
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 don't know much about this, but wouldn't just
saveEntityRecord
work correctly?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 also don't know much about these functions, but I believe ideally just
saveEditedEntityRecord
should be required, as that callssaveEntityRecord
. However, usingsaveEntityRecord
on its own does seem to work successfully, so maybe we could just use that function in these cases.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 looked through the codebase some more at other uses of these functions, and
saveEntityRecord
is often used on its own (rather thansaveEditedEntityRecord
as I expected), so I've removedsaveEditedEntityRecord
from both the "Set as homepage" and "Set as posts page" actions. They still work fine so I think this is a nice refactor!Commit with these changes is here: 2cfd817.
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.
Is this exception error actually possible? Because
saveEntityRecord
doesn't seem to throw any exceptions by default.https://github.com/WordPress/gutenberg/blob/add/more-homepage-actions/packages/core-data/README.md#saveentityrecord
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 think it's nice to have the
catch
block anyway, to catch any other errors (like a network error maybe). But I completely see your point, I don't thinksaveEntityRecord
throws any exceptions.