diff --git a/packages/ketcher-core/src/typing.d.ts b/packages/ketcher-core/src/typing.d.ts new file mode 100644 index 0000000000..8b0e52c73e --- /dev/null +++ b/packages/ketcher-core/src/typing.d.ts @@ -0,0 +1,7 @@ +import { Ketcher } from 'ketcher-core' + +declare global { + interface Window { + ketcher: Ketcher + } +} diff --git a/packages/ketcher-core/src/utilities/emitEventRequestIsFinished.ts b/packages/ketcher-core/src/utilities/emitEventRequestIsFinished.ts new file mode 100644 index 0000000000..ff76ff28b1 --- /dev/null +++ b/packages/ketcher-core/src/utilities/emitEventRequestIsFinished.ts @@ -0,0 +1,12 @@ +const REQUEST_IS_FINISHED = 'REQUEST_IS_FINISHED' + +/** + * Emit event when request is finished + * Used only for testers to prevent long delays in test cases + * Triggers on Add to canvas / Aromatize / Dearomatize + * Clean Up / Calculate CIP / Paste from clipboard + * maybe somewhere else + */ +export function emitEventRequestIsFinished(): void { + window?.ketcher?.eventBus.emit(REQUEST_IS_FINISHED) +} diff --git a/packages/ketcher-core/src/utilities/index.ts b/packages/ketcher-core/src/utilities/index.ts index c0fd2c2b3e..c312125eee 100644 --- a/packages/ketcher-core/src/utilities/index.ts +++ b/packages/ketcher-core/src/utilities/index.ts @@ -18,3 +18,4 @@ export * from './ifDef' export * from './tfx' export * from './runAsyncAction' export * from './b64toBlob' +export * from './emitEventRequestIsFinished' diff --git a/packages/ketcher-react/src/script/ui/state/shared.ts b/packages/ketcher-react/src/script/ui/state/shared.ts index 615a515468..8985066bad 100644 --- a/packages/ketcher-react/src/script/ui/state/shared.ts +++ b/packages/ketcher-react/src/script/ui/state/shared.ts @@ -21,7 +21,8 @@ import { getStereoAtomsMap, identifyStructFormat, Struct, - SupportedFormat + SupportedFormat, + emitEventRequestIsFinished } from 'ketcher-core' import { supportedSGroupTypes } from './constants' @@ -160,6 +161,8 @@ export function load(struct: Struct, options?) { } catch (err: any) { dispatch(setAnalyzingFile(false)) err && errorHandler(err.message) + } finally { + emitEventRequestIsFinished() } } }