Add usage ticks every 10s - different per editor
This commit is contained in:
Родитель
8544666748
Коммит
4de8cc264f
|
@ -3277,6 +3277,7 @@ module TDev
|
|||
|
||||
return final();
|
||||
}).then(() => {
|
||||
Ticker.setCurrentEditorId("touchdevelop");
|
||||
if (!shouldRun) return Browser.EditorSettings.initEditorModeAsync().then(() => this.setMode(true))
|
||||
else return Promise.as();
|
||||
}).then(() => {
|
||||
|
|
|
@ -304,6 +304,7 @@ module TDev {
|
|||
|
||||
switch ((<Message> event.data).type) {
|
||||
case MessageType.Save: {
|
||||
tick(Ticks.externalSave);
|
||||
var message = <Message_Save> event.data;
|
||||
World.getInstalledHeaderAsync(this.guid).then((header: Cloud.Header) => {
|
||||
var scriptText = message.script.scriptText;
|
||||
|
@ -538,6 +539,7 @@ module TDev {
|
|||
break;
|
||||
|
||||
case MessageType.Load:
|
||||
tick(Ticks.externalLoad);
|
||||
var message4 = <Message_Load> event.data;
|
||||
ArtUtil.handleImportFilesAsync([message4.file]).done();
|
||||
break;
|
||||
|
@ -586,6 +588,8 @@ module TDev {
|
|||
baseSnapshot: null,
|
||||
};
|
||||
|
||||
Ticker.setCurrentEditorId(editor.id);
|
||||
|
||||
// Clear leftover iframes and simulators.
|
||||
document.getElementById("externalEditorSide").setChildren([]);
|
||||
var iframeDiv = document.getElementById("externalEditorFrame");
|
||||
|
|
|
@ -1973,8 +1973,10 @@
|
|||
|
||||
if (s instanceof TopicInfo)
|
||||
this.reloadHelpTopic = setHash;
|
||||
else
|
||||
else {
|
||||
Ticker.setCurrentEditorId("shell");
|
||||
this.reloadHelpTopic = null;
|
||||
}
|
||||
Host.tryUpdate();
|
||||
|
||||
this.syncTabVisibility();
|
||||
|
|
30
rt/ticker.ts
30
rt/ticker.ts
|
@ -242,6 +242,8 @@ module TDev {
|
|||
editorTutorialNext,
|
||||
editorTutorialPrevious,
|
||||
|
||||
externalSave,
|
||||
externalLoad,
|
||||
externalCompile,
|
||||
externalRun,
|
||||
|
||||
|
@ -605,7 +607,7 @@ module TDev {
|
|||
var disabled = false;
|
||||
var delay = 10; // initial, 10s
|
||||
var chunkId = 1;
|
||||
var maxDelay = 1200; // 1200s
|
||||
var maxDelay = 300; // 300s
|
||||
var initialized = false;
|
||||
|
||||
export var mainJsName = "unknown";
|
||||
|
@ -665,6 +667,8 @@ module TDev {
|
|||
}
|
||||
}
|
||||
|
||||
usageTick();
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
@ -965,6 +969,7 @@ module TDev {
|
|||
|
||||
if (!initialized || disabled) return;
|
||||
|
||||
poke();
|
||||
checkDate();
|
||||
|
||||
var m = <TickEvent>{ timestamp: Util.now(), event: t, arg: arg }
|
||||
|
@ -1007,6 +1012,29 @@ module TDev {
|
|||
else
|
||||
return logMsgs.slice(0);
|
||||
}
|
||||
|
||||
function usageTick()
|
||||
{
|
||||
var id = getCurrentEditorId();
|
||||
if (id && !document.hidden && lastPoke) {
|
||||
rawTick("editor_" + id)
|
||||
lastPoke = 0;
|
||||
}
|
||||
// avarage out to once per 10s, but get more even probabilistic distribution
|
||||
Util.setTimeout(RT.Math_.random_range(3000,17000), usageTick)
|
||||
}
|
||||
|
||||
var currentEditorId:string;
|
||||
var lastPoke:number;
|
||||
export function poke()
|
||||
{
|
||||
lastPoke = Util.now();
|
||||
}
|
||||
export function setCurrentEditorId(id:string) {
|
||||
Util.log("set editor: " + id)
|
||||
currentEditorId = id;
|
||||
}
|
||||
export function getCurrentEditorId() { return currentEditorId; }
|
||||
}
|
||||
|
||||
export function tick(t: Ticks, arg?: string) { Ticker.tick(t, arg) }
|
||||
|
|
Загрузка…
Ссылка в новой задаче