Skip to content

Commit

Permalink
Merge pull request #2827 from ONLYOFFICE/hotfix/fix-bugs
Browse files Browse the repository at this point in the history
Hotfix/fix bugs
  • Loading branch information
maxkadushkin authored Feb 6, 2024
2 parents 9f5537d + be7fddf commit d3f289e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 47 deletions.
30 changes: 13 additions & 17 deletions apps/common/mobile/lib/controller/Plugins.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,18 @@ const PluginsController = inject('storeAppOptions')(observer(props => {
iframe;

useEffect(() => {
const onDocumentReady = () => {
Common.Notifications.on('engineCreated', api => {
api.asc_registerCallback("asc_onPluginShow", showPluginModal);
api.asc_registerCallback("asc_onPluginClose", pluginClose);
api.asc_registerCallback("asc_onPluginResize", pluginResize);
api.asc_registerCallback('asc_onPluginsInit', onPluginsInit);

if(!storeAppOptions.customization || storeAppOptions.plugins !== false) {
loadPlugins();
}
});

Common.Gateway.on('init', loadConfig);
};
Common.Notifications.on('engineCreated', api => {
api.asc_registerCallback("asc_onPluginShow", showPluginModal);
api.asc_registerCallback("asc_onPluginClose", pluginClose);
api.asc_registerCallback("asc_onPluginResize", pluginResize);
api.asc_registerCallback('asc_onPluginsInit', onPluginsInit);

if(!storeAppOptions.customization || storeAppOptions.plugins !== false) {
loadPlugins();
}
});

onDocumentReady();
Common.Gateway.on('init', loadConfig);

return () => {
const api = Common.EditorApi.get();
Expand Down Expand Up @@ -190,8 +186,8 @@ const PluginsController = inject('storeAppOptions')(observer(props => {
const parsePlugins = pluginsdata => {
let isEdit = storeAppOptions.isEdit;

if ( pluginsdata instanceof Array ) {
let lang = storeAppOptions.lang.split(/[\-_]/)[0];
if (pluginsdata instanceof Array) {
let lang = storeAppOptions.lang ? storeAppOptions.lang.split(/[\-_]/)[0] : 'en';
pluginsdata.forEach((item) => {
item.variations.forEach( (itemVar) => {
let description = itemVar.description;
Expand Down
71 changes: 42 additions & 29 deletions apps/documenteditor/mobile/src/controller/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,41 +324,53 @@ class MainController extends Component {
}
};

const _process_array = (array, fn) => {
let results = [];
return array.reduce(function(p, item) {
return p.then(function() {
return fn(item).then(function(data) {
results.push(data);
return results;
});
});
}, Promise.resolve());
const _process_array = async (array, fn) => {
const results = [];

for (const item of array) {
try {
const data = await fn(item);
results.push(data);
} catch (error) {
console.log(`Error with processing element ${item}:`, error);
continue;
}
}

return results;
};

_process_array(dep_scripts, promise_get_script)
.then ( result => {
.then(() => {
window["flat_desine"] = true;
const {t} = this.props;
let _translate = t('Main.SDK', {returnObjects:true});
for (let item in _translate) {
if (_translate.hasOwnProperty(item)) {
const str = _translate[item];
if (item[item.length-1]===' ' && str[str.length-1]!==' ')
_translate[item] += ' ';
const { t } = this.props;
const _translate = t('Main.SDK', { returnObjects: true });

Object.entries(_translate).forEach(([key, value]) => {
if (key.endsWith(' ') && !value.endsWith(' ')) {
_translate[key] = value + ' ';
}
}
["Error! Bookmark not defined",
"No table of contents entries found",
"No table of figures entries found",
"Error! Main Document Only",
"Error! Not a valid bookmark self-reference",
"Error! No text of specified style in document"].forEach(item => {
_translate[item + '.'] = _translate[item];
delete _translate[item];
});

var result = /[\?\&]fileType=\b(pdf)|(djvu|xps|oxps)\b&?/i.exec(window.location.search),
const errorMessages = [
"Error! Bookmark not defined",
"No table of contents entries found",
"No table of figures entries found",
"Error! Main Document Only",
"Error! Not a valid bookmark self-reference",
"Error! No text of specified style in document"
];

for (const item of errorMessages) {
const newItem = item + '.';

if (_translate[item]) {
_translate[newItem] = _translate[item];
delete _translate[item];
}
}

let result = /[\?\&]fileType=\b(pdf)|(djvu|xps|oxps)\b&?/i.exec(window.location.search),
isPDF = (!!result && result.length && typeof result[2] === 'string') || (!!result && result.length && typeof result[1] === 'string') && !window.isPDFForm;

const config = {
Expand Down Expand Up @@ -406,7 +418,8 @@ class MainController extends Component {
Common.Gateway.internalMessage('listenHardBack');
}, error => {
console.log('promise failed ' + error);
});
}
);
};

if ( About.developVersion() ) {
Expand Down
9 changes: 9 additions & 0 deletions apps/documenteditor/mobile/src/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ i18n.use(initReactI18next)
react: {
useSuspense: false,
},
}).then(() => {
console.log("i18next is ready");
})
.catch((error) => {
console.error("i18next initialization error:", error);
});

i18n.on('failedLoading', (lng, ns, msg) => {
console.log(msg);
});

export default i18n;
2 changes: 1 addition & 1 deletion apps/documenteditor/mobile/src/store/appOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class storeAppOptions {
this.templates = config.templates;
this.recent = config.recent;
this.createUrl = config.createUrl;
this.lang = config.lang;
this.lang = config.lang ?? 'en';
this.location = (typeof (config.location) == 'string') ? config.location.toLowerCase() : '';
this.sharingSettingsUrl = config.sharingSettingsUrl;
this.canRequestSharingSettings = config.canRequestSharingSettings;
Expand Down

0 comments on commit d3f289e

Please sign in to comment.