Skip to content

Commit

Permalink
Merge pull request #36 from YvoElling/fix/close-dialog-confirmation
Browse files Browse the repository at this point in the history
Fix final 'thanks dialog' not closing when moving to a different screen.
  • Loading branch information
Staartvin authored Mar 16, 2023
2 parents 6da34f7 + 5b769f6 commit 43d7aed
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions scrs/ProductScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ def on_timeout(self, dt):
def on_leave(self, *args):
self.timeout_event.cancel()

if self.final_dialog is not None:
self.final_dialog.dismiss()
self.final_dialog = None

# Called when the user wants to leave this active session.
def on_leave_product_screen_button(self):
self.end_user_session()
Expand Down Expand Up @@ -290,12 +294,13 @@ def on_confirm_payment(self, dt=None):

@mainthread
def handle_transaction_result(success: bool):
if success:
# Reset instance variables
self.end_user_session()
# Reset instance variables
self.end_user_session()

if self.shopping_cart_dialog is not None:
self.shopping_cart_dialog.dismiss()

if self.shopping_cart_dialog is not None:
self.shopping_cart_dialog.dismiss()
if success:

self.timeout_event.cancel()

Expand All @@ -312,11 +317,6 @@ def handle_transaction_result(success: bool):
self.timeout_event = Clock.schedule_once(self.on_thanks, 5)
self.final_dialog.open()
else:
# Reset instance variables
self.end_user_session()

if self.shopping_cart_dialog is not None:
self.shopping_cart_dialog.dismiss()

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

def on_thanks(self, _):
if self.final_dialog is not None:
self.final_dialog.dismiss()
self.final_dialog = None

if self.manager.current == Screens.PRODUCT_SCREEN.value:
# Return to the default screen for a new user to log in
self.manager.current = Screens.DEFAULT_SCREEN.value
Expand Down

0 comments on commit 43d7aed

Please sign in to comment.