Files
zulip/static/js/huddle_data.js
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00

28 lines
751 B
JavaScript

"use strict";
const _ = require("lodash");
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());
huddles = _.sortBy(huddles, (huddle) => huddle_timestamps.get(huddle));
return huddles.reverse();
};
window.huddle_data = exports;