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

Add post autosave for title generation and content resizing. #626

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

iamdharmesh
Copy link
Member

Description of the Change

PR adds autosave functionality for post title generation and content resizing when the post is not dirty (meaning it doesn't contain any other changes). This addition aims to keep a record of every small change made by classifAI, and the editor can restore previous post content by utilizing WordPress core's revision functionality.

Note: Autosave has not been added to excerpt generation yet, as it directly replaces the post excerpt before manual human review.

Closes #590

How to test the Change

  1. Create/Edit any post.
  2. Click "Generate titles" without making any changes to the post.
  3. Verify that the post title value is updated and the post is also saved.
  4. Make changes in post content.
  5. Click "Generate titles".
  6. Verify that it only updates the title value without saving the post.
  7. Verify this with the classic editor.
  8. Test the same with Resizing content.

Changelog Entry

Added - Post autosave for title generation and content resizing.

Credits

Props @jeffpaul @iamdharmesh

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@iamdharmesh iamdharmesh self-assigned this Nov 28, 2023
@iamdharmesh iamdharmesh marked this pull request as ready for review November 28, 2023 10:59
@jeffpaul jeffpaul added this to the 2.6.0 milestone Nov 28, 2023
@dkotter dkotter modified the milestones: 2.6.0, 2.5.0 Nov 28, 2023

// If no edited values in post trigger save.
if ( ! isDirty ) {
await dispatch( 'core' ).saveEditedEntityRecord(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this trigger an autosave or a normal save? Or maybe in Gutenberg it's the same thing? I'm seeing the saveEntityRecord function has an isAutosave option but don't see the same in this function, so just want to ensure we're using the right thing here

Copy link
Member Author

Choose a reason for hiding this comment

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

Does this trigger an autosave or a normal save?

@dkotter this is a normal save. As Gutenberg provides information on whether the post is dirty or not, we can make sure that the post doesn't contain any other changes than our changes, we are good to trigger the normal save here. Please let me know if you think we should trigger autosave here instead of the normal save.

Or maybe in Gutenberg it's the same thing?

Normal save is different from autosave in Gutenberg as well, like the classic editor.

@dkotter dkotter requested a review from berkod November 29, 2023 17:14
@jeffpaul jeffpaul mentioned this pull request Dec 6, 2023
22 tasks
@dkotter dkotter merged commit 1e4d2a0 into develop Dec 7, 2023
13 checks passed
@dkotter dkotter deleted the enhancement/590 branch December 7, 2023 17:10
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.

Preserve existing data & provide rollbacks
4 participants