diff --git a/apps/documenteditor/mobile/src/controller/LongActions.jsx b/apps/documenteditor/mobile/src/controller/LongActions.jsx index de95424c1..28b2ad789 100644 --- a/apps/documenteditor/mobile/src/controller/LongActions.jsx +++ b/apps/documenteditor/mobile/src/controller/LongActions.jsx @@ -25,11 +25,16 @@ const LongActionsController = inject('storeAppOptions')(({storeAppOptions}) => { }; useEffect( () => { - Common.Notifications.on('engineCreated', (api) => { + const on_engine_created = api => { api.asc_registerCallback('asc_onStartAction', onLongActionBegin); api.asc_registerCallback('asc_onEndAction', onLongActionEnd); api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); - }); + }; + + const api = Common.EditorApi.get(); + if(!api) Common.Notifications.on('engineCreated', on_engine_created); + else on_engine_created(api); + Common.Notifications.on('preloader:endAction', onLongActionEnd); Common.Notifications.on('preloader:beginAction', onLongActionBegin); Common.Notifications.on('preloader:close', closePreloader); @@ -41,7 +46,8 @@ const LongActionsController = inject('storeAppOptions')(({storeAppOptions}) => { api.asc_unregisterCallback('asc_onEndAction', onLongActionEnd); api.asc_unregisterCallback('asc_onOpenDocumentProgress', onOpenDocument); } - + + Common.Notifications.off('engineCreated', on_engine_created); Common.Notifications.off('preloader:endAction', onLongActionEnd); Common.Notifications.off('preloader:beginAction', onLongActionBegin); Common.Notifications.off('preloader:close', closePreloader);