remove legacy method usage from file page

This commit is contained in:
btzr-io 2019-05-29 13:35:46 -06:00
parent 934f3b271a
commit 731d84f4be
2 changed files with 14 additions and 26 deletions

View file

@ -19,11 +19,11 @@ type Props = {
};
class FileActions extends React.PureComponent<Props> {
MaximizeViewer() {
maximizeViewer = () => {
// Get viewer container
const viewer = document.getElementsByClassName('content__embedded')[0];
viewer.webkitRequestFullscreen();
}
};
render() {
const { fileInfo, uri, openModal, claimIsMine, claimId, showFullscreen } = this.props;
@ -33,14 +33,7 @@ class FileActions extends React.PureComponent<Props> {
<React.Fragment>
{showFullscreen && (
<Tooltip onComponent body={__('Full screen (f)')}>
<Button
button="alt"
description={__('Fullscreen')}
icon={ICONS.FULLSCREEN}
onClick={() => {
this.MaximizeViewer();
}}
/>
<Button button="alt" description={__('Fullscreen')} icon={ICONS.FULLSCREEN} onClick={this.maximizeViewer} />
</Tooltip>
)}
{showDelete && (

View file

@ -92,23 +92,8 @@ class FilePage extends React.Component<Props> {
setViewed(uri);
}
// This is now marked as a react lecacy method:
// https://reactjs.org/docs/react-component.html#unsafe_componentwillmount
UNSAFE_componentWillReceiveProps(nextProps: Props) {
const { fetchFileInfo, uri, setViewed } = this.props;
// @if TARGET='app'
if (nextProps.fileInfo === undefined) {
fetchFileInfo(uri);
}
// @endif
if (uri !== nextProps.uri) {
setViewed(nextProps.uri);
}
}
componentDidUpdate(prevProps: Props) {
const { isSubscribed, claim, uri, fetchViewCount, claimIsMine } = this.props;
const { isSubscribed, claim, uri, fileInfo, setViewed, fetchViewCount, claimIsMine, fetchFileInfo } = this.props;
if (!prevProps.isSubscribed && isSubscribed) {
this.removeFromSubscriptionNotifications();
@ -117,6 +102,16 @@ class FilePage extends React.Component<Props> {
if (prevProps.uri !== uri && claimIsMine) {
fetchViewCount(claim.claim_id);
}
// @if TARGET='app'
if (fileInfo === undefined) {
fetchFileInfo(uri);
}
// @endif
if (prevProps.uri !== uri) {
setViewed(uri);
}
}
removeFromSubscriptionNotifications() {