diff --git a/packages/apollo-mst/src/AnnotationFeature.ts b/packages/apollo-mst/src/AnnotationFeature.ts index ca4c62a9..c7016e11 100644 --- a/packages/apollo-mst/src/AnnotationFeature.ts +++ b/packages/apollo-mst/src/AnnotationFeature.ts @@ -134,7 +134,7 @@ export const AnnotationFeature = types const dl = self.discontinuousLocations if (dl && dl.length > 0 && dl[index].end !== end) { dl[index].end = end - if (index === dl.length - 1) { + if (index === 0) { self.end = end } } diff --git a/packages/apollo-shared/src/Changes/DiscontinuousLocationEndChange.ts b/packages/apollo-shared/src/Changes/DiscontinuousLocationEndChange.ts index c08e55ac..7f935f79 100644 --- a/packages/apollo-shared/src/Changes/DiscontinuousLocationEndChange.ts +++ b/packages/apollo-shared/src/Changes/DiscontinuousLocationEndChange.ts @@ -93,31 +93,31 @@ 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 === feature.discontinuousLocations.length - 1) { + if (index === 0) { feature.end = newEnd } try { - topLevelFeature.markModified('discontinuousLocations') + topLevelFeature.markModified('children') await topLevelFeature.save() } catch (error) { logger.debug?.(`*** FAILED: ${error}`) diff --git a/packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts b/packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts index cecc7b82..ece440bb 100644 --- a/packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts +++ b/packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts @@ -93,31 +93,38 @@ export class DiscontinuousLocationStartChange extends FeatureChange { 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) - } + 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) + // } feature.discontinuousLocations[index].start = newStart if (index === 0) { feature.start = newStart } + logger.debug?.(`I'm here ${index}`) + try { - topLevelFeature.markModified('discontinuousLocations') + topLevelFeature.markModified('children') await topLevelFeature.save() } catch (error) { logger.debug?.(`*** FAILED: ${error}`)