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

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-03-09 05:10:03 +05:30
import SimpleTile from "./SimpleTile.js";
export default class MessageTile extends SimpleTile {
constructor(options) {
super(options);
this._isOwn = this._entry.sender === options.ownUserId;
this._date = new Date(this._entry.timestamp);
this._isContinuation = false;
2019-03-09 05:10:03 +05:30
}
get shape() {
return "message";
}
2019-03-09 05:10:03 +05:30
get sender() {
return this._entry.sender;
2019-03-09 05:10:03 +05:30
}
get date() {
return this._date.toLocaleDateString({}, {month: "numeric", day: "numeric"});
2019-03-09 05:10:03 +05:30
}
get time() {
return this._date.toLocaleTimeString({}, {hour: "numeric", minute: "2-digit"});
2019-03-09 05:10:03 +05:30
}
2019-06-16 14:23:23 +05:30
get isOwn() {
return this._isOwn;
}
get isContinuation() {
return this._isContinuation;
}
2019-03-09 05:10:03 +05:30
_getContent() {
return this._entry.content;
2019-03-09 05:10:03 +05:30
}
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");
}
}
2019-03-09 05:10:03 +05:30
}