Skip to content

Commit

Permalink
fix: respect shouldPublish when it is set to false
Browse files Browse the repository at this point in the history
  • Loading branch information
TimBeyer committed Jan 2, 2019
1 parent 0db8789 commit 721bd05
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/lib/action/entry-derive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import EntryDerive from '../interfaces/entry-derive'
import { APIAction } from './action'
import { OfflineAPI } from '../offline-api'
import { ContentType } from '../entities/content-type'
import isDefined from '../utils/is-defined'

import Entry from '../entities/entry'
import * as _ from 'lodash'

Expand All @@ -22,7 +24,7 @@ class EntryDeriveAction extends APIAction {
this.derivedContentType = entryDerivation.derivedContentType
this.deriveEntryForLocale = entryDerivation.deriveEntryForLocale
this.identityKey = entryDerivation.identityKey
this.shouldPublish = entryDerivation.shouldPublish || true
this.shouldPublish = isDefined(entryDerivation.shouldPublish) ? entryDerivation.shouldPublish : true
}

async applyTo (api: OfflineAPI) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/entities/entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cloneDeep } from 'lodash'
import APIEntry from '../interfaces/api-entry'
import { isNullOrUndefined } from 'util'
import isDefined from '../utils/is-defined'

class Entry {
private _id: string
Expand Down Expand Up @@ -64,7 +64,7 @@ class Entry {
}

get isPublished () {
return !isNullOrUndefined(this._publishedVersion)
return isDefined(this._publishedVersion)
}

get publishedVersion () {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/utils/is-defined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function isDefined<T> (value: T | undefined | null): value is T {
return value !== undefined && value !== null
}

0 comments on commit 721bd05

Please sign in to comment.