[Glitch] Fix unnecessary re-rendering of various components when typing in web UI (#2063)

Port 9620ee90be to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
This commit is contained in:
Claire
2023-01-05 13:32:29 +01:00
committed by GitHub
parent 3a94668d87
commit 7e9d5bdbb9
5 changed files with 36 additions and 21 deletions

View File

@ -1,6 +1,6 @@
import escapeTextContentForBrowser from 'escape-html';
import { createSelector } from 'reselect';
import { List as ImmutableList } from 'immutable';
import { List as ImmutableList, Map as ImmutableMap, is } from 'immutable';
import { toServerSideType } from 'flavours/glitch/utils/filters';
import { me } from 'flavours/glitch/initial_state';
@ -74,6 +74,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) => {