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:
parent
be5c8159d3
commit
8768002113
|
@ -672,6 +672,14 @@ class Station
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $nowplaying_timestamp
|
||||
*/
|
||||
public function setNowPlayingTimestamp(int $nowplaying_timestamp): void
|
||||
{
|
||||
$this->nowplaying_timestamp = $nowplaying_timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user