Update the State Management code

This commit is contained in:
Tim Bentley 2020-06-20 07:25:20 +00:00
parent 24c74ab3c9
commit 2d8ee13fc7
3 changed files with 3 additions and 16 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@openlp/web-remote",
"version": "0.9.3",
"version": "0.9.4",
"description": "The web remote for OpenLP, written in Angular",
"keywords": ["OpenLP", "Angular", "Remote"],
"homepage": "https://openlp.org/",

View File

@ -12,7 +12,7 @@ export class MainViewComponent implements OnInit {
ngOnInit() {
this.updateImage();
this.openlpService.liveChanged$.subscribe(item => this.updateImage());
this.openlpService.stateChanged$.subscribe(item => this.updateImage());
}
updateImage(): void {

View File

@ -36,7 +36,6 @@ const httpOptions = {
export class OpenLPService {
private apiURL: string;
public stateChanged$: EventEmitter<State>;
public liveChanged$: EventEmitter<State>;
constructor(private http: HttpClient) {
const host = window.location.hostname;
@ -51,7 +50,7 @@ export class OpenLPService {
this.stateChanged$ = new EventEmitter<State>();
this.retrieveSystemInformation().subscribe(info => {
const ws = new WebSocket(`ws://${host}:${info.websocket_port}/state`);
const ws = new WebSocket(`ws://${host}:${info.websocket_port}`);
ws.onmessage = (event) => {
const reader = new FileReader();
reader.onload = () => {
@ -61,18 +60,6 @@ export class OpenLPService {
reader.readAsText(event.data);
};
});
this.liveChanged$ = new EventEmitter<State>();
this.retrieveSystemInformation().subscribe(info => {
const ws = new WebSocket(`ws://${host}:${info.websocket_port}/live_changed`);
ws.onmessage = (event) => {
const reader = new FileReader();
reader.onload = () => {
const state = deserialize(JSON.parse(reader.result as string).results, State);
this.liveChanged$.emit(state);
};
reader.readAsText(event.data);
};
});
}
setAuthToken(token: string): void {