diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-11-10 18:01:39 +0100 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2018-11-13 15:54:04 +0100 |
commit | c78c80f807e5e57e549496e3a76a0743c5e44ac2 (patch) | |
tree | 132066837882fcb55e9af9e1e4a6be6573f3b170 /app/javascript/flavours/glitch/actions/notifications.js | |
parent | 5ebbaffaa308d4e0496f99321bbaeb1205bb8930 (diff) |
[Glitch] Fix loading indicator inconsistency
Port 3cecf3e5b995f5035b17fd9572c17ba1ede9346b to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/actions/notifications.js')
-rw-r--r-- | app/javascript/flavours/glitch/actions/notifications.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/javascript/flavours/glitch/actions/notifications.js b/app/javascript/flavours/glitch/actions/notifications.js index fb84cd01e..ddf14f78f 100644 --- a/app/javascript/flavours/glitch/actions/notifications.js +++ b/app/javascript/flavours/glitch/actions/notifications.js @@ -89,6 +89,7 @@ const noOp = () => {}; export function expandNotifications({ maxId } = {}, done = noOp) { return (dispatch, getState) => { const notifications = getState().get('notifications'); + const isLoadingMore = !!maxId; if (notifications.get('isLoading')) { done(); @@ -104,40 +105,43 @@ export function expandNotifications({ maxId } = {}, done = noOp) { params.since_id = notifications.getIn(['items', 0]); } - dispatch(expandNotificationsRequest()); + dispatch(expandNotificationsRequest(isLoadingMore)); api(getState).get('/api/v1/notifications', { params }).then(response => { const next = getLinks(response).refs.find(link => link.rel === 'next'); - dispatch(expandNotificationsSuccess(response.data, next ? next.uri : null)); + dispatch(expandNotificationsSuccess(response.data, next ? next.uri : null, isLoadingMore)); fetchRelatedRelationships(dispatch, response.data); done(); }).catch(error => { - dispatch(expandNotificationsFail(error)); + dispatch(expandNotificationsFail(error, isLoadingMore)); done(); }); }; }; -export function expandNotificationsRequest() { +export function expandNotificationsRequest(isLoadingMore) { return { type: NOTIFICATIONS_EXPAND_REQUEST, + skipLoading: !isLoadingMore, }; }; -export function expandNotificationsSuccess(notifications, next) { +export function expandNotificationsSuccess(notifications, next, isLoadingMore) { return { type: NOTIFICATIONS_EXPAND_SUCCESS, notifications, accounts: notifications.map(item => item.account), statuses: notifications.map(item => item.status).filter(status => !!status), next, + skipLoading: !isLoadingMore, }; }; -export function expandNotificationsFail(error) { +export function expandNotificationsFail(error, isLoadingMore) { return { type: NOTIFICATIONS_EXPAND_FAIL, error, + skipLoading: !isLoadingMore, }; }; |