Pinafore-Web-Client-Frontend/src/routes/_actions/stream/fillStreamingGap.js

16 lines
761 B
JavaScript
Raw Normal View History

2019-07-22 00:31:26 +02:00
// TODO: should probably just keep fetching timeline items in the gap, not stop at 40
import { addStatusesOrNotifications } from '../addStatusOrNotification'
import { getTimeline } from '../../_api/timelines'
const TIMELINE_GAP_BATCH_SIZE = 40
// fill in the "streaming gap" i.e. fetch the most recent items so that there isn't
// a big gap in the timeline if you haven't looked at it in awhile
export async function fillStreamingGap (instanceName, accessToken, timelineName, firstTimelineItemId) {
let newTimelineItems = await getTimeline(instanceName, accessToken,
timelineName, null, firstTimelineItemId, TIMELINE_GAP_BATCH_SIZE)
if (newTimelineItems.length) {
addStatusesOrNotifications(instanceName, timelineName, newTimelineItems)
}
}