about summary refs log tree commit diff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-03 11:06:55 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-03 11:06:55 +0100
commitaff22bfdb554207ae73b8946310f7328f645be70 (patch)
tree3a38c650411f0cae712efd71ac2eb12895c290fa /app/assets/javascripts
parent4b357ecf98f373f5ed31c71ecc1a79d23572cd00 (diff)
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
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/components/actions/compose.jsx12
-rw-r--r--app/assets/javascripts/components/reducers/timelines.jsx4
2 files changed, 13 insertions, 3 deletions
diff --git a/app/assets/javascripts/components/actions/compose.jsx b/app/assets/javascripts/components/actions/compose.jsx
index b576c7444..228469df1 100644
--- a/app/assets/javascripts/components/actions/compose.jsx
+++ b/app/assets/javascripts/components/actions/compose.jsx
@@ -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));
   };
 };
 
diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx
index db13cad31..c12d1b70d 100644
--- a/app/assets/javascripts/components/reducers/timelines.jsx
+++ b/app/assets/javascripts/components/reducers/timelines.jsx
@@ -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) {