[desktop] fix bug 59925

This commit is contained in:
Maxim Kadushkin 2022-12-11 12:12:52 +03:00
parent a350d98f8f
commit 2c15f82cb9
3 changed files with 56 additions and 55 deletions

View file

@ -238,42 +238,44 @@ define([
} }
const _checkHelpAvailable = function () { const _checkHelpAvailable = function () {
const curr_lang = Common.Locale.getCurrentLanguage(); const me = this;
let url = 'resources/help/' + curr_lang; const build_url = function (arg1, arg2, arg3) {
fetch(url + '/Contents.json').then(function (response) { const re_ls = /\/$/;
if ( response.ok ) { return (re_ls.test(arg1) ? arg1 : arg1 + '/') + arg2 + arg3;
/* local help avail */ }
helpUrl = url;
} else fetch(build_url('resources/help/', Common.Locale.getDefaultLanguage(), '/Contents.json'))
if ( curr_lang != Common.Locale.getDefaultLanguage() ) { .then(function (response) {
url = 'resources/help/' + Common.Locale.getDefaultLanguage(); if ( response.ok ) {
fetch(url + '/Contents.json').then(function (response){ /* local help avail */
if ( response.ok ) { fetch(build_url('resources/help/', Common.Locale.getCurrentLanguage(), '/Contents.json'))
/* local help avail. def lang */ .then(function (response){
helpUrl = url; if ( response.ok )
} else helpUrl = build_url('resources/help/', Common.Locale.getCurrentLanguage(), '');
if ( this.helpUrl() ) { })
url = this.helpUrl() + curr_lang; .catch(function (e) {
fetch(url + '/Contents.json').then(function (response){ helpUrl = build_url('resources/help/', Common.Locale.getDefaultLanguage(), '');
})
}
}).catch(function (e) {
if ( me.helpUrl() ) {
fetch(build_url(me.helpUrl(), Common.Locale.getDefaultLanguage(), '/Contents.json'))
.then(function (response) {
if ( response.ok ) { if ( response.ok ) {
/* remote help avail */ /* remote help avail */
helpUrl = url; fetch(build_url(me.helpUrl(), Common.Locale.getCurrentLanguage(), '/Contents.json'))
} else { .then(function (response) {
url = this.helpUrl() + Common.getDefaultLanguage(); if ( response.ok ) {
fetch(url + '/Contents.json').then(function (response){ helpUrl = build_url(me.helpUrl(), Common.Locale.getCurrentLanguage(), '');
if ( response.ok ) { }
/* remote help avail. def lang */ })
helpUrl = url; .catch(function (e) {
} else { helpUrl = build_url(me.helpUrl(), Common.Locale.getDefaultLanguage(), '');
/* no help avail. open help center */ });
}
});
} }
}); })
} }
}); });
}
});
} }
return { return {
@ -281,6 +283,7 @@ define([
_.extend(config, opts); _.extend(config, opts);
if ( config.isDesktopApp ) { if ( config.isDesktopApp ) {
const me = this;
let is_win_xp = nativevars && nativevars.os === 'winxp'; let is_win_xp = nativevars && nativevars.os === 'winxp';
Common.UI.Themes.setAvailable(!is_win_xp); Common.UI.Themes.setAvailable(!is_win_xp);
@ -322,7 +325,7 @@ define([
}).show(); }).show();
} }
_checkHelpAvailable(); _checkHelpAvailable.call(me);
} }
}); });

View file

@ -2028,20 +2028,8 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json'; store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json';
store.fetch(config); store.fetch(config);
} else { } else {
if ( Common.Controllers.Desktop.isActive() ) { me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
if ( store.contentLang === '{{DEFAULT_LANG}}' || !Common.Controllers.Desktop.helpUrl() ) { store.reset(me.en_data);
me.noHelpContents = true;
me.iFrame.src = '../../common/main/resources/help/download.html';
} else {
store.contentLang = store.contentLang === lang ? '{{DEFAULT_LANG}}' : lang;
me.urlPref = Common.Controllers.Desktop.helpUrl() + '/' + store.contentLang + '/';
store.url = me.urlPref + 'Contents.json';
store.fetch(config);
}
} else {
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
store.reset(me.en_data);
}
} }
}, },
success: function () { success: function () {
@ -2055,9 +2043,21 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
me.onSelectItem(me.openUrl ? me.openUrl : rec.get('src')); me.onSelectItem(me.openUrl ? me.openUrl : rec.get('src'));
} }
}; };
store.url = 'resources/help/' + lang + '/Contents.json';
store.fetch(config); if ( Common.Controllers.Desktop.isActive() ) {
this.urlPref = 'resources/help/' + lang + '/'; if ( !Common.Controllers.Desktop.isHelpAvailable() ) {
me.noHelpContents = true;
me.iFrame.src = '../../common/main/resources/help/download.html';
} else {
me.urlPref = Common.Controllers.Desktop.helpUrl() + '/';
store.url = me.urlPref + 'Contents.json';
store.fetch(config);
}
} else {
store.url = 'resources/help/' + lang + '/Contents.json';
store.fetch(config);
this.urlPref = 'resources/help/' + lang + '/';
}
} }
}, },

View file

@ -472,6 +472,7 @@ define([
window.open(_url_obj.toString(), '_blank'); window.open(_url_obj.toString(), '_blank');
} }
me.helpUrl = null;
return; return;
} }
} }
@ -489,10 +490,7 @@ define([
me.helpUrl = url; me.helpUrl = url;
me.showHelp(); me.showHelp();
} else { } else {
// me.helpUrl = null; me.helpUrl = null;
if ( Common.Controllers.Desktop.isActive() ) {
url = 'resources/help/' + lang + name;
}
} }
}); });
} }