force relay when id is suffixed with "/r"

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-02-13 16:40:24 +08:00
parent 759c1901a5
commit 6f106251f9
15 changed files with 127 additions and 63 deletions

View File

@@ -66,7 +66,8 @@ class _ConnectionPageState extends State<ConnectionPage>
_idFocusNode.addListener(() {
_idInputFocused.value = _idFocusNode.hasFocus;
// select all to faciliate removing text, just following the behavior of address input of chrome
_idController.selection = TextSelection(baseOffset: 0, extentOffset: _idController.value.text.length);
_idController.selection = TextSelection(
baseOffset: 0, extentOffset: _idController.value.text.length);
});
windowManager.addListener(this);
}
@@ -149,8 +150,11 @@ class _ConnectionPageState extends State<ConnectionPage>
/// Callback for the connect button.
/// Connects to the selected peer.
void onConnect({bool isFileTransfer = false}) {
final id = _idController.id;
connect(context, id, isFileTransfer: isFileTransfer);
var id = _idController.id;
var forceRelay = id.endsWith(r'/r');
if (forceRelay) id = id.substring(0, id.length - 2);
connect(context, id,
isFileTransfer: isFileTransfer, forceRelay: forceRelay);
}
/// UI for the remote ID TextField.