Skip to content

Commit e2647a7

Browse files
committed
galleryView option automatically initialized state gallery
1 parent 647843c commit e2647a7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/app/extensions/state-gallery/manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function listImages(data: StateGalleryData | undefined, byCategory: boolean = fa
231231
const assemblies = data?.assembly;
232232
for (const assemblyId in assemblies) {
233233
for (const img of assemblies[assemblyId].image ?? []) {
234-
out.push({ ...img, category: 'Entry', ...ImageTitles.assembly(img, { assemblyId }) });
234+
out.push({ ...img, category: 'Assemblies', ...ImageTitles.assembly(img, { assemblyId }) });
235235
}
236236
}
237237
// Entity

src/app/viewer.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { CustomEvents } from './custom-events';
4646
import { PDBeDomainAnnotations } from './domain-annotations/behavior';
4747
import * as Foldseek from './extensions/foldseek';
4848
import { StateGallery, StateGalleryExtensionFunctions } from './extensions/state-gallery/behavior';
49+
import { StateGalleryManager } from './extensions/state-gallery/manager';
4950
import { StateGalleryControls } from './extensions/state-gallery/ui';
5051
import { AlphafoldView, LigandView, LoadParams, ModelServerRequest, PDBeVolumes, QueryHelper, QueryParam, StructureComponentTags, Tags, addDefaults, applyOverpaint, getComponentTypeFromTags, getStructureUrl, normalizeColor, runWithProgressMessage } from './helpers';
5152
import { PluginCustomState } from './plugin-custom-state';
@@ -204,14 +205,21 @@ export class PDBeMolstarPlugin {
204205
}
205206

206207
// Create/ Initialise Plugin
207-
const onBeforeUIRender = (plugin: PluginContext) => {
208+
const onBeforeUIRender = async (plugin: PluginContext) => {
208209
// This needs to run after the plugin is created but before the UI is rendered
209210
PluginCustomState(plugin).initParams = { ...this.initParams };
210211
PluginCustomState(plugin).events = {
211212
segmentUpdate: this._ev<boolean>(),
212213
superpositionInit: this._ev<boolean>(),
213214
isBusy: this._ev<boolean>(),
214215
};
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+
}
215223
};
216224

217225
if (Array.isArray(target)) {
@@ -258,6 +266,8 @@ export class PDBeMolstarPlugin {
258266
// Initialise superposition
259267
initSuperposition(this.plugin, this.events.loadComplete);
260268

269+
} else if (this.initParams.galleryView) {
270+
// Do nothing, StateGalleryManager initialized in onBeforeUIRender
261271
} else {
262272
// Load Molecule CIF or coordQuery and Parse
263273
const dataSource = this.getMoleculeSrcUrl();

0 commit comments

Comments
 (0)