fix: the playback-error test matches the prefixed username, and announcementFor keeps detekt's two returns (M542)
release / govulncheck (push) Successful in 15s
release / web (push) Successful in 1m25s
release / go (push) Successful in 1m35s
release / integration (push) Successful in 5m7s
release / android (push) Successful in 5m8s
release / Build signed APK (releases and dev) (push) Successful in 5m20s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 22:53:13 -04:00
co-authored by Claude Opus 5.5
parent 854c307834
commit 8538f0dc68
2 changed files with 15 additions and 13 deletions
@@ -66,18 +66,20 @@ internal sealed interface Announcement {
/** How many titles an expanded pile lists, newest first. */ /** How many titles an expanded pile lists, newest first. */
internal const val PILE_LINES = 5 internal const val PILE_LINES = 5
internal fun announcementFor(fresh: List<CachedNotificationEntity>): Announcement? { internal fun announcementFor(fresh: List<CachedNotificationEntity>): Announcement? = when {
if (fresh.isEmpty()) return null fresh.isEmpty() -> null
if (fresh.size <= INDIVIDUAL_LIMIT) return Announcement.Each(fresh) fresh.size <= INDIVIDUAL_LIMIT -> Announcement.Each(fresh)
// A pile goes where its notices would: library health only when every else -> Announcement.Pile(
// one of them is, so a listener's own news is never filed under it. count = fresh.size,
val channel = if (fresh.all { shadeChannelFor(it.kind) == ShadeChannel.LIBRARY_HEALTH }) { // A pile goes where its notices would: library health only when every
ShadeChannel.LIBRARY_HEALTH // one of them is, so a listener's own news is never filed under it.
} else { channel = if (fresh.all { shadeChannelFor(it.kind) == ShadeChannel.LIBRARY_HEALTH }) {
ShadeChannel.YOUR_REQUESTS ShadeChannel.LIBRARY_HEALTH
} } else {
val lines = fresh.sortedByDescending { it.createdAt }.take(PILE_LINES).map { it.title } ShadeChannel.YOUR_REQUESTS
return Announcement.Pile(fresh.size, channel, lines) },
lines = fresh.sortedByDescending { it.createdAt }.take(PILE_LINES).map { it.title },
)
} }
/** The phone channel per kind, as the user set it. No settings cached: on, the default for every kind. */ /** The phone channel per kind, as the user set it. No settings cached: on, the default for every kind. */
+1 -1
View File
@@ -212,7 +212,7 @@ func TestNotify_PlaybackErrorsCoalesceIntoOneCount(t *testing.T) {
got := inboxOf(t, pool, admin) got := inboxOf(t, pool, admin)
wantInbox(t, "admin", got, notifications.KindPlaybackErrors) wantInbox(t, "admin", got, notifications.KindPlaybackErrors)
if got[0].Payload.Count != 2 || len(got[0].Payload.Items) != 2 || if got[0].Payload.Count != 2 || len(got[0].Payload.Items) != 2 ||
!strings.HasSuffix(got[0].Payload.Items[0], "(np-play-alice)") { !strings.HasSuffix(got[0].Payload.Items[0], "np-play-alice)") {
t.Errorf("payload = %+v, want two reports, each naming the track and alice", got[0].Payload) t.Errorf("payload = %+v, want two reports, each naming the track and alice", got[0].Payload)
} }
wantInbox(t, "reporter", inboxOf(t, pool, alice)) wantInbox(t, "reporter", inboxOf(t, pool, alice))