Skip to content

Commit

Permalink
Properly update state when saving track to Apollo (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjstevens authored Sep 20, 2024
1 parent 096c318 commit ea5f56e
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 {
trackId: string
type: string
}
const newTrackId = trackId.slice(
0,
trackId.length - sessionTrackIdentifier.length,
)
trackConfigSnapshot = {
const newTrackConfigSnapshot = {
...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)
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
jbrowse.addTrackConf(newTrackConfigSnapshot)
},
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)
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
jbrowse.deleteTrackConf(conf)
},
icon: SaveIcon,
},
Expand Down

0 comments on commit ea5f56e

Please sign in to comment.