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.
49 lines
1.2 KiB
JavaScript
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");
|
|
}
|
|
}
|
|
}
|