refactor: extend store with current epg program field

This commit is contained in:
4gray committed 2021-07-05 18:45:04 +02:00
1 parent 9f5014021c
commit 0116a63823
2 files changed
+15

No files matched your search

@@ -105,6 +105,7 @@ export class EpgListComponent {
} else {
this.items = [];
this.channel = null;
this.channelStore.setCurrentEpgProgram(undefined);
}
}
@@ -155,6 +156,7 @@ export class EpgListComponent {
this.playingNow = this.items.find(
(item) => this.timeNow >= item.start && this.timeNow <= item.stop
);
this.channelStore.setCurrentEpgProgram(this.playingNow);
}
/**
+13
View File
@@ -9,6 +9,7 @@ import { EpgProgram } from '../player/models/epg-program.model';
export interface ChannelState extends EntityState<Channel> {
active: Channel;
epgAvailable: boolean;
currentEpgProgram: EpgProgram;
favorites: string[];
playlistId: string;
}
@@ -23,6 +24,7 @@ export class ChannelStore extends EntityStore<ChannelState> {
constructor(private electronService: ElectronService) {
super({
active: undefined,
currentEpgProgram: undefined,
epgAvailable: false,
favorites: [],
playlistId: '',
@@ -123,4 +125,15 @@ export class ChannelStore extends EntityStore<ChannelState> {
};
});
}
/**
* Updates the active epg program for the active channel
* @param currentEpgProgram program to set
*/
setCurrentEpgProgram(currentEpgProgram: EpgProgram): void {
this.update((store) => ({
...store,
currentEpgProgram,
}));
}
}