Skip to content

Commit

Permalink
Fixed "html" being marked as changed if mobiledoc or html was not cha…
Browse files Browse the repository at this point in the history
…nged

no issue

- if you html is NULL e.g. you create a draft post, we always set "html" to ""
- this get's marked as changed
- !this.get('html') was added for the 2.0 migration, because some posts had custom mobiledoc, but no html value
  • Loading branch information
kirrg001 committed Feb 23, 2019
1 parent 641b67e commit 58153ad
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/server/models/post.js
Expand Up @@ -342,8 +342,9 @@ Post = ghostBookshelf.Model.extend({
this.set('mobiledoc', JSON.stringify(converters.mobiledocConverter.blankStructure()));
}

// render mobiledoc to HTML
if (this.hasChanged('mobiledoc') || !this.get('html')) {
// CASE: mobiledoc has changed, generate html
// CASE: html is null, but mobiledoc exists (only important for migrations & importing)
if (this.hasChanged('mobiledoc') || (!this.get('html') && (options.migrating || options.importing))) {
try {
this.set('html', converters.mobiledocConverter.render(JSON.parse(this.get('mobiledoc'))));
} catch (err) {
Expand Down

0 comments on commit 58153ad

Please sign in to comment.