move date up to SimpleTile

we'll need it to see if we have a date separator
This commit is contained in:
Bruno Windels 2022-06-25 12:36:39 +02:00
parent 623939c671
commit e69a39d6a7
2 changed files with 5 additions and 5 deletions

View file

@ -21,7 +21,6 @@ import {getIdentifierColorNumber, avatarInitials, getAvatarHttpUrl} from "../../
export class BaseMessageTile extends SimpleTile { export class BaseMessageTile extends SimpleTile {
constructor(entry, options) { constructor(entry, options) {
super(entry, options); super(entry, options);
this._date = this._entry.timestamp ? new Date(this._entry.timestamp) : null;
this._isContinuation = false; this._isContinuation = false;
this._reactions = null; this._reactions = null;
this._replyTile = null; this._replyTile = null;
@ -78,10 +77,6 @@ export class BaseMessageTile extends SimpleTile {
return this.displayName; return this.displayName;
} }
get date() {
return this._date && this._date.toLocaleDateString({}, {month: "numeric", day: "numeric"});
}
get time() { get time() {
return this._date && this._date.toLocaleTimeString({}, {hour: "numeric", minute: "2-digit"}); return this._date && this._date.toLocaleTimeString({}, {hour: "numeric", minute: "2-digit"});
} }

View file

@ -22,6 +22,7 @@ export class SimpleTile extends ViewModel {
constructor(entry, options) { constructor(entry, options) {
super(options); super(options);
this._entry = entry; this._entry = entry;
this._date = this._entry.timestamp ? new Date(this._entry.timestamp) : null;
this._emitUpdate = undefined; this._emitUpdate = undefined;
} }
// view model props for all subclasses // view model props for all subclasses
@ -45,6 +46,10 @@ export class SimpleTile extends ViewModel {
return this._entry.asEventKey(); return this._entry.asEventKey();
} }
get date() {
return this._date && this._date.toLocaleDateString({}, {weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'});
}
get eventId() { get eventId() {
return this._entry.id; return this._entry.id;
} }