Skip to content

Commit 0f2fe5a

Browse files
committed
Tolerate missing state in download logic.
1 parent c83fb6f commit 0f2fe5a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • src/content-handlers/iiif/extensions/uv-openseadragon-extension

src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,12 @@ export default class OpenSeadragonExtension extends BaseExtension<Config> {
614614
// todo: can this be added to store?
615615
const paged = this.isPagingSettingEnabled();
616616

617-
const { downloadDialogueOpen, dialogueTriggerButton } =
618-
this.store.getState() as OpenSeadragonExtensionState;
617+
// Try to initialize using the stored state; exit early if the state is not ready yet:
618+
const state: null | OpenSeadragonExtensionState = this.store.getState();
619+
if (state === null) {
620+
return;
621+
}
622+
const { downloadDialogueOpen, dialogueTriggerButton } = state as OpenSeadragonExtensionState;
619623

620624
// todo: can the overlay visibility be added to the store?
621625
if (downloadDialogueOpen) {

0 commit comments

Comments
 (0)