This commit is contained in:
Sijmen 2023-04-25 16:44:05 +02:00
parent adfddfc9cf
commit e51c8991ac
Signed by: vijfhoek
GPG key ID: DAF7821E067D9C48
2 changed files with 13 additions and 13 deletions

View file

@ -127,18 +127,18 @@ async fn sse(_req: tide::Request<()>, sender: tide::sse::Sender) -> tide::Result
loop { loop {
stream.write_all(b"idle playlist player\n").await?; stream.write_all(b"idle playlist player\n").await?;
loop {
buffer.clear(); buffer.clear();
reader.read_line(&mut buffer).await?; reader.read_line(&mut buffer).await?;
if buffer == "OK\n" {
break;
}
let (_, changed) = buffer let (_, changed) = buffer
.trim_end() .trim_end()
.split_once(": ") .split_once(": ")
.ok_or(anyhow!("unexpected response from MPD"))?; .ok_or(anyhow!("unexpected response from MPD"))?;
sender.send(changed, "", None).await?; sender.send(changed, "", None).await?;
buffer.clear();
reader.read_line(&mut buffer).await?;
if buffer != "OK\n" {
Err(anyhow!("mpd didn't return OK"))?;
} }
} }
} }

View file

@ -187,8 +187,8 @@
</div> </div>
<div class="player"> <div class="player">
<div hx-trigger="load,sse:queue,sse:player" hx-get="/current"></div> <div hx-trigger="load,sse:player" hx-get="/current"></div>
<div hx-trigger="load,sse:queue,sse:player" hx-get="/queue"></div> <div hx-trigger="load,sse:playlist" hx-get="/queue"></div>
</div> </div>
</body> </body>
</html> </html>