Refactor Messages API with new types and conventions

This commit is contained in:
Kristóf Tóth 2018-05-31 12:24:34 +02:00
parent 2fdcea4af8
commit c407ce1e96
2 changed files with 8 additions and 7 deletions

View File

@ -2,7 +2,6 @@
// All Rights Reserved. See LICENSE file for details.
import { CommandMessage } from './command.message';
import { SetValueCommand } from './set.value.command';
export interface MessageControlCommand extends CommandMessage {
next_visibility?: boolean;
}
export interface MessagesControlCommand extends CommandMessage, SetValueCommand<boolean> {}

View File

@ -6,7 +6,7 @@ import { MarkdownService } from '../services/markdown.service';
import { WebSocketService } from '../services/websocket.service';
import { MessagesMessage } from '../message.types/messages.message';
import { MessageControlCommand } from '../message.types/message.control.command';
import { MessagesControlCommand } from '../message.types/messages.control.command';
import { config } from '../config';
import { CommandMessage } from '../message.types/command.message';
@ -18,7 +18,9 @@ import { CommandMessage } from '../message.types/command.message';
export class MessagesComponent implements OnInit {
messages: MessagesMessage[] = [];
showNextButton: boolean = config.messages.showNextButton;
command_handlers = {'showbutton': this.showButtonHandler.bind(this)};
command_handlers = {
'showNextButton': this.showButtonHandler.bind(this)
};
constructor(
private markdownService: MarkdownService,
@ -44,8 +46,8 @@ export class MessagesComponent implements OnInit {
return this.markdownService.convertToHtml(text);
}
showButtonHandler(data: MessageControlCommand) {
this.showNextButton = data.next_visibility;
showButtonHandler(data: MessagesControlCommand) {
this.showNextButton = data.value;
}
stepFSM() {