mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-03 22:53:56 +08:00
🎁 Sync 2026-10-18 22:41:16
This commit is contained in:
1 parent
3eca35a513
commit
3159b4f938
88 files changed
+5597
-1051
No files matched your search
@@ -28,6 +28,9 @@ return view.extend({
|
||||
this._include = include;
|
||||
this._loading = null;
|
||||
|
||||
if (include != null)
|
||||
this.disableCache = include.disableCache;
|
||||
|
||||
if (include != null && include.title != null)
|
||||
this.title = include.title;
|
||||
|
||||
@@ -150,16 +153,20 @@ return view.extend({
|
||||
if (include.hide && !first_load)
|
||||
return Promise.resolve(null);
|
||||
|
||||
if (!include.hide && !container.hasAttribute('data-cached'))
|
||||
if (include._pendingLoad)
|
||||
return include._pendingLoad;
|
||||
|
||||
if (first_load && !include.hide && !container.hasAttribute('data-cached'))
|
||||
this.renderIncludePlaceholder(container);
|
||||
|
||||
if (typeof(include.load) == 'function') {
|
||||
return include.load().then(L.bind(function(result) {
|
||||
include._pendingLoad = Promise.resolve().then(function() { return include.load(); }).then(L.bind(function(result) {
|
||||
this.applyIncludeResult(include, container, result, first_load);
|
||||
return result;
|
||||
}, this)).catch(function() {
|
||||
return null;
|
||||
});
|
||||
}).finally(function() { include._pendingLoad = null; });
|
||||
return include._pendingLoad;
|
||||
}
|
||||
|
||||
this.applyIncludeResult(include, container, null, first_load);
|
||||
@@ -188,43 +195,13 @@ return view.extend({
|
||||
}
|
||||
},
|
||||
|
||||
invokeIncludesLoad: function(includes, first_load) {
|
||||
var tasks = [];
|
||||
|
||||
for (var i = 0; i < includes.length; i++) {
|
||||
if (includes[i].hide && !first_load) {
|
||||
tasks.push(Promise.resolve(null));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof(includes[i].load) == 'function') {
|
||||
tasks.push(Promise.resolve(includes[i].load()).catch(function() {
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
else {
|
||||
tasks.push(Promise.resolve(null));
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.all(tasks);
|
||||
},
|
||||
|
||||
poll_status: function(includes, containers, first_load) {
|
||||
var fetch = first_load ? Promise.resolve(null) : network.flushCache();
|
||||
|
||||
return fetch.then(L.bind(
|
||||
this.invokeIncludesLoad, this, includes, first_load
|
||||
)).then(L.bind(function(results) {
|
||||
for (var i = 0; i < includes.length; i++) {
|
||||
this.applyIncludeResult(includes[i], containers[i], results ? results[i] : null, first_load);
|
||||
}
|
||||
|
||||
var ssi = document.querySelector('div.includes');
|
||||
if (ssi) {
|
||||
ssi.style.display = '';
|
||||
ssi.classList.add('fade-in');
|
||||
}
|
||||
return fetch.then(L.bind(function() {
|
||||
// Slow wireless queries must not hold up other cards or their next poll.
|
||||
this.loadIncludeGroup(includes, containers, true, first_load);
|
||||
return this.loadIncludeGroup(includes, containers, false, first_load);
|
||||
}, this));
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user