]> cat aescling's git repositories - mastodon.git/commitdiff
Fix WebUI crash when a toot with a playing video gets deleted
authorClaire <claire.github-309c@sitedethib.com>
Thu, 10 Jun 2021 14:08:31 +0000 (16:08 +0200)
committerClaire <claire.github-309c@sitedethib.com>
Thu, 24 Jun 2021 13:19:12 +0000 (15:19 +0200)
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
app/javascript/flavours/glitch/actions/picture_in_picture.js

index 4085cb59e0097f326624ad8d7214e3f70205d3d7..33d8d57d475d05823eeda97bbff3cb4939f39803 100644 (file)
@@ -22,13 +22,20 @@ export const PICTURE_IN_PICTURE_REMOVE = 'PICTURE_IN_PICTURE_REMOVE';
  * @param {MediaProps} props
  * @return {object}
  */
-export const deployPictureInPicture = (statusId, accountId, playerType, props) => ({
-  type: PICTURE_IN_PICTURE_DEPLOY,
-  statusId,
-  accountId,
-  playerType,
-  props,
-});
+export const deployPictureInPicture = (statusId, accountId, playerType, props) => {
+  return (dispatch, getState) => {
+    // Do not open a player for a toot that does not exist
+    if (getState().hasIn(['statuses', statusId])) {
+      dispatch({
+        type: PICTURE_IN_PICTURE_DEPLOY,
+        statusId,
+        accountId,
+        playerType,
+        props,
+      });
+    }
+  };
+};
 
 /*
  * @return {object}