You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
647 B
JavaScript

"use strict";
module.exports = function (a, b) {
if (a.type === "roomStateUpdate" && b.type === "roomTimelineEvent") {
// Sort roomStateUpdates towards the front
return -1;
} else if (a.type === "roomTimelineEvent" && b.type === "roomStateUpdate") {
return 1;
} else if (a.timestamp == null && b.timestamp != null) {
// Sort timestamp-less events towards the front
return -1;
} else if (a.timestamp != null && b.timestamp == null) {
return 1;
} else if (a.timestamp == null && b.timestamp == null) {
// Keep timestamp-less events stable, relative to each other
return 0;
} else {
return (a.timestamp - b.timestamp);
}
};