Fix issue where browser would show wrong directory

This commit is contained in:
Sijmen 2023-04-27 05:01:36 +02:00
parent 4dc3368da9
commit 5d34359eb1
Signed by: vijfhoek
GPG Key ID: DAF7821E067D9C48
2 changed files with 15 additions and 9 deletions

View File

@ -2,9 +2,10 @@
<ul class="breadcrumb">
<li>
<a
href="/?path="
hx-replace-url="/?path="
hx-get="/browser?path="
href="/"
hx-replace-url="/"
hx-get="/browser"
hx-vals='{"path": ""}'
hx-target=".browser"
>Root</a>
</li>
@ -16,7 +17,9 @@
<a
href="/?path={{ path[..i + 1].join("/") }}"
hx-replace-url="/?path={{ path[..i + 1].join("/") }}"
hx-get="/browser?path={{ path[..i + 1].join("/") }}" hx-target=".browser"
hx-get="/browser"
hx-vals='{"path": "{{ path[..i + 1].join("/") }}"}'
hx-target=".browser"
>{{ component }}</a>
{% endif %}
</li>
@ -37,7 +40,8 @@
</li>
{% when mpd::Entry::Directory with { name, path } %}
<li
hx-get="/browser?path={{ path }}"
hx-get="/browser"
hx-vals='{"path": "{{ path }}"}'
hx-replace-url="/?path={{ path }}"
hx-target=".browser"
>
@ -45,7 +49,7 @@
<div class="song__name">{{ name }}</div>
</li>
{% when mpd::Entry::Playlist with { name, path } %}
<li hx-post="/queue?path={{path}}" hx-swap="none" role="button" >
<li hx-post="/queue?path={{ path }}" hx-swap="none" role="button" >
<span class="material-symbols-outlined">playlist_play</span>
<div class="song">
<div class="song__name">{{ name }}</div>

View File

@ -186,12 +186,14 @@
<body hx-ext="sse" sse-connect="/sse">
<div
class="browser"
hx-trigger="load,sse:database" hx-get="/browser?path={{ path }}"
hx-trigger="load,sse:database"
hx-get="/browser"
hx-vals="js:{path: new URLSearchParams(window.location.search).get('path') || ''}"
></div>
<div class="player">
<div hx-trigger="load,sse:player" hx-get="/player"></div>
<div hx-trigger="load,sse:playlist,sse:player" hx-get="/queue"></div>
<div hx-trigger="sse:player" hx-get="/player"></div>
<div hx-trigger="sse:playlist,sse:player" hx-get="/queue"></div>
</div>
</body>
</html>