Merge pull request #3069 from fufesou/refact/sync_option_after_toggle

sync option after toggle
This commit is contained in:
RustDesk 2023-02-03 23:18:43 +08:00 committed by GitHub
commit a7f0b63623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -273,6 +273,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
menu.add(MenuEntryDivider<String>());
menu.add(() {
final state = ShowRemoteCursorState.find(key);
final optKey = 'show-remote-cursor';
return MenuEntrySwitch2<String>(
switchType: SwitchType.scheckbox,
text: translate('Show remote cursor'),
@ -280,9 +281,8 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
return state;
},
setter: (bool v) async {
state.value = v;
await bind.sessionToggleOption(
id: key, value: 'show-remote-cursor');
await bind.sessionToggleOption(id: key, value: optKey);
state.value = bind.sessionGetToggleOptionSync(id: key, arg: optKey);
cancelFunc();
},
padding: padding,

View File

@ -1160,6 +1160,7 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
if (!widget.ffi.canvasModel.cursorEmbedded) {
displayMenu.add(() {
final state = ShowRemoteCursorState.find(widget.id);
final optKey = 'show-remote-cursor';
return MenuEntrySwitch2<String>(
switchType: SwitchType.scheckbox,
text: translate('Show remote cursor'),
@ -1167,9 +1168,9 @@ class _RemoteMenubarState extends State<RemoteMenubar> {
return state;
},
setter: (bool v) async {
state.value = v;
await bind.sessionToggleOption(
id: widget.id, value: 'show-remote-cursor');
await bind.sessionToggleOption(id: widget.id, value: optKey);
state.value =
bind.sessionGetToggleOptionSync(id: widget.id, arg: optKey);
},
padding: padding,
dismissOnClicked: true,