Make sure the time attribute for MAM message is parsed through moment
Messages (received directly or via MAM) are stored in a backbone collection that's kept sorted by the message's "time" attribute. Various parts of the codebase rely on this behavior. For regular messages, the time attribute is generated by `moment().format()`, which generates a timestamp in the browser's local timezone, for example "...+02:00". For MAM messages, we would previously copy the "delay.stamp" value into the "time" attribute verbatim. However, that value is generated by the server and is unlikely to be in the same timezone locale. ISO timestamps expressed in different timezones cannot be sorted lexicographically, breaking the premise of keeping the messages collection sorted by time.
This commit is contained in:
parent
15b2273631
commit
565f7d9f74
2
dist/converse.js
vendored
2
dist/converse.js
vendored
@ -62855,7 +62855,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
|
||||
'references': this.getReferencesFromStanza(stanza),
|
||||
'subject': _.propertyOf(stanza.querySelector('subject'))('textContent'),
|
||||
'thread': _.propertyOf(stanza.querySelector('thread'))('textContent'),
|
||||
'time': delay ? delay.getAttribute('stamp') : moment().format(),
|
||||
'time': delay ? moment(delay.getAttribute('stamp')).format() : moment().format(),
|
||||
'type': stanza.getAttribute('type')
|
||||
}, this.getStanzaIDs(original_stanza));
|
||||
|
||||
|
@ -747,7 +747,7 @@ converse.plugins.add('converse-chatboxes', {
|
||||
'references': this.getReferencesFromStanza(stanza),
|
||||
'subject': _.propertyOf(stanza.querySelector('subject'))('textContent'),
|
||||
'thread': _.propertyOf(stanza.querySelector('thread'))('textContent'),
|
||||
'time': delay ? delay.getAttribute('stamp') : moment().format(),
|
||||
'time': delay ? moment(delay.getAttribute('stamp')).format() : moment().format(),
|
||||
'type': stanza.getAttribute('type')
|
||||
}, this.getStanzaIDs(original_stanza));
|
||||
|
||||
|
2
src/headless/dist/converse-headless.js
vendored
2
src/headless/dist/converse-headless.js
vendored
@ -41102,7 +41102,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
|
||||
'references': this.getReferencesFromStanza(stanza),
|
||||
'subject': _.propertyOf(stanza.querySelector('subject'))('textContent'),
|
||||
'thread': _.propertyOf(stanza.querySelector('thread'))('textContent'),
|
||||
'time': delay ? delay.getAttribute('stamp') : moment().format(),
|
||||
'time': delay ? moment(delay.getAttribute('stamp')).format() : moment().format(),
|
||||
'type': stanza.getAttribute('type')
|
||||
}, this.getStanzaIDs(original_stanza));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user