mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
fix(orbit): pending counter ignored merged/declined items
The "X / Y pending" counter in the queue head and the guest-side gate-check both used `state.queue.filter(non-host).length`, which is the *history* count — items the host has already approved or declined still sit in `state.queue` for attribution lookup, so the counter never decreased. Reported as "3 / 4 pending" with no actual rows in the approval list. The merged / declined sets only exist in the host's local store, so the guest can't filter them out itself. Solution: the host writes an authoritative `pendingApprovalCount` into the state blob each tick; guests (and the host's own UI) read it directly, with a fallback to the old over-counting behaviour for any older client that doesn't write the field. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -130,11 +130,24 @@ export function useOrbitHost(): void {
|
||||
trackId: t.id,
|
||||
addedBy: suggesterByTrack.get(t.id) ?? base.host,
|
||||
}));
|
||||
// Authoritative pending count — same predicate the approval list uses
|
||||
// (state.queue minus host-authored, minus merged, minus declined). We
|
||||
// recompute fresh each tick from the *current* store sets so an approve
|
||||
// / decline that happened mid-sweep is reflected on the very next push.
|
||||
const mergedNow = new Set(useOrbitStore.getState().mergedSuggestionKeys);
|
||||
const declinedNow = new Set(useOrbitStore.getState().declinedSuggestionKeys);
|
||||
const pendingApprovalCount = afterShuffle.queue.filter(q =>
|
||||
q.addedBy !== afterShuffle.host
|
||||
&& !mergedNow.has(suggestionKey(q))
|
||||
&& !declinedNow.has(suggestionKey(q))
|
||||
).length;
|
||||
|
||||
const next: OrbitState = {
|
||||
...afterShuffle,
|
||||
...snapshotPlayerPatch(base.host),
|
||||
playQueue,
|
||||
playQueueTotal: upcoming.length,
|
||||
pendingApprovalCount,
|
||||
};
|
||||
|
||||
// 5) Commit locally + push remote.
|
||||
|
||||
Reference in New Issue
Block a user