Skip to content

Commit

Permalink
Fix buttons with screens
Browse files Browse the repository at this point in the history
  • Loading branch information
he110 committed Jan 16, 2020
1 parent 94014ad commit c59c83e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Telegram/Messenger.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,15 @@ public function sendScreen(MessengerScreen $screen): bool
$buttons = array();
$current = null;
$result = true;

foreach ($screen->fixItemsOrder() as $index => $item) {
if ($item instanceof Button)
$buttons[] = $item;
else {
list($current, $result, $buttons) = $this->sendScreenHelper($current, $item, $result, $buttons);
}
foreach ($screen->fixItemsOrder() as $index => $item) {
if (!($item instanceof Button)) {
list($current, $result, $btns) = $this->sendScreenHelper($current, $item, $result, $buttons);
$buttons = array_merge($buttons, $btns);
$buttons = array_unique($buttons);
}
}
$this->workWithScreenItem($current, $buttons);
Expand Down Expand Up @@ -311,6 +314,9 @@ private function buttonToArray(Button $button): array
* @param $result
* @param $buttons
* @return array
* @throws AccessTokenException
* @throws AttachmentNotFoundException
* @throws TargetUserException
*/
private function sendScreenHelper($current, $item, $result, $buttons): array
{
Expand Down

0 comments on commit c59c83e

Please sign in to comment.