External editors.
Fix the use-case where we import from the cloud someone else's script, written using an external editor.
This commit is contained in:
Родитель
1c5cdaec19
Коммит
e9b618b85a
|
@ -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,
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче