Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
πŸ› Fixed unnecessary "Are you sure you want to leave?" modals
Browse files Browse the repository at this point in the history
no issue
- if a post was saved before the body content was edited you would get stuck with an "Are you sure you want to leave?" modal even though you had already saved
- the editor saw the post as being in a dirty state because the `mobiledoc` and `scratch` value were null but after saving the `mobiledoc` value was set to an blank mobiledoc object as returned by the API
- updated the `post` model save method to reset the `scratch` value if the returned `mobiledoc` no longer matches
  • Loading branch information
kevinansfield committed Mar 15, 2019
1 parent e551488 commit 6b01266
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/models/post.js
Expand Up @@ -190,6 +190,19 @@ export default Model.extend(Comparable, ValidationEngine, {
}
}),

save() {
// ensure that our scratch value used in the editor is kept in sync with
// what we get back from the API after saving - avoids issues which cause
// the editor to see a saved post as dirty and show a "are you sure" modal
return this._super(...arguments).then(() => {
if (JSON.stringify(this.mobiledoc) !== JSON.stringify(this.scratch)) {
this.set('scratch', this.mobiledoc);
}

return this;
});
},

_getPublishedAtBlogTZ() {
let publishedAtUTC = this.publishedAtUTC;
let publishedAtBlogDate = this.publishedAtBlogDate;
Expand Down

0 comments on commit 6b01266

Please sign in to comment.