Skip to content

Commit

Permalink
Fix #47 by renaming TIMELINE_SET action to TIMELINE_REFRESH_SUCCESS
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Sep 20, 2016
1 parent 1d2856c commit 6d89edc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
11 changes: 2 additions & 9 deletions app/assets/javascripts/components/actions/timelines.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import api from '../api'

export const TIMELINE_SET = 'TIMELINE_SET';
export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
export const TIMELINE_DELETE = 'TIMELINE_DELETE';

Expand All @@ -12,9 +11,9 @@ export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
export const TIMELINE_EXPAND_SUCCESS = 'TIMELINE_EXPAND_SUCCESS';
export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';

export function setTimeline(timeline, statuses) {
export function refreshTimelineSuccess(timeline, statuses) {
return {
type: TIMELINE_SET,
type: TIMELINE_REFRESH_SUCCESS,
timeline: timeline,
statuses: statuses
};
Expand Down Expand Up @@ -54,12 +53,6 @@ export function refreshTimeline(timeline) {
};
};

export function refreshTimelineSuccess(timeline, statuses) {
return function (dispatch) {
dispatch(setTimeline(timeline, statuses));
};
};

export function refreshTimelineFail(timeline, error) {
return {
type: TIMELINE_REFRESH_FAIL,
Expand Down
31 changes: 18 additions & 13 deletions app/assets/javascripts/components/containers/mastodon.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { Provider } from 'react-redux';
import configureStore from '../store/configureStore';
import { setTimeline, updateTimeline, deleteFromTimelines, refreshTimeline } from '../actions/timelines';
import { setAccessToken } from '../actions/meta';
import { setAccountSelf } from '../actions/accounts';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import { Router, Route, hashHistory } from 'react-router';
import Account from '../features/account';
import Settings from '../features/settings';
import Status from '../features/status';
import Subscriptions from '../features/subscriptions';
import UI from '../features/ui';
import { Provider } from 'react-redux';
import configureStore from '../store/configureStore';
import {
refreshTimelineSuccess,
updateTimeline,
deleteFromTimelines,
refreshTimeline
} from '../actions/timelines';
import { setAccessToken } from '../actions/meta';
import { setAccountSelf } from '../actions/accounts';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import { Router, Route, hashHistory } from 'react-router';
import Account from '../features/account';
import Settings from '../features/settings';
import Status from '../features/status';
import Subscriptions from '../features/subscriptions';
import UI from '../features/ui';

const store = configureStore();

Expand All @@ -29,7 +34,7 @@ const Mastodon = React.createClass({

for (var timelineType in this.props.timelines) {
if (this.props.timelines.hasOwnProperty(timelineType)) {
store.dispatch(setTimeline(timelineType, JSON.parse(this.props.timelines[timelineType])));
store.dispatch(refreshTimelineSuccess(timelineType, JSON.parse(this.props.timelines[timelineType])));
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/components/reducers/timelines.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
TIMELINE_SET,
TIMELINE_REFRESH_SUCCESS,
TIMELINE_UPDATE,
TIMELINE_DELETE
} from '../actions/timelines';
Expand Down Expand Up @@ -139,7 +139,7 @@ function normalizeContext(state, status, ancestors, descendants) {

export default function timelines(state = initialState, action) {
switch(action.type) {
case TIMELINE_SET:
case TIMELINE_REFRESH_SUCCESS:
return normalizeTimeline(state, action.timeline, Immutable.fromJS(action.statuses));
case TIMELINE_UPDATE:
return updateTimeline(state, action.timeline, Immutable.fromJS(action.status));
Expand Down

0 comments on commit 6d89edc

Please sign in to comment.