]> cat aescling's git repositories - mastodon.git/commitdiff
Immediately go back in browser history upon successfully sending toot (#9663)
authorThibG <thib@sitedethib.com>
Sun, 30 Dec 2018 17:58:25 +0000 (18:58 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 30 Dec 2018 17:58:25 +0000 (18:58 +0100)
Avoids possible misleading delay before redirection during which the
composer would be cleared and redrawn.

app/javascript/mastodon/actions/compose.js

index 1c7f14b5ef7f3656666411d3cd1b27fd4e85e20d..a4352faaba63746cd28cf22faab7c1c6799cb5ed 100644 (file)
@@ -130,6 +130,12 @@ export function submitCompose(routerHistory) {
         'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']),
       },
     }).then(function (response) {
+      if (response.data.visibility === 'direct' && getState().getIn(['conversations', 'mounted']) <= 0 && routerHistory) {
+        routerHistory.push('/timelines/direct');
+      } else if (routerHistory && routerHistory.location.pathname === '/statuses/new' && window.history.state) {
+        routerHistory.goBack();
+      }
+
       dispatch(insertIntoTagHistory(response.data.tags, status));
       dispatch(submitComposeSuccess({ ...response.data }));
 
@@ -142,12 +148,6 @@ export function submitCompose(routerHistory) {
         }
       };
 
-      if (response.data.visibility === 'direct' && getState().getIn(['conversations', 'mounted']) <= 0 && routerHistory) {
-        routerHistory.push('/timelines/direct');
-      } else if (routerHistory && routerHistory.location.pathname === '/statuses/new' && window.history.state) {
-        routerHistory.goBack();
-      }
-
       if (response.data.visibility !== 'direct') {
         insertIfOnline('home');
       }