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

Fix some issues with saving the course structure #3648

Merged
merged 7 commits into from
Sep 25, 2020
Merged

Conversation

yscik
Copy link
Contributor

@yscik yscik commented Sep 24, 2020

This fixes a few issues caused by the blocks being updated after saving:

  • IDs not being assigned to the new blocks on first save
  • Posts having a newer version autosaved if the user doesn't save the post again
  • Post always being displayed as dirty after save

Looks like saving the post again is seamless to the user, and this is the cleanest of the possible solutions.

Changes proposed in this Pull Request

  • Add check to only update the blocks if the structure is different
  • Add check to only save the structure if it changed
  • Save the post again when the blocks were updated after the structure was saved ( = IDs were assigned to new lessons/modules)

Testing instructions

  • Create course with outline block, add lessons, customize their colors
  • Publish the post
  • Post should be marked as saved (course meta boxes might interfere with this one)
  • IDs should be saved in the post_content for the lesson blocks
  • After publishing the lessons, their style on the frontend should also look like as set in the editor
    --
  • Reloading a course post after saving should not show a Newer autosaved version is available message.

@yscik yscik requested a review from a team September 24, 2020 18:02
@yscik yscik added this to the 3.6.0 milestone Sep 24, 2020
Copy link
Contributor

@renatho renatho left a comment

Choose a reason for hiding this comment

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

It's looking good! =)

Just testing, I saw that in the first save it wasn't calling the resave.

assets/blocks/course-outline/data.js Show resolved Hide resolved
Copy link
Member

@jom jom left a comment

Choose a reason for hiding this comment

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

Nice solution!

It also gracefully recovers if I try to create a course, add a module, don't add a module title, add lessons, attempt to save draft (no course structure saved), and refresh. I can then resume where I left off.

@yscik yscik merged commit 8575c61 into master Sep 25, 2020
@yscik yscik deleted the fix/structure-sync branch September 25, 2020 15:14
@donnapep donnapep changed the title Fix structure saving Fix some issues with saving the course structure Sep 30, 2020
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