Don't show a popup if there's nothing to say
This commit is contained in:
parent
f59c39be6e
commit
06e5470c4d
1 changed files with 19 additions and 12 deletions
|
|
@ -97,21 +97,28 @@ class ThreadPlumbing:
|
||||||
if self.ui_caller:
|
if self.ui_caller:
|
||||||
self.ui_caller(result)
|
self.ui_caller(result)
|
||||||
|
|
||||||
# Show popup and wait for user choice
|
# do we need to decide on an action?
|
||||||
choice = bool(result.function_choice)
|
choice = bool(result.function_choice)
|
||||||
logger.info(f"On the main thread, the choice is {choice}")
|
|
||||||
|
|
||||||
|
# if there's a message or a choice to make:
|
||||||
|
if result.message or choice:
|
||||||
|
# Then Show popup and wait for user choice
|
||||||
|
popup = self.error_implementation(
|
||||||
|
choice=bool(result.function_choice),
|
||||||
|
title=f"Error: {result.error_type.value}",
|
||||||
|
message=result.message,
|
||||||
|
on_answer=self._on_popup_answer,
|
||||||
|
passed_result=result,
|
||||||
|
end_app=False
|
||||||
|
)
|
||||||
|
# framework neutral show method
|
||||||
|
popup.show()
|
||||||
|
|
||||||
|
# otherwise return it as is:
|
||||||
|
else:
|
||||||
|
if self.ui_caller:
|
||||||
|
self.ui_caller(passed_result)
|
||||||
|
|
||||||
popup = self.error_implementation(
|
|
||||||
choice=bool(result.function_choice),
|
|
||||||
title=f"Error: {result.error_type.value}",
|
|
||||||
message=result.message,
|
|
||||||
on_answer=self._on_popup_answer,
|
|
||||||
passed_result=result,
|
|
||||||
end_app=False
|
|
||||||
)
|
|
||||||
# framework neutral show method
|
|
||||||
popup.show()
|
|
||||||
|
|
||||||
def _on_popup_answer(self, user_choice: bool, passed_result: Result):
|
def _on_popup_answer(self, user_choice: bool, passed_result: Result):
|
||||||
"""User responded to popup"""
|
"""User responded to popup"""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue