Skip to content

Commit d8019f6

Browse files
committed
flicker fix for RadioBrowser actions
1 parent 23c36f1 commit d8019f6

3 files changed

Lines changed: 36 additions & 10 deletions

File tree

frontend/nextcp-ui/src/app/mediaserver/display-container/display-container-header/display-container-header.component.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,15 @@ export class DisplayContainerHeaderComponent implements OnInit {
432432

433433
private cdsBrowseFinished() {
434434
console.log('cdsBrowseFinished ... ');
435-
// A fresh browse result starts at the top, so show the full hero header.
436-
this.condensed.set(false);
437-
this.clearSearch();
435+
// The listing on screen was re-read where it stands - nobody navigated anywhere. Everything
436+
// below that belongs to arriving at a container has to stay put for it, or the header pops back
437+
// open and the quick search empties itself while the user is looking at it.
438+
const inPlace = this.contentDirectoryService().isInPlaceRefresh();
439+
if (!inPlace) {
440+
// A fresh browse result starts at the top, so show the full hero header.
441+
this.condensed.set(false);
442+
this.clearSearch();
443+
}
438444
this.fillGenres();
439445
this.readContainerRating();
440446
// A result set has no cover of its own. Blowing one hit's artwork up behind
@@ -446,8 +452,7 @@ export class DisplayContainerHeaderComponent implements OnInit {
446452
// so a reply without a cover means "not reported this time", not "has none". Clearing on that
447453
// drops the wash to black for a moment and it flickers back - keep what is up instead. Only a
448454
// real navigation may clear, because there the empty genuinely belongs to the new container.
449-
const keepLastImage =
450-
!artUrl && this.contentDirectoryService().isInPlaceRefresh();
455+
const keepLastImage = !artUrl && inPlace;
451456
if (!keepLastImage) {
452457
this.backgroundImageService.setDisplayContainerHeaderImage(artUrl);
453458
// Drive the full-screen "living canvas" wash from the item currently being

frontend/nextcp-ui/src/app/service/cds-update.service.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,30 @@ export class CdsUpdateService {
8888
*/
8989
public announceRatingChange(change: RatingChange): void {
9090
if (change.containerId) {
91-
this.pruneExpired();
92-
this.selfInflicted.set(change.containerId, Date.now());
91+
this.markOwnChange(change.containerId);
9392
}
9493
this.itemRatingChanged$.next(change);
9594
}
9695

96+
/**
97+
* Announces content this browser has written into a container - a radio station appended to a
98+
* playlist, a cover replaced. The view showing it browses again once, here; the media server's
99+
* echo of the same write is ignored, so the listing is not replaced another six times while the
100+
* server re-reads the file it was just told to change.
101+
*/
102+
public announceContainerChange(containerId: string): void {
103+
if (!containerId) {
104+
return;
105+
}
106+
this.markOwnChange(containerId);
107+
this.containerContentChanged$.next(containerId);
108+
}
109+
110+
private markOwnChange(containerId: string): void {
111+
this.pruneExpired();
112+
this.selfInflicted.set(containerId, Date.now());
113+
}
114+
97115
private isOwnChange(containerId: string): boolean {
98116
const changedAt = this.selfInflicted.get(containerId);
99117
if (changedAt === undefined) {
@@ -136,7 +154,7 @@ export class CdsUpdateService {
136154
// The media server stores the picture before it answers, so the browse
137155
// that follows already sees it.
138156
result.subscribe({
139-
next: () => this.containerContentChanged$.next(containerId),
157+
next: () => this.announceContainerChange(containerId),
140158
error: () => {},
141159
});
142160
}

frontend/nextcp-ui/src/app/service/radio-browser.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,12 @@ export class RadioBrowserService {
117117
request,
118118
'add radio station',
119119
);
120-
// the media server writes the entry before it answers, so the browse that follows sees it
120+
// The media server writes the entry before it answers, so the browse that follows sees it.
121+
// Announced rather than pushed: UMS re-reads the playlist file it was just told to change and
122+
// bumps its update id several times over, and acting on that echo browses the listing away
123+
// under the user again and again - the flicker.
121124
result.subscribe({
122-
next: () => this.cdsUpdateService.containerContentChanged$.next(playlistObjectId),
125+
next: () => this.cdsUpdateService.announceContainerChange(playlistObjectId),
123126
error: () => {},
124127
});
125128
return result;

0 commit comments

Comments
 (0)