这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@dimaodnokoz
Copy link
Collaborator

Added public function "deactivate" to deactivate any existing dialog from outside. This will be useful in case when user inputs command with priority higher, than dialogs, and any dialog should be interrupted. The most popular case is /start command.

Copy link

@lptn lptn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. Please take a look to my suggestion and we can merge it

public function deactivate(Update $update): void
{
$dialog = $this->getDialogInstance($update);
if(isset($dialog)){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(isset($dialog)){
if ($dialog instanceof Dialog) {

according best practices, the only one valid usage of isset is to check whether a variable exist in the context.

/**
* @api Deactivate existing Dialog.
*/
public function deactivate(Update $update): void
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second thought I compared signatures of these methods:

public function activate(Dialog $dialog): void;
public function deactivate(Update $update): void;

activate is straightforward, you explicitly says which dialog to activate.

deactivate in it's current implementation forgets the active dialog state. These 2 are different conceptions: open dialog and active dialog.

  • open: any dialog that started but not finished yet
  • active: current open dialog

The packages doesn't have of limitations of a number of open dialogs.

I think such method implementation mixes these conceptions and that will lead to confusion and even bugs

@lptn lptn self-requested a review June 6, 2024 08:49
…State and validation of dialog instance changed
@dimaodnokoz
Copy link
Collaborator Author

Added discussed updates to PR

Copy link

@lptn lptn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@lptn lptn merged commit 1d84e47 into koot-labs:master Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants