From 6a45fd58601a2b03ed234f05b9b0a1b91d25a54d Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Thu, 9 Jan 2020 18:31:03 -0500 Subject: azure ink fixes, session --- src/client/DocServer.ts | 6 ++++-- src/client/cognitive_services/CognitiveServices.ts | 9 +++------ 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/client') diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index 1723312cf..12fed3e46 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -64,13 +64,14 @@ export namespace DocServer { } } + const instructions = "This page will automatically refresh after this alert is closed. Expect to reconnect after about 30 seconds."; function alertUser(connectionTerminationReason: string) { switch (connectionTerminationReason) { case "crash": - alert("Dash has temporarily crashed. Administrators have been notified and the server is restarting itself. Please refresh your page in a few seconds, and expect to reconnect after about 30 seconds."); + alert(`Dash has temporarily crashed. Administrators have been notified and the server is restarting itself. ${instructions}`); break; case "temporary": - alert("An administrator has chosen to restart the server. Please refresh your page in a few seconds, and expect to reconnect after about 30 seconds."); + alert(`An administrator has chosen to restart the server. ${instructions}`); break; case "exit": alert("An administrator has chosen to kill the server. Do not expect to reconnect until administrators start the server."); @@ -78,6 +79,7 @@ export namespace DocServer { default: console.log(`Received an unknown ConnectionTerminated message: ${connectionTerminationReason}`); } + window.location.reload(); } export function init(protocol: string, hostname: string, port: number, identifier: string) { diff --git a/src/client/cognitive_services/CognitiveServices.ts b/src/client/cognitive_services/CognitiveServices.ts index 02eff3b25..57296c961 100644 --- a/src/client/cognitive_services/CognitiveServices.ts +++ b/src/client/cognitive_services/CognitiveServices.ts @@ -137,7 +137,7 @@ export namespace CognitiveServices { let id = 0; const strokes: AzureStrokeData[] = inkData.map(points => ({ id: id++, - points: points.map(({ x, y }) => `${x},${y}`).join(","), + points: points.map(({ X: x, Y: y }) => `${x},${y}`).join(","), language: "en-US" })); return JSON.stringify({ @@ -153,7 +153,7 @@ export namespace CognitiveServices { const serverAddress = "https://api.cognitive.microsoft.com"; const endpoint = serverAddress + "/inkrecognizer/v1.0-preview/recognize"; - const promisified = (resolve: any, reject: any) => { + return new Promise((resolve, reject) => { xhttp.onreadystatechange = function () { if (this.readyState === 4) { const result = xhttp.responseText; @@ -171,11 +171,8 @@ export namespace CognitiveServices { xhttp.setRequestHeader('Ocp-Apim-Subscription-Key', apiKey); xhttp.setRequestHeader('Content-Type', 'application/json'); xhttp.send(body); - }; - - return new Promise(promisified); + }); }, - }; export namespace Appliers { -- cgit v1.2.3-70-g09d2