fix: fixed track unit event handling and initialisation

This commit is contained in:
Daniel Ledda
2022-04-03 15:50:01 +02:00
parent 94e601d563
commit 77b5e25e64
5 changed files with 32 additions and 20 deletions

View File

@@ -29,17 +29,17 @@ export default class BeatView extends UINode implements ISubscriber<EventTypeSub
this.title = options.title;
this.currentOrientation = options.orientation ?? "horizontal";
this.subscription = this.beat.addSubscriber(this, EventTypeSubscriptions);
this.setupBeatViews();
this.setupTrackViews();
}
notify(publisher: unknown, event: EventTypeSubscriptions): void {
if (event === BeatEvents.TrackListChanged) {
this.setupBeatViews();
this.setupTrackViews();
this.redraw();
}
}
private setupBeatViews(): void {
private setupTrackViews(): void {
const newCount = this.beat.getTrackCount();
for (let i = 0; i < newCount; i++) {
const beat = this.beat.getTrackByIndex(i);
@@ -69,11 +69,11 @@ export default class BeatView extends UINode implements ISubscriber<EventTypeSub
this.redraw();
}
setBeatGroup(newBeatGroup: Beat): void {
this.beat = newBeatGroup;
setBeat(newBeat: Beat): void {
this.beat = newBeat;
this.subscription.unbind();
this.subscription = this.beat.addSubscriber(this, BeatEvents.TrackListChanged);
this.setupBeatViews();
this.setupTrackViews();
this.redraw();
}