Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankbrgowda committed Oct 27, 2023
1 parent 2f3e34e commit c8bf04a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/apollo-mst/src/AnnotationFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('>>>>>>>>>>>')

Check warning on line 96 in packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts

View workflow job for this annotation

GitHub Actions / Lint and build

Unexpected console statement
console.log('>>>>>>>>>>>')

Check warning on line 97 in packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts

View workflow job for this annotation

GitHub Actions / Lint and build

Unexpected console statement
console.log('>>>>>>>>>>>')

Check warning on line 98 in packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts

View workflow job for this annotation

GitHub Actions / Lint and build

Unexpected console statement
console.log('>>>>>>>>>>>')

Check warning on line 99 in packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts

View workflow job for this annotation

GitHub Actions / Lint and build

Unexpected console statement
console.log('>>>>>>>>>>>')

Check warning on line 100 in packages/apollo-shared/src/Changes/DiscontinuousLocationStartChange.ts

View workflow job for this annotation

GitHub Actions / Lint and build

Unexpected console statement
// 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}`)
Expand Down

0 comments on commit c8bf04a

Please sign in to comment.