about summary refs log tree commit diff
path: root/app/javascript/mastodon/selectors
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2020-12-07 19:36:36 +0100
committerGitHub <noreply@github.com>2020-12-07 19:36:36 +0100
commit9620ee90be7e04b3616ce4b851abb63dbba7af7f (patch)
treef3880b9c8eda7dcc570553eec855080fd122e730 /app/javascript/mastodon/selectors
parent48bef17cc990afda95c4de657f7643c321e62650 (diff)
Fix unnecessary re-rendering of various components when typing in web UI (#15286)
Diffstat (limited to 'app/javascript/mastodon/selectors')
-rw-r--r--app/javascript/mastodon/selectors/index.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/javascript/mastodon/selectors/index.js b/app/javascript/mastodon/selectors/index.js
index fd3b72f96..1e19db65d 100644
--- a/app/javascript/mastodon/selectors/index.js
+++ b/app/javascript/mastodon/selectors/index.js
@@ -1,5 +1,5 @@
 import { createSelector } from 'reselect';
-import { List as ImmutableList, is } from 'immutable';
+import { List as ImmutableList, Map as ImmutableMap, is } from 'immutable';
 import { me } from '../initial_state';
 
 const getAccountBase         = (state, id) => state.getIn(['accounts', id], null);
@@ -121,6 +121,16 @@ export const makeGetStatus = () => {
   );
 };
 
+export const makeGetPictureInPicture = () => {
+  return createSelector([
+    (state, { id }) => state.get('picture_in_picture').statusId === id,
+    (state) => state.getIn(['meta', 'layout']) !== 'mobile',
+  ], (inUse, available) => ImmutableMap({
+    inUse: inUse && available,
+    available,
+  }));
+};
+
 const getAlertsBase = state => state.get('alerts');
 
 export const getAlerts = createSelector([getAlertsBase], (base) => {