4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-17 14:37:07 +00:00

Prevent overlapping NP checks, tweak recheck timeout on profile page.

This commit is contained in:
Buster Neece 2019-02-28 18:46:01 -06:00
parent be5c8159d3
commit 8768002113
3 changed files with 17 additions and 2 deletions

View File

@ -672,6 +672,14 @@ class Station
}
}
/**
* @param int $nowplaying_timestamp
*/
public function setNowPlayingTimestamp(int $nowplaying_timestamp): void
{
$this->nowplaying_timestamp = $nowplaying_timestamp;
}
/**
* @return int
*/

View File

@ -198,6 +198,10 @@ class NowPlaying extends AbstractTask implements EventSubscriberInterface
*/
public function queueStation(Entity\Station $station, array $extra_metadata = []): void
{
$station->setNowPlayingTimestamp(time());
$this->em->persist($station);
$this->em->flush($station);
$message = new Message\UpdateNowPlayingMessage;
$message->station_id = $station->getId();
$message->extra_metadata = $extra_metadata;
@ -215,7 +219,10 @@ class NowPlaying extends AbstractTask implements EventSubscriberInterface
try {
if ($message instanceof Message\UpdateNowPlayingMessage) {
$station = $this->em->find(Entity\Station::class, $message->station_id);
$this->processStation($station, $message->extra_metadata, true);
if ($station instanceof Entity\Station) {
$this->processStation($station, $message->extra_metadata, true);
}
}
} finally {
$this->em->clear();

View File

@ -28,7 +28,7 @@ function iterateTimer() {
if (np_elapsed == np_total) {
// If the song JUST reached its endpoint, check now-playing much sooner.
clearTimeout(nowPlayingTimeout);
nowPlayingTimeout = setTimeout(loadNowPlaying, 3000);
nowPlayingTimeout = setTimeout(loadNowPlaying, 5000);
}
}
}