Skip to content

Commit

Permalink
update alias on client session
Browse files Browse the repository at this point in the history
  • Loading branch information
shashankbrgowda committed Aug 6, 2024
1 parent f43c227 commit 400f57c
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion packages/apollo-shared/src/Changes/AddRefSeqAliasesChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
SerializedChange,
ServerDataStore,
} from '@apollo-annotation/common'
import { getSession } from '@jbrowse/core/util'

export interface SerializedRefSeqAliases {
refName: string
Expand All @@ -31,7 +32,33 @@ export class AddRefSeqAliasesChange extends AssemblySpecificChange {
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
async executeOnClient(_clientDataStore: ClientDataStore) {}
executeOnClient(clientDataStore: ClientDataStore) {
const { assemblyManager } = getSession(clientDataStore)
const assembly = assemblyManager.get(this.assembly)
if (!assembly) {
throw new Error(`assembly ${this.assembly} not found`)
}
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
const sessionAliases: { [x: string]: string | undefined } | undefined =
assembly.refNameAliases
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
const sessionLCAliases: { [x: string]: string | undefined } | undefined =
assembly.lowerCaseRefNameAliases

if (!sessionAliases || !sessionLCAliases) {
throw new Error('Session refNameAliases not found in assembly')
}

for (const refSeqAlias of this.refSeqAliases) {
const { aliases, refName } = refSeqAlias
for (const alias of aliases) {
sessionAliases[alias] = refName
sessionLCAliases[alias.toLowerCase()] = refName
}
}
assembly.setRefNameAliases(sessionAliases, sessionLCAliases)
return Promise.resolve()
}

getInverse(): Change {
throw new Error('Method not implemented.')
Expand Down

0 comments on commit 400f57c

Please sign in to comment.