mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-04 12:51:28 +03:00
refactor msgbox
This commit is contained in:
@@ -216,7 +216,7 @@ function getMsgboxParams() {
|
||||
return msgbox_params;
|
||||
}
|
||||
|
||||
function msgbox(type, title, text, callback, height, width, retry=0, contentStyle="") {
|
||||
function msgbox(type, title, text, callback=null, height=180, width=500, retry=0, contentStyle="") {
|
||||
var has_msgbox = msgbox_params != null;
|
||||
if (!has_msgbox && !type) return;
|
||||
var remember = false;
|
||||
@@ -249,7 +249,7 @@ function msgbox(type, title, text, callback, height, width, retry=0, contentStyl
|
||||
} else if (res == "!alive") {
|
||||
// do nothing
|
||||
} else if (res.type == "input-password") {
|
||||
if (!is_port_forward) handler.msgbox("connecting", "Connecting...", "Logging in...");
|
||||
if (!is_port_forward) msgbox("connecting", "Connecting...", "Logging in...");
|
||||
handler.login(res.password, res.remember);
|
||||
} else if (res.reconnect) {
|
||||
if (!is_port_forward) connecting();
|
||||
@@ -261,19 +261,13 @@ function connecting() {
|
||||
handler.msgbox("connecting", "Connecting...", "Connection in progress. Please wait.");
|
||||
}
|
||||
|
||||
handler.msgbox = function(type, title, text, callback=null, height=180, width=500, retry=0, contentStyle="") {
|
||||
// directly call view.Dialog from native may crash, add timer here, seem safe
|
||||
// too short time, msgbox won't get focus, per my test, 150 is almost minimun
|
||||
self.timer(150ms, function() { msgbox(type, title, text, callback, height, width, retry, contentStyle); });
|
||||
}
|
||||
|
||||
handler.block_msgbox = function(type, title, text, callback=null, height=180, width=500, retry=0) {
|
||||
msgbox(type, title, text, callback, height, width, retry);
|
||||
handler.msgbox = function(type, title, text, retry=0) {
|
||||
self.timer(30ms, function() { msgbox(type, title, text, null, 180, 500, retry); });
|
||||
}
|
||||
|
||||
var reconnectTimeout = 1;
|
||||
handler.msgbox_retry = function(type, title, text, hasRetry, callback=null, height=180, width=500) {
|
||||
handler.msgbox(type, title, text, callback, height, width, hasRetry ? reconnectTimeout : 0);
|
||||
handler.msgbox_retry = function(type, title, text, hasRetry) {
|
||||
handler.msgbox(type, title, text, hasRetry ? reconnectTimeout : 0);
|
||||
if (hasRetry) {
|
||||
reconnectTimeout *= 2;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user