don't show date & time on pending events

This commit is contained in:
Bruno Windels 2020-08-19 10:27:27 +02:00
parent 9d260c692b
commit fad728069a
2 changed files with 4 additions and 4 deletions

View file

@ -21,7 +21,7 @@ export class MessageTile extends SimpleTile {
constructor(options) { constructor(options) {
super(options); super(options);
this._isOwn = this._entry.sender === options.ownUserId; this._isOwn = this._entry.sender === options.ownUserId;
this._date = new Date(this._entry.timestamp); this._date = this._entry.timestamp ? new Date(this._entry.timestamp) : null;
this._isContinuation = false; this._isContinuation = false;
} }
@ -38,11 +38,11 @@ export class MessageTile extends SimpleTile {
} }
get date() { get date() {
return this._date.toLocaleDateString({}, {month: "numeric", day: "numeric"}); return this._date && this._date.toLocaleDateString({}, {month: "numeric", day: "numeric"});
} }
get time() { get time() {
return this._date.toLocaleTimeString({}, {hour: "numeric", minute: "2-digit"}); return this._date && this._date.toLocaleTimeString({}, {hour: "numeric", minute: "2-digit"});
} }
get isOwn() { get isOwn() {

View file

@ -20,7 +20,7 @@ import {renderMessage} from "./common.js";
export class TextMessageView extends TemplateView { export class TextMessageView extends TemplateView {
render(t, vm) { render(t, vm) {
return renderMessage(t, vm, return renderMessage(t, vm,
[t.p([vm.text, t.time(vm.date + " " + vm.time)])] [t.p([vm.text, t.time({className: {hidden: !vm.date}}, vm.date + " " + vm.time)])]
); );
} }
} }