make the nested comments for base versions load faster; also include the direct base script for unpublished scripts

This commit is contained in:
Michal Moskal 2015-08-22 08:25:37 +01:00
Родитель a876aec159
Коммит e3e49e12d4
3 изменённых файлов: 24 добавлений и 6 удалений

Просмотреть файл

@ -181,6 +181,7 @@ module TDev {
flows:any[]; // ???
haserrors:boolean; // whether this script has any compilation errors
rootid:string; // refers to the earliest script along the chain of script bases
baseid?:string; // lite
updateid:string; // refers to the latest published successor (along any path) of that script with the same name and from the same user
updatetime:number;
ishidden:boolean; // whether the user has indicated that this script should be hidden

Просмотреть файл

@ -3884,9 +3884,9 @@
if (js.id && js.rootid == js.id)
return div(null)
var cont = div(null)
var getFor = (id: string) => {
var getFor = (id: string, skipComments = false) => {
Util.assert(!!id, "missing comment id");
TheApiCacheMgr.getAsync(id + "/base", true).done(resp => {
TheApiCacheMgr.getAsync(Cloud.lite ? id : id + "/base", true).done(resp => {
versionDepth++;
if (!resp) return
var d = div("sdLoadingMore", lf("loading comments for /{0}...", resp.id))
@ -3927,12 +3927,12 @@
cont.appendChild(div(null, hd, d))
if (resp.rootid != resp.id) {
if (versionDepth < 5) getFor(resp.id)
if (versionDepth < 5) getFor(Cloud.lite ? resp.baseid : resp.id)
else {
var loadMoreVersion = HTML.mkButton(lf("load more"),() => {
loadMoreVersion.removeSelf();
versionDepth = 0;
getFor(resp.id);
getFor(Cloud.lite ? resp.baseid : resp.id);
});
cont.appendChild(loadMoreVersion);
}
@ -3940,7 +3940,24 @@
})
}
getFor(this.getParentId())
if (Cloud.lite)
// the call to /family is there to prefetch typical parents
TheApiCacheMgr.getAsync(this.getParentId() + "/family?count=10&etagsmode=includeetags", true)
.done((prefetch) => {
prefetch.items.forEach((e, i) => {
TheApiCacheMgr.store(e.id, e, prefetch.etags[i], true);
})
if (this.parent.publicId) {
Util.assert(!!js.id)
if (js.baseid) getFor(js.baseid)
}
else
getFor(this.getParentId(), true)
})
else
getFor(this.getParentId())
return cont
} else {

Просмотреть файл

@ -577,7 +577,7 @@ module TDev.Cloud {
export function getScriptTextAsync(id: string) : Promise {
return Util.httpGetTextAsync(getPublicApiUrl(encodeURIComponent(id) + "/text?original=true"))
.then(text => {
if (/^.*upperplex/.test(text)) return text
if (Cloud.lite || /^.*upperplex/.test(text)) return text
else
return Util.httpGetTextAsync(getPublicApiUrl(encodeURIComponent(id) + "/text?original=true&ids=true"))
})