remove legacy method usage from file page
This commit is contained in:
parent
934f3b271a
commit
731d84f4be
2 changed files with 14 additions and 26 deletions
|
@ -19,11 +19,11 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileActions extends React.PureComponent<Props> {
|
class FileActions extends React.PureComponent<Props> {
|
||||||
MaximizeViewer() {
|
maximizeViewer = () => {
|
||||||
// Get viewer container
|
// Get viewer container
|
||||||
const viewer = document.getElementsByClassName('content__embedded')[0];
|
const viewer = document.getElementsByClassName('content__embedded')[0];
|
||||||
viewer.webkitRequestFullscreen();
|
viewer.webkitRequestFullscreen();
|
||||||
}
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { fileInfo, uri, openModal, claimIsMine, claimId, showFullscreen } = this.props;
|
const { fileInfo, uri, openModal, claimIsMine, claimId, showFullscreen } = this.props;
|
||||||
|
@ -33,14 +33,7 @@ class FileActions extends React.PureComponent<Props> {
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{showFullscreen && (
|
{showFullscreen && (
|
||||||
<Tooltip onComponent body={__('Full screen (f)')}>
|
<Tooltip onComponent body={__('Full screen (f)')}>
|
||||||
<Button
|
<Button button="alt" description={__('Fullscreen')} icon={ICONS.FULLSCREEN} onClick={this.maximizeViewer} />
|
||||||
button="alt"
|
|
||||||
description={__('Fullscreen')}
|
|
||||||
icon={ICONS.FULLSCREEN}
|
|
||||||
onClick={() => {
|
|
||||||
this.MaximizeViewer();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
{showDelete && (
|
{showDelete && (
|
||||||
|
|
|
@ -92,23 +92,8 @@ class FilePage extends React.Component<Props> {
|
||||||
setViewed(uri);
|
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) {
|
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) {
|
if (!prevProps.isSubscribed && isSubscribed) {
|
||||||
this.removeFromSubscriptionNotifications();
|
this.removeFromSubscriptionNotifications();
|
||||||
|
@ -117,6 +102,16 @@ class FilePage extends React.Component<Props> {
|
||||||
if (prevProps.uri !== uri && claimIsMine) {
|
if (prevProps.uri !== uri && claimIsMine) {
|
||||||
fetchViewCount(claim.claim_id);
|
fetchViewCount(claim.claim_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @if TARGET='app'
|
||||||
|
if (fileInfo === undefined) {
|
||||||
|
fetchFileInfo(uri);
|
||||||
|
}
|
||||||
|
// @endif
|
||||||
|
|
||||||
|
if (prevProps.uri !== uri) {
|
||||||
|
setViewed(uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeFromSubscriptionNotifications() {
|
removeFromSubscriptionNotifications() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue