Browse Source

Add own composed status to home without waiting for websocket event

This makes the UI appear less laggy. After all, the status *is* created
right there and then, it's the distribution to home timelines that can take
a while
master
Eugen Rochko 7 years ago
parent
commit
aff22bfdb5
2 changed files with 13 additions and 3 deletions
  1. +9
    -3
      app/assets/javascripts/components/actions/compose.jsx
  2. +4
    -0
      app/assets/javascripts/components/reducers/timelines.jsx

+ 9
- 3
app/assets/javascripts/components/actions/compose.jsx View File

@ -1,5 +1,7 @@
import api from '../api'
import { updateTimeline } from './timelines';
export const COMPOSE_CHANGE = 'COMPOSE_CHANGE';
export const COMPOSE_SUBMIT_REQUEST = 'COMPOSE_SUBMIT_REQUEST';
export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS';
@ -66,9 +68,13 @@ export function submitComposeRequest() {
};
export function submitComposeSuccess(status) {
return {
type: COMPOSE_SUBMIT_SUCCESS,
status: status
return (dispatch, getState) => {
dispatch({
type: COMPOSE_SUBMIT_SUCCESS,
status: status
});
dispatch(updateTimeline('home', status));
};
};

+ 4
- 0
app/assets/javascripts/components/reducers/timelines.jsx View File

@ -95,6 +95,10 @@ const updateTimeline = (state, timeline, status, references) => {
state = normalizeStatus(state, status);
state = state.update(timeline, list => {
if (list.includes(status.get('id'))) {
return list;
}
const reblogOfId = status.getIn(['reblog', 'id'], null);
if (reblogOfId !== null) {

Loading…
Cancel
Save