Added debouncing to markReadNotifications and fetchComments

• Added:
- debouncing to markReadNotifications and fetchComments
This commit is contained in:
mgabdev
2021-01-09 01:50:18 -05:00
parent 1da4cb9f0f
commit 8c7a52065c
2 changed files with 20 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import api, { getLinks } from '../api'
import debounce from 'lodash.debounce'
import IntlMessageFormat from 'intl-messageformat'
import noop from 'lodash.noop'
import { fetchRelationships } from './accounts'
@@ -262,9 +263,14 @@ export const setFilter = (path, value) => (dispatch) => {
/**
*
*/
export const markReadNotifications = () => (dispatch, getState) => {
if (!me) return
debouncedMarkReadNotifications(dispatch, getState)
}
export const debouncedMarkReadNotifications = debounce((dispatch, getState) => {
if (!me) return
const topNotification = parseInt(getState().getIn(['notifications', 'items', 0, 'id']))
const lastReadId = getState().getIn(['notifications', 'lastReadId'])
@@ -278,4 +284,4 @@ export const markReadNotifications = () => (dispatch, getState) => {
})
})
}
}
}, 5000, { leading: true })