diff options
Diffstat (limited to 'app/assets/javascripts')
3 files changed, 60 insertions, 17 deletions
diff --git a/app/assets/javascripts/components/actions/timelines.jsx b/app/assets/javascripts/components/actions/timelines.jsx index 4d4122ec7..383b727e9 100644 --- a/app/assets/javascripts/components/actions/timelines.jsx +++ b/app/assets/javascripts/components/actions/timelines.jsx @@ -1,6 +1,12 @@ -export const TIMELINE_SET = 'TIMELINE_SET'; -export const TIMELINE_UPDATE = 'TIMELINE_UPDATE'; -export const TIMELINE_DELETE = 'TIMELINE_DELETE'; +import api from '../api' + +export const TIMELINE_SET = 'TIMELINE_SET'; +export const TIMELINE_UPDATE = 'TIMELINE_UPDATE'; +export const TIMELINE_DELETE = 'TIMELINE_DELETE'; + +export const TIMELINE_REFRESH_REQUEST = 'TIMELINE_REFRESH_REQUEST'; +export const TIMELINE_REFRESH_SUCCESS = 'TIMELINE_REFRESH_SUCCESS'; +export const TIMELINE_REFRESH_FAIL = 'TIMELINE_REFRESH_FAIL'; export function setTimeline(timeline, statuses) { return { @@ -24,3 +30,36 @@ export function deleteFromTimelines(id) { id: id }; } + +export function refreshTimelineRequest(timeline) { + return { + type: TIMELINE_REFRESH_REQUEST, + timeline: timeline + }; +} + +export function refreshTimeline(timeline) { + return function (dispatch, getState) { + dispatch(refreshTimelineRequest(timeline)); + + api(getState).get(`/api/statuses/${timeline}`).then(function (response) { + dispatch(refreshTimelineSuccess(timeline, response.data)); + }).catch(function (error) { + dispatch(refreshTimelineFail(timeline, error)); + }); + }; +} + +export function refreshTimelineSuccess(timeline, statuses) { + return function (dispatch) { + dispatch(setTimeline(timeline, statuses)); + }; +} + +export function refreshTimelineFail(timeline, error) { + return { + type: TIMELINE_REFRESH_FAIL, + timeline: timeline, + error: error + }; +} diff --git a/app/assets/javascripts/components/components/avatar.jsx b/app/assets/javascripts/components/components/avatar.jsx index 6177683ba..267d02bcd 100644 --- a/app/assets/javascripts/components/components/avatar.jsx +++ b/app/assets/javascripts/components/components/avatar.jsx @@ -11,7 +11,7 @@ const Avatar = React.createClass({ render () { return ( - <div style={{ width: `${this.props.size}px`, height: `${this.props.size}px` }}> + <div style={{ width: `${this.props.size}px`, height: `${this.props.size}px`, borderRadius: '4px', overflow: 'hidden' }} className='transparent-background'> <img src={this.props.src} width={this.props.size} height={this.props.size} alt='' style={{ display: 'block', borderRadius: '4px' }} /> </div> ); diff --git a/app/assets/javascripts/components/containers/root.jsx b/app/assets/javascripts/components/containers/root.jsx index eb031bdd4..e2baefa24 100644 --- a/app/assets/javascripts/components/containers/root.jsx +++ b/app/assets/javascripts/components/containers/root.jsx @@ -1,12 +1,12 @@ -import { Provider } from 'react-redux'; -import configureStore from '../store/configureStore'; -import Frontend from '../components/frontend'; -import { setTimeline, updateTimeline, deleteFromTimelines } from '../actions/timelines'; -import { setAccessToken } from '../actions/meta'; -import PureRenderMixin from 'react-addons-pure-render-mixin'; -import { Router, Route, createMemoryHistory } from 'react-router'; -import AccountRoute from '../routes/account_route'; -import StatusRoute from '../routes/status_route'; +import { Provider } from 'react-redux'; +import configureStore from '../store/configureStore'; +import Frontend from '../components/frontend'; +import { setTimeline, updateTimeline, deleteFromTimelines, refreshTimeline } from '../actions/timelines'; +import { setAccessToken } from '../actions/meta'; +import PureRenderMixin from 'react-addons-pure-render-mixin'; +import { Router, Route, createMemoryHistory } from 'react-router'; +import AccountRoute from '../routes/account_route'; +import StatusRoute from '../routes/status_route'; const store = configureStore(); const history = createMemoryHistory(); @@ -36,10 +36,14 @@ const Root = React.createClass({ disconnected: function() {}, received: function(data) { - if (data.type === 'update') { - return store.dispatch(updateTimeline(data.timeline, JSON.parse(data.message))); - } else if (data.type === 'delete') { - return store.dispatch(deleteFromTimelines(data.id)); + switch(data.type) { + case 'update': + return store.dispatch(updateTimeline(data.timeline, JSON.parse(data.message))); + case 'delete': + return store.dispatch(deleteFromTimelines(data.id)); + case 'merge': + case 'unmerge': + return store.dispatch(refreshTimeline('home')); } } }); |