shared playlists: a follow with news says so through a toast, and a follower's rows keep the owner's catalog ids
This commit is contained in:
1 parent
594a33a302
commit
8285b97cbe
5 files changed
+320
-5
No files matched your search
@@ -8,7 +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";
|
||||
import { announceProposal, announceFollowNews } from "./state.svelte.js";
|
||||
|
||||
const LS_SEEN = "community.lastSeen";
|
||||
const LS_FAVS = "community.roomFavs";
|
||||
@@ -401,7 +401,10 @@ export async function startInboxWatch() {
|
||||
}
|
||||
|
||||
/** One pass over the followed playlists, quiet like the inbox poll: the
|
||||
* backend logs what it found, and a card appears only when there is news. */
|
||||
* backend logs what it found, a card appears only when there is news, and
|
||||
* the news itself is the one thing that speaks — a toast per playlist the
|
||||
* owner changed by rows. Only the poll announces: Check now on the share
|
||||
* sheet reports in place, where the person is already looking. */
|
||||
async function pollFollows() {
|
||||
if (checkingFollows || community.busy["followcheck"]) return;
|
||||
checkingFollows = true;
|
||||
@@ -409,8 +412,9 @@ async function pollFollows() {
|
||||
if (!adapterConnected(community.freenet?.status)) return;
|
||||
await refreshFollowing();
|
||||
if (!community.following.length) return;
|
||||
await api.sharedPlaylistsCheck();
|
||||
const r = await api.sharedPlaylistsCheck();
|
||||
await refreshFollowing();
|
||||
for (const n of r?.news ?? []) announceFollowNews(n.name, n.added, n.removed);
|
||||
} catch {
|
||||
// Never surfaces; the Check now button is the one that reports.
|
||||
} finally {
|
||||
|
||||
@@ -256,6 +256,30 @@ export function announceProposal(from, playlist) {
|
||||
proposalToast.seq += 1;
|
||||
}
|
||||
|
||||
/** A playlist this device follows has news (FollowNewsToast): the owner's
|
||||
* revision added rows, or dropped some. The follow poll runs every ten
|
||||
* minutes in silence and the Inbox card only shows when the page is open,
|
||||
* so without this a new track arrives unannounced. One poll can find news
|
||||
* on several follows at once: a second playlist inside the window counts
|
||||
* up ("3 playlists have new tracks") the way a burst of proposals does,
|
||||
* and the same playlist again just replaces its line. */
|
||||
export const followNewsToast = $state({ seq: 0, name: "", added: 0, removed: 0, count: 0 });
|
||||
const FOLLOW_NEWS_TOAST_WINDOW_MS = 8000;
|
||||
let followNewsToastAt = 0;
|
||||
let followNewsToastNames = new Set();
|
||||
|
||||
export function announceFollowNews(name, added, removed) {
|
||||
const now = Date.now();
|
||||
if (now - followNewsToastAt >= FOLLOW_NEWS_TOAST_WINDOW_MS) followNewsToastNames = new Set();
|
||||
followNewsToastNames.add(name);
|
||||
followNewsToast.count = followNewsToastNames.size;
|
||||
followNewsToast.name = name;
|
||||
followNewsToast.added = added;
|
||||
followNewsToast.removed = removed;
|
||||
followNewsToastAt = now;
|
||||
followNewsToast.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
|
||||
@@ -7809,6 +7833,7 @@ if (import.meta.env.DEV) {
|
||||
playlistStore, refreshPlaylists, goToView, peekNextIndices,
|
||||
slsk, search, runSearch, uploadToast, announceUpload,
|
||||
proposalToast, announceProposal,
|
||||
followNewsToast, announceFollowNews,
|
||||
searchTabs, selectSearchTab, closeSearchTab, filesForGroup,
|
||||
downloads, network, sendDm, openChat,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user