|
|
@@ -329,6 +329,7 @@ function onRoomUpdated() {
|
|
|
if (MSG_GROUPS[currentGroup]) {
|
|
|
if (currentMsgInGroup >= MSG_GROUPS[currentGroup].messages.length) {
|
|
|
if (!msg.removed) {
|
|
|
+ var sameDayThanPrevious = isSameDay(msg.ts, prevTs);
|
|
|
if (msg instanceof MeMessage || (prevMsg && prevMsg.userId !== msg.userId) || !msg.userId) {
|
|
|
while (MSG_GROUPS[currentGroup].content.children[currentMsgInGroup])
|
|
|
MSG_GROUPS[currentGroup].content.children[currentMsgInGroup].remove();
|
|
|
@@ -355,8 +356,7 @@ function onRoomUpdated() {
|
|
|
prevMsg = msg;
|
|
|
return;
|
|
|
}
|
|
|
- }
|
|
|
- // else message got removed
|
|
|
+ } // else message got removed
|
|
|
}
|
|
|
if (MSG_GROUPS[currentGroup]) {
|
|
|
if (MSG_GROUPS[currentGroup].messages[currentMsgInGroup] === msg.id) {
|
|
|
@@ -398,6 +398,7 @@ function onRoomUpdated() {
|
|
|
if (!MSG_GROUPS[currentGroup]) {
|
|
|
// next group
|
|
|
MSG_GROUPS[currentGroup] = createMessageGroupDom(DATA.context.getUser(msg.userId), msg.username);
|
|
|
+ /** @type {Element} */
|
|
|
var dom = msg.getDom();
|
|
|
firstTsCombo = msg.ts;
|
|
|
if ((!prevMsg || prevMsg.ts <= SELECTED_ROOM.lastRead) && msg.ts > SELECTED_ROOM.lastRead) {
|
|
|
@@ -420,6 +421,15 @@ function onRoomUpdated() {
|
|
|
currentMsgInGroup = 0;
|
|
|
firstTsCombo = msg.ts;
|
|
|
}
|
|
|
+ if (!currentMsgGroupDom || currentMsgGroupDom.content.firstChild === dom) {
|
|
|
+ if (sameDayThanPrevious) {
|
|
|
+ (currentMsgGroupDom || dom).classList.remove(R.klass.msg.firstOfDay);
|
|
|
+ } else {
|
|
|
+ (currentMsgGroupDom || dom).classList.add(R.klass.msg.firstOfDay);
|
|
|
+ (currentMsgGroupDom || dom).dataset["date"] = locale.formatDay(msg.ts);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ prevTs = msg.ts;
|
|
|
return;
|
|
|
}
|
|
|
});
|