From d84ad34434c2d85635da6944f685a9b73b8dc547 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sun, 17 Apr 2022 10:15:27 +0700 Subject: [PATCH] Add "Old" pairing method to the UI --- dance.py | 3 ++- static/js/app.js | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/dance.py b/dance.py index 331e1bb..433bab5 100644 --- a/dance.py +++ b/dance.py @@ -28,6 +28,7 @@ class WsCommand(Enum): class PairingMethod(Enum): DEFAULT = 'default' FAST = 'fast' + OLD = 'old' REGEX_PAIRING_CODE = re.compile(r'^\d{6}$') @@ -222,7 +223,7 @@ def is_valid_ip_address(val): def is_valid_pairing_method(val): - return val in [PairingMethod.DEFAULT.value, PairingMethod.FAST.value] + return val in [PairingMethod.DEFAULT.value, PairingMethod.FAST.value, PairingMethod.OLD.value] def get_host_ip(): diff --git a/static/js/app.js b/static/js/app.js index b8146d1..0f26f30 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -17,7 +17,8 @@ const BATTERY_LEVEL = { const PairingMethod = { DEFAULT: 'default', - FAST: 'fast' + FAST: 'fast', + OLD: 'old', } const WsCommand = { @@ -83,8 +84,13 @@ class PairingMethodPicker extends Component { return html` ` } @@ -141,14 +147,14 @@ class PrivateIpAddress extends Component { return html` ${pairing_method == PairingMethod.DEFAULT && state.lock_host && html` `} - ${(pairing_method == PairingMethod.FAST || !state.lock_host) && html` + ${(pairing_method != PairingMethod.DEFAULT || !state.lock_host) && html` `} @@ -181,7 +187,7 @@ class PairingCode extends Component { ${props.pairing_method == PairingMethod.DEFAULT && html` !/[0-9]/.test(e.key) && e.preventDefault()} onChange=${this.onChange} /> `} - ${props.pairing_method == PairingMethod.FAST && html` + ${props.pairing_method != PairingMethod.DEFAULT && html` `} `