forked from cybrespace/pinafore
be less aggressive about throttling notifications
This commit is contained in:
parent
3458c353e4
commit
cfb8e28fcc
|
@ -5,6 +5,7 @@ import { store } from '../_store/store'
|
|||
import { scheduleIdleTask } from '../_utils/scheduleIdleTask'
|
||||
import uniqBy from 'lodash/uniqBy'
|
||||
import uniq from 'lodash/uniq'
|
||||
import { isMobile } from '../_utils/isMobile'
|
||||
|
||||
function getExistingItemIdsSet (instanceName, timelineName) {
|
||||
let timelineItemIds = store.getForTimeline(instanceName, timelineName, 'timelineItemIds') || []
|
||||
|
@ -70,10 +71,11 @@ async function processFreshUpdates (instanceName, timelineName) {
|
|||
}
|
||||
|
||||
const lazilyProcessFreshUpdates = throttle((instanceName, timelineName) => {
|
||||
scheduleIdleTask(() => {
|
||||
const runTask = isMobile() ? scheduleIdleTask : requestAnimationFrame
|
||||
runTask(() => {
|
||||
/* no await */ processFreshUpdates(instanceName, timelineName)
|
||||
})
|
||||
}, 5000)
|
||||
}, 3000)
|
||||
|
||||
export function addStatusOrNotification (instanceName, timelineName, newStatusOrNotification) {
|
||||
addStatusesOrNotifications(instanceName, timelineName, [newStatusOrNotification])
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { TimelineStream } from '../_api/TimelineStream'
|
||||
import { scheduleIdleTask } from '../_utils/scheduleIdleTask'
|
||||
import { mark, stop } from '../_utils/marks'
|
||||
import { deleteStatus } from './deleteStatuses'
|
||||
import { addStatusOrNotification } from './addStatusOrNotification'
|
||||
|
@ -29,9 +28,7 @@ export function createStream (streamingApi, instanceName, accessToken,
|
|||
console.error("don't know how to handle event", msg)
|
||||
return
|
||||
}
|
||||
scheduleIdleTask(() => {
|
||||
processMessage(instanceName, timelineName, msg)
|
||||
})
|
||||
},
|
||||
onOpen () {
|
||||
if (onOpenStream) {
|
||||
|
|
Loading…
Reference in New Issue