23 lines
474 B
JavaScript
23 lines
474 B
JavaScript
import { getIO } from './realtime.js';
|
|
|
|
const MAX_FEED = 40;
|
|
const feed = [];
|
|
|
|
export function getDropFeed() {
|
|
return [...feed];
|
|
}
|
|
|
|
export function pushDrop(entry) {
|
|
const event = {
|
|
id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
at: new Date().toISOString(),
|
|
...entry,
|
|
};
|
|
feed.unshift(event);
|
|
if (feed.length > MAX_FEED) feed.length = MAX_FEED;
|
|
|
|
const io = getIO();
|
|
if (io) io.to('feed').emit('feed:drop', event);
|
|
return event;
|
|
}
|