@@ -46,6 +46,7 @@ import { CustomEvents } from './custom-events';
46
46
import { PDBeDomainAnnotations } from './domain-annotations/behavior' ;
47
47
import * as Foldseek from './extensions/foldseek' ;
48
48
import { StateGallery , StateGalleryExtensionFunctions } from './extensions/state-gallery/behavior' ;
49
+ import { StateGalleryManager } from './extensions/state-gallery/manager' ;
49
50
import { StateGalleryControls } from './extensions/state-gallery/ui' ;
50
51
import { AlphafoldView , LigandView , LoadParams , ModelServerRequest , PDBeVolumes , QueryHelper , QueryParam , StructureComponentTags , Tags , addDefaults , applyOverpaint , getComponentTypeFromTags , getStructureUrl , normalizeColor , runWithProgressMessage } from './helpers' ;
51
52
import { PluginCustomState } from './plugin-custom-state' ;
@@ -204,14 +205,21 @@ export class PDBeMolstarPlugin {
204
205
}
205
206
206
207
// Create/ Initialise Plugin
207
- const onBeforeUIRender = ( plugin : PluginContext ) => {
208
+ const onBeforeUIRender = async ( plugin : PluginContext ) => {
208
209
// This needs to run after the plugin is created but before the UI is rendered
209
210
PluginCustomState ( plugin ) . initParams = { ...this . initParams } ;
210
211
PluginCustomState ( plugin ) . events = {
211
212
segmentUpdate : this . _ev < boolean > ( ) ,
212
213
superpositionInit : this . _ev < boolean > ( ) ,
213
214
isBusy : this . _ev < boolean > ( ) ,
214
215
} ;
216
+ if ( this . initParams . galleryView && this . initParams . moleculeId ) {
217
+ try {
218
+ await StateGalleryManager . create ( plugin , this . initParams . moleculeId ) ; // sets extension custom state
219
+ } catch ( err ) {
220
+ console . error ( `Failed to initialize StateGalleryManager for entry ${ this . initParams . moleculeId } .\n${ err } ` ) ;
221
+ }
222
+ }
215
223
} ;
216
224
217
225
if ( Array . isArray ( target ) ) {
@@ -258,6 +266,8 @@ export class PDBeMolstarPlugin {
258
266
// Initialise superposition
259
267
initSuperposition ( this . plugin , this . events . loadComplete ) ;
260
268
269
+ } else if ( this . initParams . galleryView ) {
270
+ // Do nothing, StateGalleryManager initialized in onBeforeUIRender
261
271
} else {
262
272
// Load Molecule CIF or coordQuery and Parse
263
273
const dataSource = this . getMoleculeSrcUrl ( ) ;
0 commit comments