Skip to content

Commit

Permalink
Properly update state when saving track to Apollo
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjstevens committed Sep 20, 2024
1 parent 096c318 commit d46d129
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/jbrowse-plugin-apollo/src/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,15 @@ export function extendSession(
if (Object.keys(filteredConfig).length === 0) {
filteredConfig = undefined
}
let trackConfigSnapshot = getSnapshot(conf) as {
const trackConfigSnapshot = getSnapshot(conf) as {

Check warning on line 326 in packages/jbrowse-plugin-apollo/src/session/session.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/session/session.ts#L326

Added line #L326 was not covered by tests
trackId: string
type: string
}
const newTrackId = trackId.slice(
0,
trackId.length - sessionTrackIdentifier.length,
)
trackConfigSnapshot = {
const newTrackConfigSnapshot = {

Check warning on line 334 in packages/jbrowse-plugin-apollo/src/session/session.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/session/session.ts#L334

Added line #L334 was not covered by tests
...trackConfigSnapshot,
trackId: newTrackId,
}
Expand All @@ -346,7 +346,7 @@ export function extendSession(
...filteredConfig,
tracks: filteredConfig?.tracks && [
...filteredConfig.tracks,
trackConfigSnapshot,
newTrackConfigSnapshot,
],
},
})
Expand All @@ -357,6 +357,10 @@ export function extendSession(
const { notify } = self as unknown as AbstractSessionModel
notify('Track added', 'success')
}
// @ts-expect-error This method is missing in the JB types
self.deleteTrackConf(conf)

Check warning on line 361 in packages/jbrowse-plugin-apollo/src/session/session.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/session/session.ts#L361

Added line #L361 was not covered by tests
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
jbrowse.addTrackConf(newTrackConfigSnapshot)

Check warning on line 363 in packages/jbrowse-plugin-apollo/src/session/session.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/session/session.ts#L363

Added line #L363 was not covered by tests
},
icon: SaveIcon,
},
Expand Down Expand Up @@ -396,6 +400,10 @@ export function extendSession(
const { notify } = self as unknown as AbstractSessionModel
notify('Track removed', 'success')
}
// @ts-expect-error This method is missing in the JB types
self.deleteTrackConf(conf)

Check warning on line 404 in packages/jbrowse-plugin-apollo/src/session/session.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/session/session.ts#L404

Added line #L404 was not covered by tests
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
jbrowse.deleteTrackConf(conf)

Check warning on line 406 in packages/jbrowse-plugin-apollo/src/session/session.ts

View check run for this annotation

Codecov / codecov/patch

packages/jbrowse-plugin-apollo/src/session/session.ts#L406

Added line #L406 was not covered by tests
},
icon: SaveIcon,
},
Expand Down

0 comments on commit d46d129

Please sign in to comment.