about summary refs log tree commit diff
path: root/app/javascript/mastodon/actions/notifications.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-06-11 17:07:35 +0200
committerGitHub <noreply@github.com>2017-06-11 17:07:35 +0200
commit47bf7a8047ce59b899d147e4483168f9852eeb7c (patch)
tree79dd51ed84b1ed350cd754c8fca988dd6718a93a /app/javascript/mastodon/actions/notifications.js
parent85d405c810a3bfc146c7901d770444419f32e46f (diff)
Fix #3665 - Refactor timelines reducer (#3686)
* Move ancestors/descendants out of timelines reducer

* Refactor timelines reducer

All types of timelines now have a flat structure and use the same
reducer functions and actions

* Reintroduce some missing behaviours

* Fix wrong import in reports

* Fix includes typo

* Fix issue related to "next" pagination in timelines and notifications

* Fix bug with timeline's initial state, expandNotifications
Diffstat (limited to 'app/javascript/mastodon/actions/notifications.js')
-rw-r--r--app/javascript/mastodon/actions/notifications.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/app/javascript/mastodon/actions/notifications.js b/app/javascript/mastodon/actions/notifications.js
index 51b06ed32..d3de2d871 100644
--- a/app/javascript/mastodon/actions/notifications.js
+++ b/app/javascript/mastodon/actions/notifications.js
@@ -124,25 +124,22 @@ export function refreshNotificationsFail(error, skipLoading) {
 
 export function expandNotifications() {
   return (dispatch, getState) => {
-    const url    = getState().getIn(['notifications', 'next'], null);
-    const lastId = getState().getIn(['notifications', 'items']).last();
+    const items  = getState().getIn(['notifications', 'items'], Immutable.List());
 
-    if (url === null || getState().getIn(['notifications', 'isLoading'])) {
+    if (getState().getIn(['notifications', 'isLoading']) || items.size === 0) {
       return;
     }
 
-    dispatch(expandNotificationsRequest());
-
     const params = {
-      max_id: lastId,
+      max_id: items.last().get('id'),
       limit: 20,
+      exclude_types: excludeTypesFromSettings(getState()),
     };
 
-    params.exclude_types = excludeTypesFromSettings(getState());
+    dispatch(expandNotificationsRequest());
 
-    api(getState).get(url, params).then(response => {
+    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));
       fetchRelatedRelationships(dispatch, response.data);
     }).catch(error => {