@@ -46,10 +46,7 @@ mod imp {
4646 pub selected_device : RefCell < Option < DeviceObject > > ,
4747
4848 #[ property( get, set) ]
49- pub usb_pin_entry_visible : RefCell < bool > ,
50-
51- #[ property( get, set) ]
52- pub nfc_pin_entry_visible : RefCell < bool > ,
49+ pub usb_nfc_pin_entry_visible : RefCell < bool > ,
5350
5451 #[ property( get, set) ]
5552 pub prompt : RefCell < String > ,
@@ -123,7 +120,7 @@ impl ViewModel {
123120 match rx. recv( ) . await {
124121 Ok ( update) => {
125122 // TODO: hack so I don't have to unset this in every event manually.
126- view_model. set_usb_pin_entry_visible ( false ) ;
123+ view_model. set_usb_nfc_pin_entry_visible ( false ) ;
127124 match update {
128125 ViewUpdate :: SetTitle ( title) => view_model. set_title( title) ,
129126 ViewUpdate :: SetDevices ( devices) => {
@@ -136,31 +133,8 @@ impl ViewModel {
136133 ViewUpdate :: WaitingForDevice ( device) => {
137134 view_model. waiting_for_device( & device)
138135 }
139- ViewUpdate :: UsbNeedsPin { attempts_left } => {
140- let prompt = match attempts_left {
141- Some ( 1 ) => {
142- "Enter your PIN. 1 attempt remaining." . to_string( )
143- }
144- Some ( attempts_left) => format!(
145- "Enter your PIN. {attempts_left} attempts remaining."
146- ) ,
147- None => "Enter your PIN." . to_string( ) ,
148- } ;
149- view_model. set_prompt( prompt) ;
150- view_model. set_usb_pin_entry_visible( true ) ;
151- }
152- ViewUpdate :: UsbNeedsUserVerification { attempts_left } => {
153- let prompt = match attempts_left {
154- Some ( 1 ) => "Touch your device again. 1 attempt remaining."
155- . to_string( ) ,
156- Some ( attempts_left) => format!(
157- "Touch your device again. {attempts_left} attempts remaining."
158- ) ,
159- None => "Touch your device." . to_string( ) ,
160- } ;
161- view_model. set_prompt( prompt) ;
162- }
163- ViewUpdate :: NfcNeedsPin { attempts_left } => {
136+ ViewUpdate :: UsbNeedsPin { attempts_left }
137+ | ViewUpdate :: NfcNeedsPin { attempts_left } => {
164138 let prompt = match attempts_left {
165139 Some ( 1 ) => {
166140 "Enter your PIN. 1 attempt remaining." . to_string( )
@@ -171,9 +145,10 @@ impl ViewModel {
171145 None => "Enter your PIN." . to_string( ) ,
172146 } ;
173147 view_model. set_prompt( prompt) ;
174- view_model. set_nfc_pin_entry_visible ( true ) ;
148+ view_model. set_usb_nfc_pin_entry_visible ( true ) ;
175149 }
176- ViewUpdate :: NfcNeedsUserVerification { attempts_left } => {
150+ ViewUpdate :: UsbNeedsUserVerification { attempts_left }
151+ | ViewUpdate :: NfcNeedsUserVerification { attempts_left } => {
177152 let prompt = match attempts_left {
178153 Some ( 1 ) => "Touch your device again. 1 attempt remaining."
179154 . to_string( ) ,
@@ -352,11 +327,7 @@ impl ViewModel {
352327 self . set_prompt ( "Multiple devices found. Please select with which to proceed." ) ;
353328 }
354329
355- pub async fn send_usb_device_pin ( & self , pin : String ) {
356- self . send_event ( ViewEvent :: PinEntered ( pin) ) . await ;
357- }
358-
359- pub async fn send_nfc_device_pin ( & self , pin : String ) {
330+ pub async fn send_usb_nfc_device_pin ( & self , pin : String ) {
360331 self . send_event ( ViewEvent :: PinEntered ( pin) ) . await ;
361332 }
362333
0 commit comments