Use randomized setTimeout when fallback-polling and re-add since_id (#7522)
This commit is contained in:
		@@ -76,9 +76,14 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
 | 
			
		||||
 | 
			
		||||
const excludeTypesFromSettings = state => state.getIn(['settings', 'notifications', 'shows']).filter(enabled => !enabled).keySeq().toJS();
 | 
			
		||||
 | 
			
		||||
export function expandNotifications({ maxId } = {}) {
 | 
			
		||||
const noOp = () => {};
 | 
			
		||||
 | 
			
		||||
export function expandNotifications({ maxId } = {}, done = noOp) {
 | 
			
		||||
  return (dispatch, getState) => {
 | 
			
		||||
    if (getState().getIn(['notifications', 'isLoading'])) {
 | 
			
		||||
    const notifications = getState().get('notifications');
 | 
			
		||||
 | 
			
		||||
    if (notifications.get('isLoading')) {
 | 
			
		||||
      done();
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -87,6 +92,10 @@ export function expandNotifications({ maxId } = {}) {
 | 
			
		||||
      exclude_types: excludeTypesFromSettings(getState()),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    if (!maxId && notifications.get('items').size > 0) {
 | 
			
		||||
      params.since_id = notifications.getIn(['items', 0]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    dispatch(expandNotificationsRequest());
 | 
			
		||||
 | 
			
		||||
    api(getState).get('/api/v1/notifications', { params }).then(response => {
 | 
			
		||||
@@ -97,8 +106,10 @@ export function expandNotifications({ maxId } = {}) {
 | 
			
		||||
 | 
			
		||||
      dispatch(expandNotificationsSuccess(response.data, next ? next.uri : null));
 | 
			
		||||
      fetchRelatedRelationships(dispatch, response.data);
 | 
			
		||||
      done();
 | 
			
		||||
    }).catch(error => {
 | 
			
		||||
      dispatch(expandNotificationsFail(error));
 | 
			
		||||
      done();
 | 
			
		||||
    });
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user