Skip to content

Commit a2fce95

Browse files
wryunsystemcrash
authored andcommitted
luci-base: don't render until luci-loaded is done
Because the setupDOM/initDOM methods do strange things related to the old lua server rendered templates (like remove all the elements currently hidden by dependencies...), we want to be sure that these have finished before the view itself renders. This also ensures that any caching (e.g. from probeSystemFeatures) is finished before the view render. This feels like a hacky fix, but it's not clear to me what the best one is. Signed-off-by: James Haggerty <[email protected]>
1 parent 9924970 commit a2fce95

File tree

1 file changed

+12
-0
lines changed
  • modules/luci-base/htdocs/luci-static/resources

1 file changed

+12
-0
lines changed

modules/luci-base/htdocs/luci-static/resources/luci.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,15 @@
18931893
DOM.content(vp, E('div', { 'class': 'spinning' }, _('Loading view…')));
18941894

18951895
return Promise.resolve(this.load())
1896+
.then(function (...args) {
1897+
if (L.loaded) {
1898+
return Promise.resolve(...args);
1899+
} else {
1900+
return new Promise(function (resolve) {
1901+
document.addEventListener('luci-loaded', resolve.bind(null, ...args), { once: true });
1902+
});
1903+
}
1904+
})
18961905
.then(LuCI.prototype.bind(this.render, this))
18971906
.then(LuCI.prototype.bind(function(nodes) {
18981907
const vp = document.getElementById('view');
@@ -2688,9 +2697,12 @@
26882697
initDOM() {
26892698
originalCBIInit();
26902699
Poll.start();
2700+
L.loaded = true;
26912701
document.dispatchEvent(new CustomEvent('luci-loaded'));
26922702
},
26932703

2704+
loaded: false,
2705+
26942706
/**
26952707
* The `env` object holds environment settings used by LuCI, such
26962708
* as request timeouts, base URLs etc.

0 commit comments

Comments
 (0)