diff --git a/src/emain.ts b/src/emain.ts
index 1e28d27b..083482da 100644
--- a/src/emain.ts
+++ b/src/emain.ts
@@ -400,7 +400,17 @@ function getFetchHeaders() {
};
}
-function getClientData() {
+async function getClientDataPoll(loopNum : number) {
+ let lastTime = (loopNum >= 6);
+ let cdata = await getClientData(!lastTime, loopNum);
+ if (lastTime || cdata != null) {
+ return cdata;
+ }
+ await sleep(1000);
+ return getClientDataPoll(loopNum+1);
+}
+
+function getClientData(willRetry : boolean, retryNum : number) {
let url = getBaseHostPort() + "/api/get-client-data";
let fetchHeaders = getFetchHeaders();
return fetch(url, {headers: fetchHeaders}).then((resp) => handleJsonFetchResponse(url, resp)).then((data) => {
@@ -409,7 +419,11 @@ function getClientData() {
}
return data.data;
}).catch((err) => {
- console.log("error getting client-data", err);
+ if (willRetry) {
+ console.log("error getting client-data from local-server, will retry", "(" + retryNum + ")");
+ return null;
+ }
+ console.log("error getting client-data from local-server, failed: ", err);
return null;
});
}
@@ -498,7 +512,7 @@ electron.ipcMain.on("context-editmenu", (event, {x, y}, opts) => {
async function createMainWindowWrap() {
let clientData = null;
try {
- clientData = await getClientData();
+ clientData = await getClientDataPoll(1);
}
catch (e) {
console.log("error getting local-server clientdata", e.toString());
@@ -531,7 +545,6 @@ function runActiveTimer() {
setTimeout(runActiveTimer, 60000);
}
-
// ====== MAIN ====== //
(async () => {
@@ -548,7 +561,6 @@ function runActiveTimer() {
catch (e) {
console.log(e.toString());
}
- await sleep(1000); // TODO remove this sleep, poll getClientData() in createMainWindow
setTimeout(runActiveTimer, 5000); // start active timer, wait 5s just to be safe
await app.whenReady();
await createMainWindowWrap();
diff --git a/src/main.tsx b/src/main.tsx
index 1fd0a0e5..35f398ad 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -2635,14 +2635,14 @@ class DisconnectedModal extends React.Component<{}, {}> {
let logLine : string = null;
let idx : number = 0;
return (
-
+
-
+
-
Prompt Client Disconnected
+
Prompt Client Disconnected
-
+
{logLine}
@@ -2650,7 +2650,7 @@ class DisconnectedModal extends React.Component<{}, {}> {
-
+
+
);
diff --git a/src/model.ts b/src/model.ts
index 6f51a848..98cde26a 100644
--- a/src/model.ts
+++ b/src/model.ts
@@ -2402,7 +2402,7 @@ class Model {
getApi().onLocalServerStatusChange(this.onLocalServerStatusChange.bind(this));
document.addEventListener("keydown", this.docKeyDownHandler.bind(this));
document.addEventListener("selectionchange", this.docSelectionChangeHandler.bind(this));
- setTimeout(() => this.getClientData(), 10);
+ setTimeout(() => this.getClientDataLoop(1), 10);
}
registerRendererPlugin(plugin : RendererPluginType) {
@@ -2936,6 +2936,24 @@ class Model {
return (update.info != null || update.history != null);
}
+ getClientDataLoop(loopNum : number) : void {
+ this.getClientData();
+ if (this.clientData.get() != null) {
+ return;
+ }
+ let timeoutMs = 1000;
+ if (loopNum > 5) {
+ timeoutMs = 3000;
+ }
+ if (loopNum > 10) {
+ timeoutMs = 10000;
+ }
+ if (loopNum > 15) {
+ timeoutMs = 30000;
+ }
+ setTimeout(() => this.getClientDataLoop(loopNum+1), timeoutMs);
+ }
+
getClientData() : void {
let url = sprintf(GlobalModel.getBaseHostPort() + "/api/get-client-data");
let fetchHeaders = this.getFetchHeaders();
diff --git a/src/sh2.less b/src/sh2.less
index 7fec7c30..c47b6249 100644
--- a/src/sh2.less
+++ b/src/sh2.less
@@ -147,7 +147,7 @@ body::-webkit-scrollbar {
}
&.should-fade {
- opacity: 0;
+ opacity: 1.0;
animation: fade-in 2.5s;
}
}
@@ -2403,52 +2403,20 @@ input[type=checkbox] {
.mono-font(inherit, 700);
}
-.sc-modal {
+.disconnected-modal {
.modal-content {
- padding: 10px;
- background-color: #666;
-
- .message-header {
- .mono-font();
- font-size: 16px;
- margin-bottom: 10px;
- }
-
- .message-content {
- flex-grow: 1;
- max-height: 80%;
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- margin-bottom: 10px;
- }
-
- .message-footer {
- border-top: 1px solid #666;
- display: flex;
- flex-direction: row;
- justify-content: center;
- align-items: center;
-
- .spacer {
- flex-grow: 1;
- }
-
+ footer {
.footer-text-link {
.mono-font(12px);
color: @term-white;
cursor: pointer;
}
}
-
- .button {
- .mono-font();
- }
}
}
.disconnected-modal {
- .message-content {
+ .inner-content {
.ws-log {
padding: 5px;
background-color: black;