Fix the use-case where we import from the cloud someone else's script, written
using an external editor.
This commit is contained in:
Jonathan Protzenko 2015-04-02 16:08:18 -07:00
Родитель 1c5cdaec19
Коммит e9b618b85a
2 изменённых файлов: 17 добавлений и 8 удалений

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

@ -183,7 +183,7 @@ module TDev {
screenshotthumburl:string;
screenshoturl:string;
mergeids:string[];
editor?: string;
editor?: string; // convention where empty means touchdevelop, for backwards compatibility
}
export interface JsonHistoryItem

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

@ -850,17 +850,26 @@ module TDev {
var item = items[guid];
return item.status == "published" && item.scriptId == scriptId;
});
if (matchingGuids.length > 0) return items[matchingGuids[0]];
return ScriptCache.getScriptAsync(scriptId).then((text) => {
if (matchingGuids.length > 0)
return items[matchingGuids[0]];
return Promise.join({
text: ScriptCache.getScriptAsync(scriptId),
json: (<any>Browser).TheApiCacheMgr.getAsync(scriptId),
}).then(data => {
var text: string = data.text;
var json = data.json;
if (!text) {
HTML.showErrorNotification("cannot get script /" + scriptId);
return new PromiseInv(); // stall
} else {
return installAsync("published", scriptId, userId, {
scriptText: text,
// This is a script stub that uses the different
// convention
editorName: json.editor || "touchdevelop",
scriptName: json.name,
});
}
return installAsync("published", scriptId, userId, {
scriptText: text,
editorName: "touchdevelop",
scriptName: getScriptMeta(text).name,
})
});
});
}