From e69a39d6a7e92d43d68dd32abe5d6c899f3ed416 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Sat, 25 Jun 2022 12:36:39 +0200 Subject: [PATCH] move date up to SimpleTile we'll need it to see if we have a date separator --- src/domain/session/room/timeline/tiles/BaseMessageTile.js | 5 ----- src/domain/session/room/timeline/tiles/SimpleTile.js | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/domain/session/room/timeline/tiles/BaseMessageTile.js b/src/domain/session/room/timeline/tiles/BaseMessageTile.js index 03cc16ba..13d1dd78 100644 --- a/src/domain/session/room/timeline/tiles/BaseMessageTile.js +++ b/src/domain/session/room/timeline/tiles/BaseMessageTile.js @@ -21,7 +21,6 @@ import {getIdentifierColorNumber, avatarInitials, getAvatarHttpUrl} from "../../ export class BaseMessageTile extends SimpleTile { constructor(entry, options) { super(entry, options); - this._date = this._entry.timestamp ? new Date(this._entry.timestamp) : null; this._isContinuation = false; this._reactions = null; this._replyTile = null; @@ -78,10 +77,6 @@ export class BaseMessageTile extends SimpleTile { return this.displayName; } - get date() { - return this._date && this._date.toLocaleDateString({}, {month: "numeric", day: "numeric"}); - } - get time() { return this._date && this._date.toLocaleTimeString({}, {hour: "numeric", minute: "2-digit"}); } diff --git a/src/domain/session/room/timeline/tiles/SimpleTile.js b/src/domain/session/room/timeline/tiles/SimpleTile.js index 04141576..09e88113 100644 --- a/src/domain/session/room/timeline/tiles/SimpleTile.js +++ b/src/domain/session/room/timeline/tiles/SimpleTile.js @@ -22,6 +22,7 @@ export class SimpleTile extends ViewModel { constructor(entry, options) { super(options); this._entry = entry; + this._date = this._entry.timestamp ? new Date(this._entry.timestamp) : null; this._emitUpdate = undefined; } // view model props for all subclasses @@ -45,6 +46,10 @@ export class SimpleTile extends ViewModel { return this._entry.asEventKey(); } + get date() { + return this._date && this._date.toLocaleDateString({}, {weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'}); + } + get eventId() { return this._entry.id; }