fix(ActivityMonitor): prevent multiple event dispatches during polling
This commit is contained in:
@@ -22,6 +22,8 @@ class ActivityMonitor extends Component
|
|||||||
|
|
||||||
protected $activity;
|
protected $activity;
|
||||||
|
|
||||||
|
public static $eventDispatched = false;
|
||||||
|
|
||||||
protected $listeners = ['activityMonitor' => 'newMonitorActivity'];
|
protected $listeners = ['activityMonitor' => 'newMonitorActivity'];
|
||||||
|
|
||||||
public function newMonitorActivity($activityId, $eventToDispatch = 'activityFinished')
|
public function newMonitorActivity($activityId, $eventToDispatch = 'activityFinished')
|
||||||
@@ -51,15 +53,19 @@ class ActivityMonitor extends Component
|
|||||||
$causer_id = data_get($this->activity, 'causer_id');
|
$causer_id = data_get($this->activity, 'causer_id');
|
||||||
$user = User::find($causer_id);
|
$user = User::find($causer_id);
|
||||||
if ($user) {
|
if ($user) {
|
||||||
foreach ($user->teams as $team) {
|
$teamId = $user->currentTeam()->id;
|
||||||
$teamId = $team->id;
|
if (! self::$eventDispatched) {
|
||||||
$this->eventToDispatch::dispatch($teamId);
|
$this->eventToDispatch::dispatch($teamId);
|
||||||
|
self::$eventDispatched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->dispatch($this->eventToDispatch);
|
if (! self::$eventDispatched) {
|
||||||
|
$this->dispatch($this->eventToDispatch);
|
||||||
|
self::$eventDispatched = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user