community: a proposal on your board arrives as a toast, carried sealed through the inbox
This commit is contained in:
1 parent
4d03cf849b
commit
fd216ecd3d
6 files changed
+241
-1
No files matched your search
@@ -8,6 +8,7 @@
|
||||
// <time>", never "online"; and the adapter's states are named for what they
|
||||
// are (node stopped, incompatible, connecting), never softened.
|
||||
import * as api from "./api.js";
|
||||
import { announceProposal } from "./state.svelte.js";
|
||||
|
||||
const LS_SEEN = "community.lastSeen";
|
||||
const LS_FAVS = "community.roomFavs";
|
||||
@@ -338,6 +339,11 @@ export async function initCommunity() {
|
||||
void refreshPublished();
|
||||
});
|
||||
api.onEvent("community:overlap", () => void refreshOverlap());
|
||||
api.onEvent("community:proposal", (p) => {
|
||||
announceProposal(p.from, p.playlist);
|
||||
// If the board is already on screen, show what it is talking about.
|
||||
if (community.board && community.space) void openBoard(community.space.owner, community.space.space_id);
|
||||
});
|
||||
api.onEvent("soulseek:user-state", (p) => {
|
||||
if (p.status === 1 || p.status === 2) noteSeen(p.username);
|
||||
});
|
||||
|
||||
@@ -235,6 +235,27 @@ export function announceUpload(username, name) {
|
||||
uploadToast.seq += 1;
|
||||
}
|
||||
|
||||
/** Someone proposed a change to a playlist of ours (ProposalToast). The board
|
||||
* is only read on open and Refresh, so an arriving proposal would otherwise
|
||||
* be silent. One inbox check can dispatch several at once, so a burst on the
|
||||
* SAME playlist counts up inside one pill the way an album grab does. */
|
||||
export const proposalToast = $state({ seq: 0, from: "", playlist: "", count: 0 });
|
||||
const PROPOSAL_TOAST_WINDOW_MS = 8000;
|
||||
let proposalToastAt = 0;
|
||||
|
||||
export function announceProposal(from, playlist) {
|
||||
const now = Date.now();
|
||||
if (proposalToast.playlist === playlist && now - proposalToastAt < PROPOSAL_TOAST_WINDOW_MS) {
|
||||
proposalToast.count += 1;
|
||||
} else {
|
||||
proposalToast.playlist = playlist;
|
||||
proposalToast.count = 1;
|
||||
}
|
||||
proposalToast.from = from;
|
||||
proposalToastAt = now;
|
||||
proposalToast.seq += 1;
|
||||
}
|
||||
|
||||
/** Background-import status, read by ImportToast. The import window keeps
|
||||
* scanning/copying after it is closed (the component stays mounted, only
|
||||
* its template goes), and closed must never mean invisible: while work
|
||||
@@ -7787,6 +7808,7 @@ if (import.meta.env.DEV) {
|
||||
autoConnect, refreshSourcePrefs, _sourceAudit, sourcePrefs,
|
||||
playlistStore, refreshPlaylists, goToView, peekNextIndices,
|
||||
slsk, search, runSearch, uploadToast, announceUpload,
|
||||
proposalToast, announceProposal,
|
||||
searchTabs, selectSearchTab, closeSearchTab, filesForGroup,
|
||||
downloads, network, sendDm, openChat,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user