This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/src/domain/session/room/timeline/tiles/MessageTile.js
Bruno Windels 9b94c4bb61 don't expose raw event object from entry, pending event doesn't have it
it only has content and *some* of the meta fields,
but we want to threat pendingevententry and evententry as one
and the same in the rest of the application, so don't give access
to entire event object.
2019-07-29 10:27:12 +02:00

49 lines
1.2 KiB
JavaScript

import SimpleTile from "./SimpleTile.js";
export default class MessageTile extends SimpleTile {
constructor(options) {
super(options);
this._isOwn = this._entry.event.sender === options.ownUserId;
this._date = new Date(this._entry.timestamp);
this._isContinuation = false;
}
get shape() {
return "message";
}
get sender() {
return this._entry.sender;
}
get date() {
return this._date.toLocaleDateString({}, {month: "numeric", day: "numeric"});
}
get time() {
return this._date.toLocaleTimeString({}, {hour: "numeric", minute: "2-digit"});
}
get isOwn() {
return this._isOwn;
}
get isContinuation() {
return this._isContinuation;
}
_getContent() {
return this._entry.content;
}
updatePreviousSibling(prev) {
super.updatePreviousSibling(prev);
const isContinuation = prev && prev instanceof MessageTile && prev.sender === this.sender;
if (isContinuation !== this._isContinuation) {
this._isContinuation = isContinuation;
this.emitUpdate("isContinuation");
}
}
}