fix new msgbox when wrong password

This commit is contained in:
rustdesk 2022-02-01 16:32:56 +08:00
parent cd62d7024b
commit 3112792b7b
3 changed files with 16 additions and 15 deletions

View File

@ -304,12 +304,10 @@ class MultipleSessions: Reactor.Component {
var nEle = 0; var nEle = 0;
for (var el in this.$$(#sessions-type span)) { for (var el in this.$$(#sessions-type span)) {
nEle += 1; nEle += 1;
var n = el.text.length; totalChars += el.text.length;
totalChars += n;
} }
for (var el in this.$$(#sessions-type span)) { for (var el in this.$$(#sessions-type span)) {
var n = el.text.length; var maxWidth = (w - nEle * 2 * 8) * el.text.length / totalChars;
var maxWidth = (w - nEle * 2 * 8) * n / totalChars;
if (maxWidth < 0) maxWidth = 36; if (maxWidth < 0) maxWidth = 36;
el.style.set{ el.style.set{
"max-width": maxWidth + "px", "max-width": maxWidth + "px",

View File

@ -234,14 +234,14 @@ function msgbox(type, title, content, callback=null, height=180, width=500, hasR
width += is_xfce ? 50 : 0; width += is_xfce ? 50 : 0;
height += is_xfce ? 50 : 0; height += is_xfce ? 50 : 0;
if (type == "input-password") { if (type.indexOf("input-password") >= 0) {
callback = function (res) { callback = function (res) {
if (!res) { if (!res) {
view.close(); view.close();
return; return;
} }
handler.login(res.password, res.remember); handler.login(res.password, res.remember);
if (!is_port_forward) msgbox("connecting", "Connecting...", "Logging in..."); if (!is_port_forward) handler.msgbox("connecting", "Connecting...", "Logging in...");
}; };
} else if (type.indexOf("custom") < 0 && !is_port_forward && !callback) { } else if (type.indexOf("custom") < 0 && !is_port_forward && !callback) {
callback = function() { view.close(); } callback = function() { view.close(); }
@ -254,16 +254,16 @@ function connecting() {
} }
handler.msgbox = function(type, title, text, hasRetry=false) { handler.msgbox = function(type, title, text, hasRetry=false) {
msgbox(type, title, text, null, 180, 500, hasRetry); // crash somehow (when input wrong password), even with small time, for example, 1ms
self.timer(30ms, function() { msgbox(type, title, text, null, 180, 500, hasRetry); });
} }
var reconnectTimeout = 1000; var reconnectTimeout = 1000;
var activeTimer = function() {};
handler.msgbox_retry = function(type, title, text, hasRetry) { handler.msgbox_retry = function(type, title, text, hasRetry) {
handler.msgbox(type, title, text, hasRetry); handler.msgbox(type, title, text, hasRetry);
if (hasRetry) { if (hasRetry) {
self.timer(0, activeTimer); self.timer(0, retryConnect);
activeTimer = self.timer(reconnectTimeout, retryConnect); self.timer(reconnectTimeout, retryConnect);
reconnectTimeout *= 2; reconnectTimeout *= 2;
} else { } else {
reconnectTimeout = 1000; reconnectTimeout = 1000;
@ -271,9 +271,9 @@ handler.msgbox_retry = function(type, title, text, hasRetry) {
} }
function retryConnect(cancelTimer=false) { function retryConnect(cancelTimer=false) {
if (cancelTimer) self.timer(0, retryConnect);
if (!is_port_forward) connecting(); if (!is_port_forward) connecting();
handler.reconnect(); handler.reconnect();
if (cancelTimer) self.timer(0, activeTimer);
} }
/******************** end of msgbox ****************************************/ /******************** end of msgbox ****************************************/

View File

@ -9,7 +9,9 @@ function translate_text(text) {
return text; return text;
} }
var msgboxTimerFunc = function() {}
function closeMsgbox() { function closeMsgbox() {
self.timer(0, msgboxTimerFunc);
$(#msgbox).content(<span />); $(#msgbox).content(<span />);
} }
@ -86,12 +88,14 @@ class MsgboxComponent: Reactor.Component {
var hasClose = this.type.indexOf("hasclose") >= 0; var hasClose = this.type.indexOf("hasclose") >= 0;
var show_progress = this.type == "connecting"; var show_progress = this.type == "connecting";
var me = this; var me = this;
self.timer(1ms, function() { self.timer(0, msgboxTimerFunc);
msgboxTimerFunc = function() {
if (typeof content == "string") if (typeof content == "string")
me.$(#content).html = translate(content); me.$(#content).html = translate(content);
else else
me.$(#content).content(content); me.$(#content).content(content);
}); };
self.timer(3ms, msgboxTimerFunc);
return (<div><div style="position: absolute; size:*; background:black; opacity:0.5;" /> return (<div><div style="position: absolute; size:*; background:black; opacity:0.5;" />
<div style="size: *; position: absolute;"> <div style="size: *; position: absolute;">
<div style={"border: " + color + " solid 1px; background: white; margin: *; width:" + (this.width) + "px; height:" + (this.height) + "px"}> <div style={"border: " + color + " solid 1px; background: white; margin: *; width:" + (this.width) + "px; height:" + (this.height) + "px"}>
@ -152,7 +156,7 @@ class MsgboxComponent: Reactor.Component {
} }
if (this.type == "re-input-password") { if (this.type == "re-input-password") {
this.type = "input-password"; this.type = "input-password";
body.update(); this.update();
return; return;
} }
var values = this.getValues(); var values = this.getValues();
@ -221,7 +225,6 @@ class MsgboxComponent: Reactor.Component {
el = me.$(#submit); el = me.$(#submit);
if (el) { if (el) {
view.focus = el; view.focus = el;
stdout.println(el);
} }
} }
}); });