export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
+export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';
+export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
+
export function refreshTimelineSuccess(timeline, statuses, skipLoading, next) {
return {
type: TIMELINE_REFRESH_SUCCESS,
let skipLoading = false;
if (newestId !== null && getState().getIn(['timelines', timeline, 'loaded']) && (id === null || getState().getIn(['timelines', timeline, 'id']) === id)) {
+ if (id === null && getState().getIn(['timelines', timeline, 'online'])) {
+ // Skip refreshing when timeline is live anyway
+ return;
+ }
+
params = { ...params, since_id: newestId };
skipLoading = true;
}
top
};
};
+
+export function connectTimeline(timeline) {
+ return {
+ type: TIMELINE_CONNECT,
+ timeline
+ };
+};
+
+export function disconnectTimeline(timeline) {
+ return {
+ type: TIMELINE_DISCONNECT,
+ timeline
+ };
+};
refreshTimelineSuccess,
updateTimeline,
deleteFromTimelines,
- refreshTimeline
+ refreshTimeline,
+ connectTimeline,
+ disconnectTimeline
} from '../actions/timelines';
import { updateNotifications, refreshNotifications } from '../actions/notifications';
import createBrowserHistory from 'history/lib/createBrowserHistory';
this.subscription = createStream(accessToken, 'user', {
+ connected () {
+ store.dispatch(connectTimeline('home'));
+ },
+
+ disconnected () {
+ store.dispatch(disconnectTimeline('home'));
+ },
+
received (data) {
switch(data.event) {
case 'update':
},
reconnected () {
+ store.dispatch(connectTimeline('home'));
store.dispatch(refreshTimeline('home'));
store.dispatch(refreshNotifications());
}
import {
refreshTimeline,
updateTimeline,
- deleteFromTimelines
+ deleteFromTimelines,
+ connectTimeline,
+ disconnectTimeline
} from '../../actions/timelines';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
subscription = createStream(accessToken, 'public:local', {
+ connected () {
+ dispatch(connectTimeline('community'));
+ },
+
+ reconnected () {
+ dispatch(connectTimeline('community'));
+ },
+
+ disconnected () {
+ dispatch(disconnectTimeline('community'));
+ },
+
received (data) {
switch(data.event) {
case 'update':
import {
refreshTimeline,
updateTimeline,
- deleteFromTimelines
+ deleteFromTimelines,
+ connectTimeline,
+ disconnectTimeline
} from '../../actions/timelines';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
subscription = createStream(accessToken, 'public', {
+ connected () {
+ dispatch(connectTimeline('public'));
+ },
+
+ reconnected () {
+ dispatch(connectTimeline('public'));
+ },
+
+ disconnected () {
+ dispatch(disconnectTimeline('public'));
+ },
+
received (data) {
switch(data.event) {
case 'update':
TIMELINE_EXPAND_SUCCESS,
TIMELINE_EXPAND_REQUEST,
TIMELINE_EXPAND_FAIL,
- TIMELINE_SCROLL_TOP
+ TIMELINE_SCROLL_TOP,
+ TIMELINE_CONNECT,
+ TIMELINE_DISCONNECT
} from '../actions/timelines';
import {
REBLOG_SUCCESS,
path: () => '/api/v1/timelines/home',
next: null,
isLoading: false,
+ online: false,
loaded: false,
top: true,
unread: 0,
path: () => '/api/v1/timelines/public',
next: null,
isLoading: false,
+ online: false,
loaded: false,
top: true,
unread: 0,
next: null,
params: { local: true },
isLoading: false,
+ online: false,
loaded: false,
top: true,
unread: 0,
return filterTimelines(state, action.relationship, action.statuses);
case TIMELINE_SCROLL_TOP:
return updateTop(state, action.timeline, action.top);
+ case TIMELINE_CONNECT:
+ return state.setIn([action.timeline, 'online'], true);
+ case TIMELINE_DISCONNECT:
+ return state.setIn([action.timeline, 'online'], false);
default:
return state;
}