Skip to content

Commit

Permalink
Keep local file checks on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjstevens committed Dec 14, 2024
1 parent d0e3c7c commit 85527e0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/apollo-common/src/Change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface ClientDataStore {
assemblyId: string,
backendDriverType?: BackendDriverType,
): ApolloAssemblyI
clearCheckResults(): void
}

export type SerializedChange = SerializedOperation
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-shared/src/Checks/CDSCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function checkMRNA(
refSeq: refSeq.toString(),
start: max,
end: max,
message: `Feature "${_id}" is missing a stop codon`,
message: `Missing stop codon`,
})
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Region, getSession } from '@jbrowse/core/util'

import { SubmitOpts } from '../ChangeManager'
import { BackendDriver, RefNameAliases } from './BackendDriver'
import { checkFeatures } from '../util'

export class InMemoryFileDriver extends BackendDriver {
async getFeatures(): Promise<
Expand Down Expand Up @@ -84,6 +85,15 @@ export class InMemoryFileDriver extends BackendDriver {
_change: Change | AssemblySpecificChange,
_opts: SubmitOpts = {},
) {
const { clientStore } = this
const { assemblies } = clientStore
clientStore.clearCheckResults()
for (const [, assembly] of assemblies) {
if (assembly.backendDriverType === 'InMemoryFileDriver') {
const checkResults = await checkFeatures(assembly)
clientStore.addCheckResults(checkResults)
}
}
return new ValidationResultSet()
}

Expand Down
3 changes: 3 additions & 0 deletions packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ export function clientDataStoreFactory(
deleteCheckResult(checkResultId: string) {
self.checkResults.delete(checkResultId)
},
clearCheckResults() {
self.checkResults.clear()
},
}))
.volatile((self) => ({
changeManager: new ChangeManager(self as unknown as ClientDataStoreType),
Expand Down
17 changes: 16 additions & 1 deletion packages/jbrowse-plugin-apollo/src/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export function extendSession(
}
})
return types.snapshotProcessor(sm, {
postProcessor(snap: SnapshotOut<typeof sm>) {
postProcessor(snap: SnapshotOut<typeof sm>, node) {
snap.apolloSelectedFeature = undefined
const assemblies = Object.fromEntries(
Object.entries(snap.apolloDataStore.assemblies).filter(
Expand All @@ -440,6 +440,21 @@ export function extendSession(
assemblies,
checkResults: {},
}
if (!node) {
return snap
}
const { apolloDataStore } = node
const { checkResults } = apolloDataStore
for (const [, cr] of checkResults) {
const [feature] = cr.ids
if (!feature) {
continue
}
const assembly = apolloDataStore.assemblies.get(feature.assemblyId)
if (assembly && assembly.backendDriverType === 'InMemoryFileDriver') {
snap.apolloDataStore.checkResults[cr._id] = getSnapshot(cr)
}
}
return snap
},
})
Expand Down

0 comments on commit 85527e0

Please sign in to comment.