Skip to content

Commit

Permalink
Allow fetch old updates on start
Browse files Browse the repository at this point in the history
  • Loading branch information
xtrime-ru committed Feb 26, 2021
1 parent 9acd4e6 commit 721dd8c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function addSession(string $session, array $settings = []): MadelineProto
Files::getSessionSettings($session),
);
$instance = new MadelineProto\API($file, $settings);
$instance->unsetEventHandler();
$instance->async(true);

$this->instances[$session] = $instance;
Expand Down Expand Up @@ -159,6 +158,9 @@ function() use ($sessionName) {
yield (new Delayed(100));
}
if (static::isSessionLoggedIn($this->instances[$sessionName])) {
if (empty(EventObserver::$sessionClients[$sessionName])) {
$this->instances[$sessionName]->unsetEventHandler();
}
yield $this->instances[$sessionName]->start();
$this->instances[$sessionName]->loopFork();
}
Expand Down
2 changes: 1 addition & 1 deletion src/EventObservers/EventObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EventObserver
use ObserverTrait;

/** @var int[] */
private static array $sessionClients = [];
public static array $sessionClients = [];

public static function notify(array $update, string $sessionName) {
foreach (static::$subscribers as $clientId => $callback) {
Expand Down

0 comments on commit 721dd8c

Please sign in to comment.