summaryrefslogtreecommitdiff
path: root/app/ui.js
diff options
context:
space:
mode:
authorSamuel Mannehed <samuel@cendio.se>2019-03-04 09:32:11 +0100
committerGitHub <noreply@github.com>2019-03-04 09:32:11 +0100
commit9a823732a01af080357669d12d355cdc8e7e099c (patch)
treeeb4cc41bfae4d9ab8cd1c99e8d35495aa9c37d78 /app/ui.js
parentd917ccdaf7152d380ed2686bf9ddf1ef3998255d (diff)
parent1c9b904d1aa585e4f096fe922ca508bdb4c5106a (diff)
downloadnovnc-9a823732a01af080357669d12d355cdc8e7e099c.tar.gz
Merge pull request #1204 from juanjoDiaz/small_improvements
Small improvements
Diffstat (limited to 'app/ui.js')
-rw-r--r--app/ui.js43
1 files changed, 17 insertions, 26 deletions
diff --git a/app/ui.js b/app/ui.js
index db3b1f3..17ec48d 100644
--- a/app/ui.js
+++ b/app/ui.js
@@ -39,22 +39,20 @@ const UI = {
reconnect_callback: null,
reconnect_password: null,
- prime(callback) {
- if (document.readyState === "interactive" || document.readyState === "complete") {
- UI.load(callback);
- } else {
- document.addEventListener('DOMContentLoaded', UI.load.bind(UI, callback));
- }
- },
+ prime() {
+ return WebUtil.initSettings().then(() => {
+ if (document.readyState === "interactive" || document.readyState === "complete") {
+ return UI.start();
+ }
- // Setup rfb object, load settings from browser storage, then call
- // UI.init to setup the UI/menus
- load(callback) {
- WebUtil.initSettings(UI.start, callback);
+ return new Promise((resolve, reject) => {
+ document.addEventListener('DOMContentLoaded', () => UI.start().then(resolve).catch(reject));
+ });
+ });
},
// Render default UI and initialize settings menu
- start(callback) {
+ start() {
UI.initSettings();
@@ -105,9 +103,7 @@ const UI = {
UI.openConnectPanel();
}
- if (typeof callback === "function") {
- callback(UI.rfb);
- }
+ return Promise.resolve(UI.rfb);
},
initFullscreen() {
@@ -1646,18 +1642,13 @@ const UI = {
// Set up translations
const LINGUAS = ["cs", "de", "el", "es", "ko", "nl", "pl", "ru", "sv", "tr", "zh_CN", "zh_TW"];
l10n.setup(LINGUAS);
-if (l10n.language !== "en" && l10n.dictionary === undefined) {
- WebUtil.fetchJSON('app/locale/' + l10n.language + '.json', (translations) => {
- l10n.dictionary = translations;
-
- // wait for translations to load before loading the UI
- UI.prime();
- }, (err) => {
- Log.Error("Failed to load translations: " + err);
- UI.prime();
- });
-} else {
+if (l10n.language === "en" || l10n.dictionary !== undefined) {
UI.prime();
+} else {
+ WebUtil.fetchJSON('app/locale/' + l10n.language + '.json')
+ .then((translations) => { l10n.dictionary = translations; })
+ .catch(err => Log.Error("Failed to load translations: " + err))
+ .then(UI.prime);
}
export default UI;