30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import ClientController from '../client-controller';
|
|
import Elements from '../elements'
|
|
import { Message } from '../data-types';
|
|
|
|
export default function createMessage(server: ClientController, message: Message, lastMessage: Message | null): HTMLElement {
|
|
let element: HTMLElement;
|
|
if (message.hasResource()) {
|
|
if (message.isImageResource()) {
|
|
if (message.isContinued(lastMessage)) {
|
|
element = Elements.createImageResourceMessageContinued(server, message);
|
|
} else {
|
|
element = Elements.createImageResourceMessage(server, message);
|
|
}
|
|
} else {
|
|
if (message.isContinued(lastMessage)) {
|
|
element = Elements.createResourceMessageContinued(server, message);
|
|
} else {
|
|
element = Elements.createResourceMessage(server, message);
|
|
}
|
|
}
|
|
} else {
|
|
if (message.isContinued(lastMessage)) {
|
|
element = Elements.createTextMessageContinued(server, message);
|
|
} else {
|
|
element = Elements.createTextMessage(server, message);
|
|
}
|
|
}
|
|
return element;
|
|
}
|