diff --git a/README.md b/README.md index 3036b969f..ec9c5f79a 100644 --- a/README.md +++ b/README.md @@ -72,23 +72,23 @@ Things might work in Edge 15-18, Firefox 47-62 and Chrome 54-68 due to one polyf |js/* |1.14.0 |native |gzip 1.14 |gzip | |----------- |--------: |--------: |--------: |--------: | -|admin.js |2.130.942 |1.216.173 | 485.481 | 298.376 | -|app.js |4.184.455 |2.961.284 | 932.725 | 691.792 | -|boot.js | 671.522 | 94.230 | 169.502 | 28.382 | +|admin.js |2.130.942 |1.210.394 | 485.481 | 298.376 | +|app.js |4.184.455 |2.954.996 | 932.725 | 691.792 | +|boot.js | 671.522 | 93.585 | 169.502 | 28.382 | |libs.js | 647.614 | 458.656 | 194.728 | 139.408 | |polyfills.js | 325.834 | 0 | 71.825 | 0 | -|TOTAL js |7.960.367 |4.730.343 |1.854.261 |1.157.958 | +|TOTAL js |7.960.367 |4.717.631 |1.854.261 |1.157.958 | |js/min/* |1.14.0 |native |gzip 1.14 |gzip | |--------------- |--------: |--------: |--------: |--------: | -|admin.min.js | 252.147 | 156.868 | 73.657 | 44.788 | -|app.min.js | 511.202 | 384.861 |140.462 |101.677 | -|boot.min.js | 66.007 | 11.575 | 22.567 | 4.460 | +|admin.min.js | 252.147 | 156.171 | 73.657 | 44.788 | +|app.min.js | 511.202 | 384.195 |140.462 |101.677 | +|boot.min.js | 66.007 | 11.545 | 22.567 | 4.460 | |libs.min.js | 572.545 | 413.971 |176.720 |129.076 | |polyfills.min.js | 32.452 | 0 | 11.312 | 0 | -|TOTAL js/min |1.434.353 | 967.275 |424.718 |280.001 | +|TOTAL js/min |1.434.353 | 965.882 |424.718 |280.001 | -467.078 bytes (144.717 gzip) is not much, but it feels faster. +468.471 bytes (144.717 gzip) is not much, but it feels faster. |css/* |1.14.0 |native | diff --git a/dev/Common/Momentor.js b/dev/Common/Momentor.js index 025b7a1fe..e71ea2ff5 100644 --- a/dev/Common/Momentor.js +++ b/dev/Common/Momentor.js @@ -3,39 +3,24 @@ import $ from '$'; import { i18n } from 'Common/Translator'; let _moment = null; -let _momentNow = 0; - -var d, du; -const updateMomentNow = ()=>{ - // leading debounce - if (!d) { - d = setTimeout(()=>d=0, 500); - _moment = new Date(); - } -}; - -const updateMomentNowUnix = ()=>{ - // leading debounce - if (!du) { - du = setTimeout(()=>du=0, 500); - _momentNow = new Date().getTime(); - } -}; +let d; /** * @returns {moment} */ -export function momentNow() { - updateMomentNow(); - return _moment || new Date(); +function momentNow() { + if (!d) { + d = setTimeout(()=>d=0, 500); + _moment = new Date(); + } + return _moment; } /** * @returns {number} */ export function momentNowUnix() { - updateMomentNowUnix(); - return _momentNow || 0; + return momentNow().getTime() / 1000; } /** @@ -46,7 +31,7 @@ function formatCustomShortDate(m) { const now = momentNow(); if (m && now) { switch (true) { - case 4 >= (now.getTime() - m.getTime()) / 3600: + case 4 >= (now.getTime() - m.getTime()) / 3600000: return m.fromNow(); case now.format('L') === m.format('L'): return i18n('MESSAGE_LIST/TODAY_AT', { diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index 773c25fe4..485883477 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -745,14 +745,13 @@ class MessageUserStore { unreadCountChange = false; const list = [], - utc = momentNowUnix(), iCount = pInt(data.Result.MessageResultCount), iOffset = pInt(data.Result.Offset); const folder = getFolderFromCacheList(isNormal(data.Result.Folder) ? data.Result.Folder : ''); if (folder && !cached) { - folder.interval = utc; + folder.interval = momentNowUnix(); setFolderHash(data.Result.Folder, data.Result.FolderHash);