@@ -13,6 +13,7 @@ use rqs_lib::hdl::TextPayloadType;
1313use tokio_util:: sync:: CancellationToken ;
1414
1515use crate :: {
16+ ext:: MessageExt ,
1617 objects:: { self , UserAction } ,
1718 utils:: { remove_notification, spawn_notification} ,
1819 window:: PacketApplicationWindow ,
@@ -55,7 +56,10 @@ pub fn present_receive_transfer_ui(
5556 notification_id : String ,
5657 auto_decline_ctk : CancellationToken ,
5758) {
58- let init_id = receive_state. event ( ) . unwrap ( ) . id . clone ( ) ;
59+ let event = receive_state
60+ . event ( )
61+ . expect ( "ReceiveTransferState.event must be set" ) ;
62+ let init_id = event. id . clone ( ) ;
5963 let win = win. clone ( ) ;
6064
6165 // Progress dialog
@@ -94,7 +98,7 @@ pub fn present_receive_transfer_ui(
9498 . build ( ) ;
9599 progress_stack. add_named ( & progress_files_box, Some ( "progress_files" ) ) ;
96100
97- let device_name = receive_state . event ( ) . unwrap ( ) . device_name ( ) ;
101+ let device_name = event. device_name ( ) ;
98102 let device_name_box = create_device_name_box ( & device_name) ;
99103 device_name_box. set_margin_bottom ( 4 ) ;
100104 progress_files_box. append ( & device_name_box) ;
@@ -169,7 +173,9 @@ pub fn present_receive_transfer_ui(
169173 auto_decline_ctk. cancel( ) ;
170174 }
171175
172- let event = receive_state. event( ) . unwrap( ) ;
176+ let event = receive_state
177+ . event( )
178+ . expect( "ReceiveTransferState.event must be set" ) ;
173179 match receive_state. user_action( ) {
174180 Some ( UserAction :: ConsentAccept ) => {
175181 consent_dialog. close( ) ;
@@ -257,8 +263,9 @@ pub fn present_receive_transfer_ui(
257263 move |receive_state| {
258264 use rqs_lib:: TransferState ;
259265
260- let event_msg = receive_state. event( ) . expect( "Property setter isn't nullable" ) ;
261- let client_msg = event_msg. msg. as_client( ) . unwrap( ) ;
266+ let event_msg = receive_state. event( ) . expect( "ReceiveTransferState.event must be set" ) ;
267+ let client_msg = event_msg. msg. as_client_unchecked( ) ;
268+ let metadata = client_msg. metadata. as_ref( ) . unwrap( ) ;
262269
263270 match client_msg. state. clone( ) . unwrap_or( TransferState :: Initial ) {
264271 TransferState :: Initial => { }
@@ -295,7 +302,7 @@ pub fn present_receive_transfer_ui(
295302 let device_name_box = create_device_name_box( & device_name) ;
296303 info_box. append( & device_name_box) ;
297304
298- let total_bytes = client_msg . metadata. as_ref ( ) . unwrap ( ) . total_bytes;
305+ let total_bytes = metadata. total_bytes;
299306 let transfer_size = human_bytes:: human_bytes( total_bytes as f64 ) ;
300307
301308 if let Some ( files) = event_msg. files( ) {
@@ -346,10 +353,9 @@ pub fn present_receive_transfer_ui(
346353 client_msg
347354 . metadata
348355 . as_ref( )
349- . unwrap( )
350- . pin_code
351- . clone( )
352- . unwrap_or_default( )
356+ . map( |it| it. pin_code. as_ref( ) . map( |it| it. as_str( ) ) )
357+ . flatten( )
358+ . unwrap_or( "???" )
353359 )
354360 . unwrap_or_else( |_| "badly formatted locale string" . into( ) ) ,
355361 )
@@ -462,7 +468,7 @@ pub fn present_receive_transfer_ui(
462468
463469 // TODO: show a progress dialog for both but with a delay?
464470 // Create Progress bar dialog
465- let total_bytes = client_msg . metadata. as_ref ( ) . unwrap ( ) . total_bytes;
471+ let total_bytes = metadata. total_bytes;
466472 receive_state
467473 . imp( )
468474 . eta
0 commit comments