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