diff --git a/app/src/page/file/index.js b/app/src/page/file/index.js index b6207039..8a82abed 100644 --- a/app/src/page/file/index.js +++ b/app/src/page/file/index.js @@ -9,7 +9,7 @@ import { selectRewardContentClaimIds, makeSelectCostInfoForUri } from 'lbry-redux'; -//import { selectShowNsfw } from 'redux/selectors/settings'; +import { doDeleteFile } from '../../redux/actions/file'; import FilePage from './view'; const select = (state, props) => { @@ -29,6 +29,9 @@ const select = (state, props) => { const perform = dispatch => ({ fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)), fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)), + deleteFile: (fileInfo, deleteFromDevice, abandonClaim) => { + dispatch(doDeleteFile(fileInfo, deleteFromDevice, abandonClaim)); + }, }); export default connect(select, perform)(FilePage); diff --git a/app/src/page/file/view.js b/app/src/page/file/view.js index d251f09e..8327b513 100644 --- a/app/src/page/file/view.js +++ b/app/src/page/file/view.js @@ -1,6 +1,16 @@ import React from 'react'; import { Lbry } from 'lbry-redux'; -import { Text, View, ScrollView, StatusBar, TouchableOpacity, NativeModules } from 'react-native'; +import { + ActivityIndicator, + Alert, + Button, + Text, + View, + ScrollView, + StatusBar, + TouchableOpacity, + NativeModules +} from 'react-native'; import FileItemMedia from '../../component/fileItemMedia'; import FileDownloadButton from '../../component/fileDownloadButton'; import MediaPlayer from '../../component/mediaPlayer'; @@ -52,6 +62,20 @@ class FilePage extends React.PureComponent { } } + onDeletePressed = () => { + const { deleteFile, fileInfo } = this.props; + + Alert.alert( + 'Delete file', + 'Are you sure you want to remove this file from your device?', + [ + { text: 'No' }, + { text: 'Yes', onPress: () => { deleteFile(fileInfo.outpoint, true); } } + ], + { cancelable: true } + ); + } + componentWillUnmount() { StatusBar.setHidden(false); if (NativeModules.ScreenOrientation) { @@ -85,21 +109,30 @@ class FilePage extends React.PureComponent { const mediaType = Lbry.getMediaType(contentType); const isPlayable = mediaType === 'video' || mediaType === 'audio'; const { height, channel_name: channelName, value } = claim; + const showActions = (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes)); const channelClaimId = value && value.publisherSignature && value.publisherSignature.certificateId; return ( - + {(!fileInfo || (isPlayable && !this.state.mediaLoaded)) && } + {isPlayable && !this.state.mediaLoaded && } {!completed && } {fileInfo && isPlayable && { this.setState({ mediaLoaded: true }); }}/>} - + { showActions && + + {completed &&