mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
refactor all [setByName] [getByName] to async bridge function
This commit is contained in:
@@ -825,10 +825,34 @@ class WebMenu extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _WebMenuState extends State<WebMenu> {
|
||||
String? username;
|
||||
String url = "";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
() async {
|
||||
final usernameRes = await getUsername();
|
||||
final urlRes = await getUrl();
|
||||
var update = false;
|
||||
if (usernameRes != username) {
|
||||
username = usernameRes;
|
||||
update = true;
|
||||
}
|
||||
if (urlRes != url) {
|
||||
url = urlRes;
|
||||
update = true;
|
||||
}
|
||||
|
||||
if (update) {
|
||||
setState(() {});
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Provider.of<FfiModel>(context);
|
||||
final username = getUsername();
|
||||
return PopupMenuButton<String>(
|
||||
icon: Icon(Icons.more_vert),
|
||||
itemBuilder: (context) {
|
||||
@@ -846,7 +870,7 @@ class _WebMenuState extends State<WebMenu> {
|
||||
value: "server",
|
||||
)
|
||||
] +
|
||||
(getUrl().contains('admin.rustdesk.com')
|
||||
(url.contains('admin.rustdesk.com')
|
||||
? <PopupMenuItem<String>>[]
|
||||
: [
|
||||
PopupMenuItem(
|
||||
|
||||
@@ -275,9 +275,7 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
gFFI.setByName("temporary_password");
|
||||
},
|
||||
onPressed: () => bind.mainUpdateTemporaryPassword(),
|
||||
),
|
||||
FutureBuilder<Widget>(
|
||||
future: buildPasswordPopupMenu(context),
|
||||
@@ -360,7 +358,7 @@ class _DesktopHomePageState extends State<DesktopHomePage> with TrayListener {
|
||||
if (gFFI.serverModel.temporaryPasswordLength !=
|
||||
e) {
|
||||
gFFI.serverModel.temporaryPasswordLength = e;
|
||||
gFFI.setByName("temporary_password");
|
||||
bind.mainUpdateTemporaryPassword();
|
||||
}
|
||||
},
|
||||
))
|
||||
@@ -1336,8 +1334,8 @@ Future<bool> loginDialog() async {
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
void setPasswordDialog() {
|
||||
final pw = gFFI.getByName("permanent_password");
|
||||
void setPasswordDialog() async {
|
||||
final pw = await bind.mainGetPermanentPassword();
|
||||
final p0 = TextEditingController(text: pw);
|
||||
final p1 = TextEditingController(text: pw);
|
||||
var errMsg0 = "";
|
||||
@@ -1427,7 +1425,7 @@ void setPasswordDialog() {
|
||||
});
|
||||
return;
|
||||
}
|
||||
gFFI.setByName("permanent_password", pass);
|
||||
bind.mainSetPermanentPassword(password: pass);
|
||||
close();
|
||||
},
|
||||
child: Text(translate("OK"))),
|
||||
|
||||
@@ -348,8 +348,9 @@ class _RemotePageState extends State<RemotePage>
|
||||
if (dy > 0)
|
||||
dy = -1;
|
||||
else if (dy < 0) dy = 1;
|
||||
_ffi.setByName('send_mouse',
|
||||
'{"id": "${widget.id}", "type": "wheel", "x": "$dx", "y": "$dy"}');
|
||||
bind.sessionSendMouse(
|
||||
id: widget.id,
|
||||
msg: '{"type": "wheel", "x": "$dx", "y": "$dy"}');
|
||||
}
|
||||
},
|
||||
child: MouseRegion(
|
||||
|
||||
@@ -187,7 +187,7 @@ class _PeerCardState extends State<_PeerCard>
|
||||
elevation: 8,
|
||||
);
|
||||
if (value == 'remove') {
|
||||
setState(() => gFFI.setByName('remove', '$id'));
|
||||
setState(() => bind.mainRemovePeer(id: id));
|
||||
() async {
|
||||
removePreference(id);
|
||||
}();
|
||||
|
||||
Reference in New Issue
Block a user