fix auto-loading of toot content as you scroll (#529)

This commit is contained in:
Nolan Lawson 2018-09-01 14:11:39 -07:00 committed by GitHub
parent 9d27ba6c10
commit 20dda272ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,8 +10,6 @@ import { getStatus, getStatusContext } from '../_api/statuses'
import { emit } from '../_utils/eventBus' import { emit } from '../_utils/eventBus'
import { TIMELINE_BATCH_SIZE } from '../_static/timelines' import { TIMELINE_BATCH_SIZE } from '../_static/timelines'
const SCROLL_TO_BOTTOM_DELAY = 2000
async function storeFreshTimelineItemsInDatabase (instanceName, timelineName, items) { async function storeFreshTimelineItemsInDatabase (instanceName, timelineName, items) {
await database.insertTimelineItems(instanceName, timelineName, items) await database.insertTimelineItems(instanceName, timelineName, items)
if (timelineName.startsWith('status/')) { if (timelineName.startsWith('status/')) {
@ -119,10 +117,8 @@ export async function fetchTimelineItemsOnScrollToBottom (instanceName, timeline
console.log('setting runningUpdate: true') console.log('setting runningUpdate: true')
store.setForTimeline(instanceName, timelineName, { runningUpdate: true }) store.setForTimeline(instanceName, timelineName, { runningUpdate: true })
await fetchTimelineItemsAndPossiblyFallBack() await fetchTimelineItemsAndPossiblyFallBack()
setTimeout(() => {
console.log('setting runningUpdate: false') console.log('setting runningUpdate: false')
store.setForTimeline(instanceName, timelineName, { runningUpdate: false }) store.setForTimeline(instanceName, timelineName, { runningUpdate: false })
}, SCROLL_TO_BOTTOM_DELAY) // delay to avoid spamming network calls on scroll to bottom
} }
export async function showMoreItemsForTimeline (instanceName, timelineName) { export async function showMoreItemsForTimeline (instanceName, timelineName) {