1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 07:34:41 +01:00

Update get_dialogs (#162)

This commit is contained in:
giuseppeM99 2017-07-31 15:32:33 +02:00 committed by Daniil Gentili
parent f06e459e5d
commit 2931e96979

View File

@ -22,9 +22,15 @@ trait DialogHandler
$this->updates_state['sync_loading'] = true;
$res = ['dialogs' => [0], 'count' => 1];
$datacenter = $this->datacenter->curdc;
$peers = [];
while ($this->dialog_params['count'] < $res['count']) {
\danog\MadelineProto\Logger::log(['Getting dialogs...']);
$res = $this->method_call('messages.getDialogs', $this->dialog_params, ['datacenter' => $datacenter, 'FloodWaitLimit' => 100]);
foreach ($res['dialogs'] as $dialog) {
if (!in_array($dialog['peer'], $peers)) {
$peers[] = $dialog['peer'];
}
}
$this->dialog_params['count'] += count($res['dialogs']);
$this->dialog_params['offset_date'] = end($res['messages'])['date'];
$this->dialog_params['offset_peer'] = end($res['dialogs'])['peer'];
@ -35,5 +41,7 @@ trait DialogHandler
}
$this->updates_state['sync_loading'] = false;
return $peers;
}
}