2021-02-11 01:59:40 +01:00
|
|
|
import _ from "lodash";
|
2020-08-01 03:43:15 +02:00
|
|
|
|
2021-02-11 01:59:40 +01:00
|
|
|
import * as people from "./people";
|
2020-08-20 21:24:06 +02:00
|
|
|
|
2020-05-26 14:25:21 +02:00
|
|
|
const huddle_timestamps = new Map();
|
|
|
|
|
2021-02-11 01:59:40 +01:00
|
|
|
export function process_loaded_messages(messages) {
|
2020-05-26 14:25:21 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-11 01:59:40 +01:00
|
|
|
}
|
2020-05-26 14:25:21 +02:00
|
|
|
|
2021-02-11 01:59:40 +01:00
|
|
|
export function get_huddles() {
|
2020-05-26 14:25:21 +02:00
|
|
|
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();
|
2021-02-11 01:59:40 +01:00
|
|
|
}
|