about summary refs log tree commit diff
path: root/app/assets
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-17 16:36:10 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-17 16:36:10 +0200
commit8c0b19012bae203f41b75cf40d6baf121f67fdea (patch)
tree7dc72fd03f0d77d53875e8b44a85a47ec202050b /app/assets
parente906677092ca2f38abd918436ea5967c096d555f (diff)
Fix #41, debug #42
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/components/reducers/notifications.jsx22
1 files changed, 18 insertions, 4 deletions
diff --git a/app/assets/javascripts/components/reducers/notifications.jsx b/app/assets/javascripts/components/reducers/notifications.jsx
index 6ba453292..bdd2de993 100644
--- a/app/assets/javascripts/components/reducers/notifications.jsx
+++ b/app/assets/javascripts/components/reducers/notifications.jsx
@@ -7,6 +7,23 @@ import Immutable                                    from 'immutable';
 
 const initialState = Immutable.List();
 
+function notificationFromError(state, error) {
+  let n = Immutable.Map({
+    message: ''
+  });
+
+  if (error.response) {
+    n = n.withMutations(map => {
+      map.set('message', error.response.statusText);
+      map.set('title', `${error.response.status}`);
+    });
+  } else {
+    n = n.set('message', `${error}`);
+  }
+
+  return state.push(n);
+};
+
 export default function meta(state = initialState, action) {
   switch(action.type) {
     case COMPOSE_SUBMIT_FAIL:
@@ -15,10 +32,7 @@ export default function meta(state = initialState, action) {
     case REBLOG_FAIL:
     case FAVOURITE_FAIL:
     case TIMELINE_REFRESH_FAIL:
-      return state.push(Immutable.fromJS({
-        message: action.error.response.statusText,
-        title: `${action.error.response.status}`
-      }));
+      return notificationFromError(state, action.error);
     case NOTIFICATION_DISMISS:
       return state.clear();
     default: