Browse Source

Fix issue daily separator was removed when at least 2 first messages of a day are sent by the same person Refs #53

isundil 6 years ago
parent
commit
3ddcd9f84d
2 changed files with 9 additions and 7 deletions
  1. 7 5
      cli/ui.js
  2. 2 2
      srv/public/mimouchat.min.js

+ 7 - 5
cli/ui.js

@@ -362,11 +362,13 @@ function onRoomUpdated() {
                     prevMsgDom = dom;
                     currentMsgGroupDom.content.appendChild(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);
+                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;
             } else {

+ 2 - 2
srv/public/mimouchat.min.js

@@ -64,8 +64,8 @@ window.toggleReaction=function(a,b,c){var d=C.a[a],e,g;(d=C.a[a])&&(e=oa(d,b))&&
 function wb(){var a=U.length,b="";if(W)b="!"+J.jb+" - Mimouchat",document.getElementById("linkFavicon").href="favicon_err.png";else if(a)b="(!"+a+")",Cb(a,a);else{var c=0;ta(C.context,function(a){a.C>a.D&&c++});c&&(b="("+c+")");Cb(0,c)}!b.length&&R&&(b=R.name);b=b.length?b:"Mimouchat";document.title=b;Db(b)}
 function Eb(){if("Notification"in window)if("granted"===Notification.permission){var a=Date.now();if(lb+3E4<a){var b=new Notification(J.Ia);lb=a;setTimeout(function(){b.close()},5E3)}}else"denied"!==Notification.permission&&Notification.requestPermission()}
 function yb(){var a=document.createDocumentFragment(),b=R.id,c=null,d=0,e=null,g=0,h;R.B?document.getElementById("chatSystemContainer").classList.add("starred"):document.getElementById("chatSystemContainer").classList.remove("starred");kb=[];C.a[b]&&C.a[b].a.forEach(function(b){if(b.h)b.$();else{var f=b.O(),k=!1;var m=new Date(b.m);var l=new Date(g);m.setHours(0);m.setMinutes(0);m.setSeconds(0);m.setMilliseconds(0);l.setHours(0);l.setMinutes(0);l.setSeconds(0);l.setMilliseconds(0);m=m.getTime()===
-l.getTime();c&&c.M===b.M&&b.M&&m?30>Math.abs(d-b.m)&&!(b instanceof x)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,k=!0);-1<Fb&&(!c||c.m<=Fb)&&b.m>Fb?(f.classList.add("chatmsg-first-unread"),f.insertBefore(Gb,f.firstChild)):f.classList.remove("chatmsg-first-unread");if(b instanceof x)e=c=null,d=0,a.appendChild(f),h=null;else{if(k||!h)h=Hb(F(b.M),b.username),kb.push(h),a.appendChild(h);c=b;e=f;h.content.appendChild(f)}m?(h||f).classList.remove("chatmsg-first-daily"):((h||f).classList.add("chatmsg-first-daily"),
-(h||f).dataset.date=J.eb(b.m));g=b.m}});var k=!0;Ib.forEach(function(b){b.channel===R.id&&(k&&(h=Hb(Q.self,""),a.appendChild(h),k=!1),h.content.appendChild(b.c))});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;wb();window.hasFocus&&zb()}
+l.getTime();c&&c.M===b.M&&b.M&&m?30>Math.abs(d-b.m)&&!(b instanceof x)?e.classList.add("chatmsg-same-ts"):d=b.m:(d=b.m,k=!0);-1<Fb&&(!c||c.m<=Fb)&&b.m>Fb?(f.classList.add("chatmsg-first-unread"),f.insertBefore(Gb,f.firstChild)):f.classList.remove("chatmsg-first-unread");if(b instanceof x)e=c=null,d=0,a.appendChild(f),h=null;else{if(k||!h)h=Hb(F(b.M),b.username),kb.push(h),a.appendChild(h);c=b;e=f;h.content.appendChild(f)}h&&h.content.firstChild!==f||(m?(h||f).classList.remove("chatmsg-first-daily"):
+((h||f).classList.add("chatmsg-first-daily"),(h||f).dataset.date=J.eb(b.m)));g=b.m}});var k=!0;Ib.forEach(function(b){b.channel===R.id&&(k&&(h=Hb(Q.self,""),a.appendChild(h),k=!1),h.content.appendChild(b.c))});b=document.getElementById("chatWindow");b.textContent="";b.appendChild(a);b.scrollTop=b.scrollHeight-b.clientHeight;wb();window.hasFocus&&zb()}
 function Jb(a,b){if(a.classList.contains("chatmsg-hover-reply"))S&&(S=null,Ab()),T!==b&&(T=b,V());else if(a.classList.contains("chatmsg-hover-reaction")){var c=R.id,d=b.id;Kb.ua(document.body,Q,function(a){a&&Bb(c,d,a)})}else a.classList.contains("chatmsg-hover-edit")?(T&&(T=null,V()),S!==b&&(S=b,Ab())):a.classList.contains("chatmsg-hover-star")?b.B?P("DELETE","api/starMsg?room="+encodeURIComponent(R.id)+"&msgId="+b.id).a():P("POST","api/starMsg?room="+encodeURIComponent(R.id)+"&msgId="+b.id).a():
 a.classList.contains("chatmsg-hover-pin")?b.pinned?Lb(R,b):P("POST","api/pinMsg?room="+encodeURIComponent(R.id)+"&msgId="+b.id).a():a.classList.contains("chatmsg-hover-remove")&&(T&&(T=null,V()),S&&(S=null,Ab()),P("DELETE","api/msg?room="+encodeURIComponent(R.id)+"&ts="+b.id).a())}function eb(a,b,c){b={channel:a.id,text:b.trim(),Ga:c,c:Mb(b,c)};Ib.push(b);a===R&&yb();return b}
 function Nb(a){function b(a,b){for(b=b||a.target;b!==a.currentTarget&&b;){if(b.id&&b.classList.contains("chatmsg-item"))return b.id;b=b.parentElement}}for(var c=a.target;c!==a.currentTarget&&c&&!c.classList.contains("chatmsg-hover");){var d;if(c.parentElement&&c.classList.contains("chatmsg-attachment-actions-item")){var e=c.dataset.attachmentIndex,g=c.dataset.actionIndex;if((d=b(a,c))&&void 0!==e&&void 0!==g){d=d.substr(d.lastIndexOf("_")+1);(a=oa(C.a[R.id],d))&&a.s[e]&&a.s[e].actions&&a.s[e].actions[g]&&