diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-05-18 02:32:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-18 02:32:35 +0200 |
commit | dafd7afc5ef94fc9513efa341910f7e3c31b909a (patch) | |
tree | 518bc8f9b69cd7d9dd50dcdf3b81c7d561f42cb9 /app/javascript/mastodon/actions/notifications.js | |
parent | 1e02dc871533de78174b48a6a527f11b0f2bc7ec (diff) |
Use randomized setTimeout when fallback-polling and re-add since_id (#7522)
Diffstat (limited to 'app/javascript/mastodon/actions/notifications.js')
-rw-r--r-- | app/javascript/mastodon/actions/notifications.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/javascript/mastodon/actions/notifications.js b/app/javascript/mastodon/actions/notifications.js index 393268811..641ad0e14 100644 --- a/app/javascript/mastodon/actions/notifications.js +++ b/app/javascript/mastodon/actions/notifications.js @@ -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(); }); }; }; |