diff --git a/packages/apollo-shared/src/Changes/DiscontinuousLocationEndChange.ts b/packages/apollo-shared/src/Changes/DiscontinuousLocationEndChange.ts index 7f935f79..b6155365 100644 --- a/packages/apollo-shared/src/Changes/DiscontinuousLocationEndChange.ts +++ b/packages/apollo-shared/src/Changes/DiscontinuousLocationEndChange.ts @@ -93,24 +93,24 @@ export class DiscontinuousLocationEndChange extends FeatureChange { logger.error(errMsg) throw new Error(errMsg) } - // const oldEnd = feature.discontinuousLocations[index].end - // if (oldEnd !== expectedOldEnd) { - // const errMsg = `Location's current end value ${oldEnd} doesn't match with expected value ${expectedOldEnd}` - // logger.error(errMsg) - // throw new Error(errMsg) - // } - // const { start } = feature.discontinuousLocations[index] - // if (newEnd <= start) { - // const errMsg = `location end (${newEnd}) can't be smaller than location start (${start})` - // logger.error(errMsg) - // throw new Error(errMsg) - // } - // const nextLocation = feature.discontinuousLocations[index + 1] - // if (nextLocation && newEnd >= nextLocation.start) { - // const errMsg = `Location end (${newEnd}) can't be larger than the next location's start (${nextLocation.start})` - // logger.error(errMsg) - // throw new Error(errMsg) - // } + const oldEnd = feature.discontinuousLocations[index].end + if (oldEnd !== expectedOldEnd) { + const errMsg = `Location's current end value ${oldEnd} doesn't match with expected value ${expectedOldEnd}` + logger.error(errMsg) + throw new Error(errMsg) + } + const { start } = feature.discontinuousLocations[index] + if (newEnd <= start) { + const errMsg = `location end (${newEnd}) can't be smaller than location start (${start})` + logger.error(errMsg) + throw new Error(errMsg) + } + const nextLocation = feature.discontinuousLocations[index + 1] + if (nextLocation && newEnd >= nextLocation.start) { + const errMsg = `Location end (${newEnd}) can't be larger than the next location's start (${nextLocation.start})` + logger.error(errMsg) + throw new Error(errMsg) + } feature.discontinuousLocations[index].end = newEnd if (index === 0) { feature.end = newEnd diff --git a/packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts b/packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts index ece440bb..b052e52d 100644 --- a/packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts +++ b/packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts @@ -93,36 +93,30 @@ export class DiscontinuousLocationStartChange extends FeatureChange { logger.error(errMsg) throw new Error(errMsg) } - console.log('>>>>>>>>>>>') - console.log('>>>>>>>>>>>') - console.log('>>>>>>>>>>>') - console.log('>>>>>>>>>>>') - console.log('>>>>>>>>>>>') - // const oldStart = feature.discontinuousLocations[index].start - // if (oldStart !== expectedOldStart) { - // const errMsg = `Location's current start value ${oldStart} doesn't match with expected value ${expectedOldStart}` - // logger.error(errMsg) - // throw new Error(errMsg) - // } - // const { end } = feature.discontinuousLocations[index] - // if (newStart >= end) { - // const errMsg = `location start (${newStart}) can't be larger than location end (${end})` - // logger.error(errMsg) - // throw new Error(errMsg) - // } - // const previousLocation = feature.discontinuousLocations[index - 1] - // if (previousLocation && newStart <= previousLocation.end) { - // const errMsg = `Location start (${newStart}) can't be larger than the previous location's end (${previousLocation.end})` - // logger.error(errMsg) - // throw new Error(errMsg) - // } + + const oldStart = feature.discontinuousLocations[index].start + if (oldStart !== expectedOldStart) { + const errMsg = `Location's current start value ${oldStart} doesn't match with expected value ${expectedOldStart}` + logger.error(errMsg) + throw new Error(errMsg) + } + const { end } = feature.discontinuousLocations[index] + if (newStart >= end) { + const errMsg = `location start (${newStart}) can't be larger than location end (${end})` + logger.error(errMsg) + throw new Error(errMsg) + } + const previousLocation = feature.discontinuousLocations[index - 1] + if (previousLocation && newStart <= previousLocation.end) { + const errMsg = `Location start (${newStart}) can't be larger than the previous location's end (${previousLocation.end})` + logger.error(errMsg) + throw new Error(errMsg) + } feature.discontinuousLocations[index].start = newStart if (index === 0) { feature.start = newStart } - logger.debug?.(`I'm here ${index}`) - try { topLevelFeature.markModified('children') await topLevelFeature.save()