community: declare what you like on soulseek, so the similar-users shelf finally has something to rank on

This commit is contained in:
KeelrLeek committed 2026-09-03 15:05:23 -05:00
1 parent 8093adc89e
commit 7b7f48ebc6
8 files changed
+5671 -5519

No files matched your search

+21 -1
View File
@@ -60,6 +60,8 @@ export const community = $state({
interests: {},
/** The server's similar-users answer, or null before it was asked. */
similar: null,
/** What this device has declared on Soulseek — the shelf's only input. */
interests: null,
/** slsk_link_status: our own verified link and everyone we verified. */
links: null,
/** username → the last failed ask's reason. */
@@ -419,6 +421,24 @@ export async function loadUserInfo(username) {
.catch((e) => (community.interests[username] = { error: String(e) }));
}
}
/** What we have told the server we like. The shelf ranks on exactly this. */
export async function refreshInterests() {
try {
community.interests = await api.slskInterestsMine();
} catch {
// not connected; the panel says so
}
}
/** Declare an interest, or take it back, then ask the server again — the
* ranking only moves when its input does. */
export const setInterest = (thing, like, on) =>
run("interest", async () => {
community.interests = await api.slskInterestSet(thing, like, on);
community.similar = null;
await loadSimilar(true);
});
export async function loadSimilar(force = false) {
if (community.similar && !force) return;
community.busy.similar = true;
@@ -706,4 +726,4 @@ export const decideProposal = (owner, space, proposal, accept, reason) =>
// Dev handle beside `__soulstream` (state.svelte.js): probes reach the store
// through this, never through a bare import (which would be a second copy).
if (import.meta.env.DEV) globalThis.__community = community;
if (import.meta.env.DEV) globalThis.__communityActions = { friendRequest, friendRequestByKey, friendAccept, friendDecline, friendRemove, friendForget, checkLink, refreshFriends, sharedPublish, sharedWithdraw, shareSend, sharePreview, shareImport, refreshShares, refreshPublished, publishInbox, checkInbox, refreshInbox, refreshSpaces, openSpace, createSpace, postToSpace, inviteToSpace, removeFromSpace, pinToSpace, leaveSpace, openBoard, proposeToBoard, decideProposal, refreshOverlap, computeOverlap, forgetOverlap };
if (import.meta.env.DEV) globalThis.__communityActions = { friendRequest, friendRequestByKey, friendAccept, friendDecline, friendRemove, friendForget, checkLink, refreshFriends, sharedPublish, sharedWithdraw, shareSend, sharePreview, shareImport, refreshShares, refreshPublished, publishInbox, checkInbox, refreshInbox, refreshSpaces, openSpace, createSpace, postToSpace, inviteToSpace, removeFromSpace, pinToSpace, leaveSpace, openBoard, proposeToBoard, decideProposal, refreshOverlap, computeOverlap, forgetOverlap, refreshInterests, setInterest };