Skip to content

Commit 43d7aed

Browse files
authored
Merge pull request #36 from YvoElling/fix/close-dialog-confirmation
Fix final 'thanks dialog' not closing when moving to a different screen.
2 parents 6da34f7 + 5b769f6 commit 43d7aed

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

scrs/ProductScreen.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ def on_timeout(self, dt):
212212
def on_leave(self, *args):
213213
self.timeout_event.cancel()
214214

215+
if self.final_dialog is not None:
216+
self.final_dialog.dismiss()
217+
self.final_dialog = None
218+
215219
# Called when the user wants to leave this active session.
216220
def on_leave_product_screen_button(self):
217221
self.end_user_session()
@@ -290,12 +294,13 @@ def on_confirm_payment(self, dt=None):
290294

291295
@mainthread
292296
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()
296302

297-
if self.shopping_cart_dialog is not None:
298-
self.shopping_cart_dialog.dismiss()
303+
if success:
299304

300305
self.timeout_event.cancel()
301306

@@ -312,11 +317,6 @@ def handle_transaction_result(success: bool):
312317
self.timeout_event = Clock.schedule_once(self.on_thanks, 5)
313318
self.final_dialog.open()
314319
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()
320320

321321
self.final_dialog = MDDialog(
322322
text="Het is niet gelukt je aankoop te registreren. Herstart de app svp.",
@@ -336,10 +336,6 @@ def handle_transaction_result(success: bool):
336336
App.get_running_app().data_controller.create_transactions, self.shopping_cart, handle_transaction_result)
337337

338338
def on_thanks(self, _):
339-
if self.final_dialog is not None:
340-
self.final_dialog.dismiss()
341-
self.final_dialog = None
342-
343339
if self.manager.current == Screens.PRODUCT_SCREEN.value:
344340
# Return to the default screen for a new user to log in
345341
self.manager.current = Screens.DEFAULT_SCREEN.value

0 commit comments

Comments
 (0)