Skip to content

Commit d13c40c

Browse files
authored
fix(ui): list of broadcast was not render (#4974)
1 parent f9d4528 commit d13c40c

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

ui/src/app/views/broadcast/list/broadcast.list.component.ts

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { AutoUnsubscribe } from '../../../shared/decorator/autoUnsubscribe';
1313
})
1414
@AutoUnsubscribe()
1515
export class BroadcastListComponent {
16-
1716
recentBroadcasts: Array<Broadcast> = [];
1817
oldBroadcasts: Array<Broadcast> = [];
1918
filteredBroadcasts: Array<Broadcast> = [];
@@ -27,23 +26,21 @@ export class BroadcastListComponent {
2726
let filterLower = filter.toLowerCase();
2827
let broadcasts = this.recentView ? this.recentBroadcasts : this.oldBroadcasts;
2928
this.filteredBroadcasts = broadcasts.filter((br) => {
30-
return br.title.toLowerCase().indexOf(filterLower) !== -1 || br.level === filter;
29+
return br.title.toLowerCase().indexOf(filterLower) !== -1 || br.level === filter;
3130
});
3231
}
3332

3433
constructor(private _broadcastStore: BroadcastStore, private _cd: ChangeDetectorRef) {
35-
this._broadcastSub = this._broadcastStore.getBroadcasts()
36-
.pipe(finalize(() => {
37-
this.loading = false;
38-
this._cd.markForCheck();
39-
}))
40-
.subscribe((broadcasts) => {
41-
this.recentBroadcasts = broadcasts.valueSeq().toArray().filter((br) => !br.read && !br.archived)
42-
.sort((a, b) => (new Date(b.updated)).getTime() - (new Date(a.updated)).getTime());
43-
this.oldBroadcasts = broadcasts.valueSeq().toArray().filter((br) => br.read || br.archived)
44-
.sort((a, b) => (new Date(b.updated)).getTime() - (new Date(a.updated)).getTime());
45-
this.filteredBroadcasts = this.recentBroadcasts;
46-
});
34+
this._broadcastSub = this._broadcastStore.getBroadcasts()
35+
.subscribe((broadcasts) => {
36+
this.recentBroadcasts = broadcasts.valueSeq().toArray().filter((br) => !br.read && !br.archived)
37+
.sort((a, b) => (new Date(b.updated)).getTime() - (new Date(a.updated)).getTime());
38+
this.oldBroadcasts = broadcasts.valueSeq().toArray().filter((br) => br.read || br.archived)
39+
.sort((a, b) => (new Date(b.updated)).getTime() - (new Date(a.updated)).getTime());
40+
this.filteredBroadcasts = this.recentBroadcasts;
41+
this.loading = false;
42+
this._cd.markForCheck();
43+
});
4744
}
4845

4946
switchToRecentView(recent: boolean) {
@@ -54,22 +51,22 @@ export class BroadcastListComponent {
5451
this.recentView = recent;
5552
if (recent) {
5653
this.filteredBroadcasts = this.recentBroadcasts.filter((br) => {
57-
return br.title.toLowerCase().indexOf(filterLower) !== -1 || br.level === this.filter;
54+
return br.title.toLowerCase().indexOf(filterLower) !== -1 || br.level === this.filter;
5855
});
5956
} else {
6057
this.filteredBroadcasts = this.oldBroadcasts.filter((br) => {
61-
return br.title.toLowerCase().indexOf(filterLower) !== -1 || br.level === this.filter;
58+
return br.title.toLowerCase().indexOf(filterLower) !== -1 || br.level === this.filter;
6259
});
6360
}
6461
}
6562

6663
markAsRead(id: number) {
67-
this.loading = true;
68-
this._broadcastStore.markAsRead(id)
69-
.pipe(finalize(() => {
70-
this.loading = false;
71-
this._cd.markForCheck();
72-
}))
73-
.subscribe();
64+
this.loading = true;
65+
this._broadcastStore.markAsRead(id)
66+
.pipe(finalize(() => {
67+
this.loading = false;
68+
this._cd.markForCheck();
69+
}))
70+
.subscribe();
7471
}
7572
}

ui/src/app/views/home/home.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ export class HomeComponent implements OnInit {
5454
this._broadcastSub = this._broadcastService.getBroadcasts()
5555
.subscribe((broadcasts) => {
5656
this.loadingBroadcasts = false;
57-
this._cd.markForCheck();
5857
if (broadcasts) {
5958
this.broadcasts = broadcasts.valueSeq().toArray().filter((br) => !br.read && !br.archived).slice(0, 5);
6059
}
60+
this._cd.markForCheck();
6161
}, () => this.loadingBroadcasts = false);
6262
}
6363

0 commit comments

Comments
 (0)