2020-07-25 02:02:35 +02:00
|
|
|
const _ = require("lodash");
|
|
|
|
|
2020-05-26 14:25:21 +02:00
|
|
|
const huddle_timestamps = new Map();
|
|
|
|
|
|
|
|
exports.process_loaded_messages = function (messages) {
|
|
|
|
for (const message of messages) {
|
|
|
|
const huddle_string = people.huddle_string(message);
|
|
|
|
|
|
|
|
if (huddle_string) {
|
|
|
|
const old_timestamp = huddle_timestamps.get(huddle_string);
|
|
|
|
|
|
|
|
if (!old_timestamp || old_timestamp < message.timestamp) {
|
|
|
|
huddle_timestamps.set(huddle_string, message.timestamp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.get_huddles = function () {
|
|
|
|
let huddles = Array.from(huddle_timestamps.keys());
|
2020-07-02 01:45:54 +02:00
|
|
|
huddles = _.sortBy(huddles, (huddle) => huddle_timestamps.get(huddle));
|
2020-05-26 14:25:21 +02:00
|
|
|
return huddles.reverse();
|
|
|
|
};
|
|
|
|
|
|
|
|
window.huddle_data = exports;
|