@@ -212,6 +212,10 @@ def on_timeout(self, dt):
212
212
def on_leave (self , * args ):
213
213
self .timeout_event .cancel ()
214
214
215
+ if self .final_dialog is not None :
216
+ self .final_dialog .dismiss ()
217
+ self .final_dialog = None
218
+
215
219
# Called when the user wants to leave this active session.
216
220
def on_leave_product_screen_button (self ):
217
221
self .end_user_session ()
@@ -290,12 +294,13 @@ def on_confirm_payment(self, dt=None):
290
294
291
295
@mainthread
292
296
def handle_transaction_result (success : bool ):
293
- if success :
294
- # Reset instance variables
295
- self .end_user_session ()
297
+ # Reset instance variables
298
+ self .end_user_session ()
299
+
300
+ if self .shopping_cart_dialog is not None :
301
+ self .shopping_cart_dialog .dismiss ()
296
302
297
- if self .shopping_cart_dialog is not None :
298
- self .shopping_cart_dialog .dismiss ()
303
+ if success :
299
304
300
305
self .timeout_event .cancel ()
301
306
@@ -312,11 +317,6 @@ def handle_transaction_result(success: bool):
312
317
self .timeout_event = Clock .schedule_once (self .on_thanks , 5 )
313
318
self .final_dialog .open ()
314
319
else :
315
- # Reset instance variables
316
- self .end_user_session ()
317
-
318
- if self .shopping_cart_dialog is not None :
319
- self .shopping_cart_dialog .dismiss ()
320
320
321
321
self .final_dialog = MDDialog (
322
322
text = "Het is niet gelukt je aankoop te registreren. Herstart de app svp." ,
@@ -336,10 +336,6 @@ def handle_transaction_result(success: bool):
336
336
App .get_running_app ().data_controller .create_transactions , self .shopping_cart , handle_transaction_result )
337
337
338
338
def on_thanks (self , _ ):
339
- if self .final_dialog is not None :
340
- self .final_dialog .dismiss ()
341
- self .final_dialog = None
342
-
343
339
if self .manager .current == Screens .PRODUCT_SCREEN .value :
344
340
# Return to the default screen for a new user to log in
345
341
self .manager .current = Screens .DEFAULT_SCREEN .value
0 commit comments