Skip to content

Commit

Permalink
fix(link-getter): Add workaround for extra locale property in links w…
Browse files Browse the repository at this point in the history
…hen getting data from preview e

closes #81
  • Loading branch information
Khaledgarbaya committed Jun 30, 2016
1 parent 467df4b commit d677e01
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/mixins/link-getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import get from 'lodash/get'
import partial from 'lodash/partial'
import memoize from 'lodash/memoize'

let resolveAllLocales = false
/**
* Sets getters on links for a given response
* @private
* @param {Array<Entry|Asset|DeletedEntry|DeletedAsset>} items
* @param {Object} includes - Object with lists of Entry, Asset, DeletedEntry and DeletedAsset
*/
export default function mixinLinkGetters (items, includes, resolveForAllLocales) {
resolveAllLocales = resolveForAllLocales
const linkGetter = memoize(getLinksFromIncludes, memoizationResolver)
each(items, (item) => {
// TODO: workaround the preview endpoint extra locale this should be removed when
Expand Down Expand Up @@ -98,6 +100,11 @@ export default function mixinLinkGetters (items, includes, resolveForAllLocales)
function getLinksFromIncludes (field) {
var link = find(includes[field.sys.linkType], ['sys.id', field.sys.id])
if (link && link.fields) {
// TODO: workaround the preview endpoint extra locale this should be removed when
// it is fixed on the backend
if (resolveAllLocales && link.sys.locale) {
delete link.sys.locale
}
setLocalizedFieldGetters(link.fields, !!link.sys.locale)
return link
}
Expand Down

0 comments on commit d677e01

Please sign in to comment.