[all] refactoring
This commit is contained in:
parent
eee017bb0b
commit
b4d1d247ed
|
@ -4,20 +4,25 @@ import { f7 } from 'framework7-react';
|
|||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const ErrorController = inject('storeAppOptions')(({storeAppOptions, LoadingDocument}) => {
|
||||
const {t} = useTranslation();
|
||||
const _t = t("Error", { returnObjects: true });
|
||||
|
||||
useEffect(() => {
|
||||
Common.Notifications.on('engineCreated', (api) => {
|
||||
api.asc_registerCallback('asc_onError', onError);
|
||||
});
|
||||
const on_engine_created = k => { k.asc_registerCallback('asc_onError', onError); };
|
||||
|
||||
const api = Common.EditorApi.get();
|
||||
if ( !api ) Common.Notifications.on('engineCreated', on_engine_created);
|
||||
else on_engine_created(api);
|
||||
|
||||
return () => {
|
||||
const api = Common.EditorApi.get();
|
||||
if ( api ) api.asc_unregisterCallback('asc_onError', onError);
|
||||
|
||||
Common.Notifications.off('engineCreated', on_engine_created);
|
||||
}
|
||||
});
|
||||
|
||||
const onError = (id, level, errData) => {
|
||||
const {t} = useTranslation();
|
||||
const _t = t("Error", { returnObjects: true });
|
||||
|
||||
if (id === Asc.c_oAscError.ID.LoadingScriptError) {
|
||||
f7.notification.create({
|
||||
title: _t.criticalErrorTitle,
|
||||
|
|
|
@ -4,20 +4,25 @@ import { f7 } from 'framework7-react';
|
|||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const ErrorController = inject('storeAppOptions')(({storeAppOptions, LoadingDocument}) => {
|
||||
const {t} = useTranslation();
|
||||
const _t = t("Error", { returnObjects: true });
|
||||
|
||||
useEffect(() => {
|
||||
Common.Notifications.on('engineCreated', (api) => {
|
||||
api.asc_registerCallback('asc_onError', onError);
|
||||
});
|
||||
const on_engine_created = k => { k.asc_registerCallback('asc_onError', onError); };
|
||||
|
||||
const api = Common.EditorApi.get();
|
||||
if ( !api ) Common.Notifications.on('engineCreated', on_engine_created);
|
||||
else on_engine_created(api);
|
||||
|
||||
return () => {
|
||||
const api = Common.EditorApi.get();
|
||||
if ( api ) api.asc_unregisterCallback('asc_onError', onError);
|
||||
|
||||
Common.Notifications.off('engineCreated', on_engine_created);
|
||||
}
|
||||
});
|
||||
|
||||
const onError = (id, level, errData) => {
|
||||
const {t} = useTranslation();
|
||||
const _t = t("Error", { returnObjects: true });
|
||||
|
||||
if (id === Asc.c_oAscError.ID.LoadingScriptError) {
|
||||
f7.notification.create({
|
||||
title: _t.criticalErrorTitle,
|
||||
|
|
|
@ -4,20 +4,24 @@ import { f7 } from 'framework7-react';
|
|||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const ErrorController = inject('storeAppOptions')(({storeAppOptions, LoadingDocument}) => {
|
||||
const {t} = useTranslation();
|
||||
const _t = t("Error", { returnObjects: true });
|
||||
|
||||
useEffect(() => {
|
||||
Common.Notifications.on('engineCreated', (api) => {
|
||||
api.asc_registerCallback('asc_onError', onError);
|
||||
});
|
||||
const on_engine_created = k => { k.asc_registerCallback('asc_onError', onError); };
|
||||
|
||||
const api = Common.EditorApi.get();
|
||||
if ( !api ) Common.Notifications.on('engineCreated', on_engine_created);
|
||||
else on_engine_created(api);
|
||||
|
||||
return () => {
|
||||
const api = Common.EditorApi.get();
|
||||
if ( api ) api.asc_unregisterCallback('asc_onError', onError);
|
||||
|
||||
Common.Notifications.off('engineCreated', on_engine_created);
|
||||
}
|
||||
});
|
||||
|
||||
const onError = (id, level, errData) => {
|
||||
const {t} = useTranslation();
|
||||
const _t = t("Error", { returnObjects: true });
|
||||
const api = Common.EditorApi.get();
|
||||
|
||||
if (id === Asc.c_oAscError.ID.LoadingScriptError) {
|
||||
|
|
Loading…
Reference in a new issue