From ea5f56ed556de4b0630ec1454ed333e0572997df Mon Sep 17 00:00:00 2001 From: Garrett Stevens Date: Fri, 20 Sep 2024 13:47:19 -0600 Subject: [PATCH] Properly update state when saving track to Apollo (#445) --- .../jbrowse-plugin-apollo/src/session/session.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/jbrowse-plugin-apollo/src/session/session.ts b/packages/jbrowse-plugin-apollo/src/session/session.ts index 119053103..4e56759af 100644 --- a/packages/jbrowse-plugin-apollo/src/session/session.ts +++ b/packages/jbrowse-plugin-apollo/src/session/session.ts @@ -323,7 +323,7 @@ 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 } @@ -331,7 +331,7 @@ export function extendSession( 0, trackId.length - sessionTrackIdentifier.length, ) - trackConfigSnapshot = { + const newTrackConfigSnapshot = { ...trackConfigSnapshot, trackId: newTrackId, } @@ -346,7 +346,7 @@ export function extendSession( ...filteredConfig, tracks: filteredConfig?.tracks && [ ...filteredConfig.tracks, - trackConfigSnapshot, + newTrackConfigSnapshot, ], }, }) @@ -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, }, @@ -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, },