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"> <ul class="breadcrumb">
<li> <li>
<a <a
href="/?path=" href="/"
hx-replace-url="/?path=" hx-replace-url="/"
hx-get="/browser?path=" hx-get="/browser"
hx-vals='{"path": ""}'
hx-target=".browser" hx-target=".browser"
>Root</a> >Root</a>
</li> </li>
@ -16,7 +17,9 @@
<a <a
href="/?path={{ path[..i + 1].join("/") }}" href="/?path={{ path[..i + 1].join("/") }}"
hx-replace-url="/?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> >{{ component }}</a>
{% endif %} {% endif %}
</li> </li>
@ -37,7 +40,8 @@
</li> </li>
{% when mpd::Entry::Directory with { name, path } %} {% when mpd::Entry::Directory with { name, path } %}
<li <li
hx-get="/browser?path={{ path }}" hx-get="/browser"
hx-vals='{"path": "{{ path }}"}'
hx-replace-url="/?path={{ path }}" hx-replace-url="/?path={{ path }}"
hx-target=".browser" hx-target=".browser"
> >

View File

@ -186,12 +186,14 @@
<body hx-ext="sse" sse-connect="/sse"> <body hx-ext="sse" sse-connect="/sse">
<div <div
class="browser" 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>
<div class="player"> <div class="player">
<div hx-trigger="load,sse:player" hx-get="/player"></div> <div hx-trigger="sse:player" hx-get="/player"></div>
<div hx-trigger="load,sse:playlist,sse:player" hx-get="/queue"></div> <div hx-trigger="sse:playlist,sse:player" hx-get="/queue"></div>
</div> </div>
</body> </body>
</html> </html>