about summary refs log tree commit diff
path: root/app/assets/javascripts/components/containers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-04-02 21:44:06 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-04-02 21:44:06 +0200
commitaaa4d1b0fb896f0d5f607cca3760106399caf41b (patch)
treeedc656f128443bc6ac8400e88e7267a1f3098554 /app/assets/javascripts/components/containers
parent3618cc04ffc33e434b18ef6cee2a5ef79273bf7f (diff)
Keep track of which timelines are connected live to avoid redundant
refreshes on navigation
Diffstat (limited to 'app/assets/javascripts/components/containers')
-rw-r--r--app/assets/javascripts/components/containers/mastodon.jsx13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/containers/mastodon.jsx b/app/assets/javascripts/components/containers/mastodon.jsx
index 40fbac525..6dc08bb4c 100644
--- a/app/assets/javascripts/components/containers/mastodon.jsx
+++ b/app/assets/javascripts/components/containers/mastodon.jsx
@@ -4,7 +4,9 @@ import {
   refreshTimelineSuccess,
   updateTimeline,
   deleteFromTimelines,
-  refreshTimeline
+  refreshTimeline,
+  connectTimeline,
+  disconnectTimeline
 } from '../actions/timelines';
 import { updateNotifications, refreshNotifications } from '../actions/notifications';
 import createBrowserHistory from 'history/lib/createBrowserHistory';
@@ -70,6 +72,14 @@ const Mastodon = React.createClass({
 
     this.subscription = createStream(accessToken, 'user', {
 
+      connected () {
+        store.dispatch(connectTimeline('home'));
+      },
+
+      disconnected () {
+        store.dispatch(disconnectTimeline('home'));
+      },
+
       received (data) {
         switch(data.event) {
         case 'update':
@@ -85,6 +95,7 @@ const Mastodon = React.createClass({
       },
 
       reconnected () {
+        store.dispatch(connectTimeline('home'));
         store.dispatch(refreshTimeline('home'));
         store.dispatch(refreshNotifications());
       }