cachedMediaWidth: PropTypes.number,
scrollKey: PropTypes.string,
deployPictureInPicture: PropTypes.func,
- pictureInPicture: PropTypes.shape({
+ pictureInPicture: ImmutablePropTypes.contains({
inUse: PropTypes.bool,
available: PropTypes.bool,
}),
status = status.get('reblog');
}
- if (pictureInPicture.inUse) {
+ if (pictureInPicture.get('inUse')) {
media = <PictureInPicturePlaceholder width={this.props.cachedMediaWidth} />;
} else if (status.get('media_attachments').size > 0) {
if (this.props.muted) {
width={this.props.cachedMediaWidth}
height={110}
cacheWidth={this.props.cacheMediaWidth}
- deployPictureInPicture={pictureInPicture.available ? this.handleDeployPictureInPicture : undefined}
+ deployPictureInPicture={pictureInPicture.get('available') ? this.handleDeployPictureInPicture : undefined}
/>
)}
</Bundle>
sensitive={status.get('sensitive')}
onOpenVideo={this.handleOpenVideo}
cacheWidth={this.props.cacheMediaWidth}
- deployPictureInPicture={pictureInPicture.available ? this.handleDeployPictureInPicture : undefined}
+ deployPictureInPicture={pictureInPicture.get('available') ? this.handleDeployPictureInPicture : undefined}
visible={this.state.showMedia}
onToggleVisibility={this.handleToggleMediaVisibility}
/>
import React from 'react';
import { connect } from 'react-redux';
import Status from '../components/status';
-import { makeGetStatus } from '../selectors';
+import { makeGetStatus, makeGetPictureInPicture } from '../selectors';
import {
replyCompose,
mentionCompose,
const makeMapStateToProps = () => {
const getStatus = makeGetStatus();
+ const getPictureInPicture = makeGetPictureInPicture();
const mapStateToProps = (state, props) => ({
status: getStatus(state, props),
-
- pictureInPicture: {
- inUse: state.getIn(['meta', 'layout']) !== 'mobile' && state.get('picture_in_picture').statusId === props.id,
- available: state.getIn(['meta', 'layout']) !== 'mobile',
- },
+ pictureInPicture: getPictureInPicture(state, props),
});
return mapStateToProps;
domain: PropTypes.string.isRequired,
compact: PropTypes.bool,
showMedia: PropTypes.bool,
- usingPiP: PropTypes.bool,
+ pictureInPicture: ImmutablePropTypes.contains({
+ inUse: PropTypes.bool,
+ available: PropTypes.bool,
+ }),
onToggleMediaVisibility: PropTypes.func,
};
render () {
const status = (this.props.status && this.props.status.get('reblog')) ? this.props.status.get('reblog') : this.props.status;
const outerStyle = { boxSizing: 'border-box' };
- const { intl, compact, usingPiP } = this.props;
+ const { intl, compact, pictureInPicture } = this.props;
if (!status) {
return null;
outerStyle.height = `${this.state.height}px`;
}
- if (usingPiP) {
+ if (pictureInPicture.get('inUse')) {
media = <PictureInPicturePlaceholder />;
} else if (status.get('media_attachments').size > 0) {
if (status.getIn(['media_attachments', 0, 'type']) === 'audio') {
import { initMuteModal } from '../../actions/mutes';
import { initBlockModal } from '../../actions/blocks';
import { initReport } from '../../actions/reports';
-import { makeGetStatus } from '../../selectors';
+import { makeGetStatus, makeGetPictureInPicture } from '../../selectors';
import { ScrollContainer } from 'react-router-scroll-4';
import ColumnBackButton from '../../components/column_back_button';
import ColumnHeader from '../../components/column_header';
const makeMapStateToProps = () => {
const getStatus = makeGetStatus();
+ const getPictureInPicture = makeGetPictureInPicture();
const getAncestorsIds = createSelector([
(_, { id }) => id,
const mapStateToProps = (state, props) => {
const status = getStatus(state, { id: props.params.statusId });
- let ancestorsIds = Immutable.List();
+
+ let ancestorsIds = Immutable.List();
let descendantsIds = Immutable.List();
if (status) {
- ancestorsIds = getAncestorsIds(state, { id: status.get('in_reply_to_id') });
+ ancestorsIds = getAncestorsIds(state, { id: status.get('in_reply_to_id') });
descendantsIds = getDescendantsIds(state, { id: status.get('id') });
}
descendantsIds,
askReplyConfirmation: state.getIn(['compose', 'text']).trim().length !== 0,
domain: state.getIn(['meta', 'domain']),
- usingPiP: state.get('picture_in_picture').statusId === props.params.statusId,
+ pictureInPicture: getPictureInPicture(state, { id: props.params.statusId }),
};
};
askReplyConfirmation: PropTypes.bool,
multiColumn: PropTypes.bool,
domain: PropTypes.string.isRequired,
- usingPiP: PropTypes.bool,
+ pictureInPicture: ImmutablePropTypes.contains({
+ inUse: PropTypes.bool,
+ available: PropTypes.bool,
+ }),
};
state = {
render () {
let ancestors, descendants;
- const { shouldUpdateScroll, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, usingPiP } = this.props;
+ const { shouldUpdateScroll, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
const { fullscreen } = this.state;
if (status === null) {
domain={domain}
showMedia={this.state.showMedia}
onToggleMediaVisibility={this.handleToggleMediaVisibility}
- usingPiP={usingPiP}
+ pictureInPicture={pictureInPicture}
/>
<ActionBar
if (this.props.singleColumn !== prevProps.singleColumn && !this.props.singleColumn) {
this.node.addEventListener('wheel', this.handleWheel, supportsPassiveEvents ? { passive: true } : false);
}
- this.lastIndex = getIndex(this.context.router.history.location.pathname);
- this.setState({ shouldAnimate: true });
+
+ const newIndex = getIndex(this.context.router.history.location.pathname);
+
+ if (this.lastIndex !== newIndex) {
+ this.lastIndex = newIndex;
+ this.setState({ shouldAnimate: true });
+ }
}
componentWillUnmount () {
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);
);
};
+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) => {