android: the room list filtered by name, the rest on demand

Soulseek lists hundreds of rooms; the phone showed the first 80 and no way
to the rest. Community → Rooms now has a filter by name and extends the
list 200 at a time.
This commit is contained in:
KeelrLeek committed 2026-09-13 21:07:11 -05:00
1 parent 60303c8a95
commit d95c3f48d1
5 files changed
+35 -2

No files matched your search

+21 -1
View File
@@ -20,7 +20,17 @@
const online = $derived(slsk.connection === "online");
const joinedNames = $derived(Object.keys(slsk.joined));
const otherRooms = $derived(slsk.rooms.filter((r) => !slsk.joined[r.name]).slice(0, 80));
/* the server's rooms: filtered by name, the biggest first, 80 at a
time with a way to the rest */
let roomQ = $state("");
let roomCap = $state(80);
const roomsMatching = $derived.by(() => {
const k = roomQ.trim().toLowerCase();
const list = slsk.rooms.filter((r) => !slsk.joined[r.name]);
return k ? list.filter((r) => r.name.toLowerCase().includes(k)) : list;
});
const otherRooms = $derived(roomsMatching.slice(0, roomCap));
$effect(() => { void roomQ; roomCap = 80; });
const threads = $derived(
Object.entries(slsk.chats)
.map(([u, c]) => ({ u, c, last: c.messages[c.messages.length - 1] }))
@@ -121,6 +131,13 @@
<div class="sec" style="padding-top:{joinedNames.length ? 18 : 8}px"><h2>Rooms <em>· {slsk.rooms.length} on the server</em></h2></div>
{#if !slsk.rooms.length}
<div class="sec-note">Asking the server for its rooms…</div>
{:else if slsk.rooms.length > 8}
<div class="sfield roomfilter">
<Icon name="search" size={18} />
<input value={roomQ} oninput={(e) => (roomQ = e.currentTarget.value)} type="search" placeholder="Find a room" autocomplete="off" autocapitalize="off" spellcheck="false" aria-label="Find a room" />
{#if roomQ}<button class="iconbtn sm" onclick={() => (roomQ = "")} aria-label="Clear"><Icon name="x" size={18} /></button>{/if}
</div>
{#if roomQ}<div class="sec-note">{roomsMatching.length} of {slsk.rooms.length} rooms</div>{/if}
{/if}
{#each otherRooms as r (r.name)}
<button class="row" onclick={() => open(r.name)}>
@@ -129,6 +146,9 @@
<span class="r"><Icon name="plus" size={18} /></span>
</button>
{/each}
{#if roomsMatching.length > roomCap}
<div style="padding: 4px var(--pad) 8px"><button class="btn btn-ghost wide" onclick={() => (roomCap += 200)}>+ {roomsMatching.length - roomCap} more rooms</button></div>
{/if}
{:else if tab === "chat"}
{#if !threads.length}
<div class="stub"><b>No conversations yet.</b>A name in a room, or a buddy, opens one.</div>