Remove files from UI immediately (don't wait for daemon to confirm)
This commit is contained in:
parent
769ee12020
commit
cddc1ecd22
3 changed files with 24 additions and 9 deletions
|
@ -17,6 +17,7 @@ let FileTile = React.createClass({
|
||||||
local: React.PropTypes.bool,
|
local: React.PropTypes.bool,
|
||||||
cost: React.PropTypes.number,
|
cost: React.PropTypes.number,
|
||||||
costIncludesData: React.PropTypes.bool,
|
costIncludesData: React.PropTypes.bool,
|
||||||
|
hideOnRemove: React.PropTypes.bool,
|
||||||
},
|
},
|
||||||
updateFileInfo: function(progress=null) {
|
updateFileInfo: function(progress=null) {
|
||||||
const updateFileInfoCallback = ((fileInfo) => {
|
const updateFileInfoCallback = ((fileInfo) => {
|
||||||
|
@ -73,6 +74,7 @@ let FileTile = React.createClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
downloading: false,
|
downloading: false,
|
||||||
|
removeConfirmed: false,
|
||||||
isHovered: false,
|
isHovered: false,
|
||||||
cost: null,
|
cost: null,
|
||||||
costIncludesData: null,
|
costIncludesData: null,
|
||||||
|
@ -84,6 +86,7 @@ let FileTile = React.createClass({
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
compact: false,
|
compact: false,
|
||||||
|
hideOnRemove: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleMouseOver: function() {
|
handleMouseOver: function() {
|
||||||
|
@ -96,6 +99,11 @@ let FileTile = React.createClass({
|
||||||
isHovered: false,
|
isHovered: false,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
handleRemoveConfirmed: function() {
|
||||||
|
this.setState({
|
||||||
|
removeConfirmed: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
this.updateFileInfo();
|
this.updateFileInfo();
|
||||||
|
|
||||||
|
@ -120,8 +128,9 @@ let FileTile = React.createClass({
|
||||||
this._isMounted = false;
|
this._isMounted = false;
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
if (this.state.isMine === null || this.state.local === null) {
|
// Can't render until we know whether we own the file and if we have a local copy
|
||||||
// Can't render until we know whether we own the file and if we have a local copy
|
if (this.state.isMine === null || this.state.local === null ||
|
||||||
|
(this.props.hideOnRemove && this.state.removeConfirmed)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +172,8 @@ let FileTile = React.createClass({
|
||||||
<div>
|
<div>
|
||||||
{this.props.metadata.content_type.startsWith('video/') ? <WatchLink streamName={this.props.name} button="primary" /> : null}
|
{this.props.metadata.content_type.startsWith('video/') ? <WatchLink streamName={this.props.name} button="primary" /> : null}
|
||||||
{!this.props.isMine
|
{!this.props.isMine
|
||||||
? <DownloadLink streamName={this.props.name} metadata={this.props.metadata} button="text" {... downloadLinkExtraProps}/>
|
? <DownloadLink streamName={this.props.name} metadata={this.props.metadata} button="text"
|
||||||
|
onRemoveConfirmed={this.handleRemoveConfirmed} {... downloadLinkExtraProps}/>
|
||||||
: null}
|
: null}
|
||||||
</div>
|
</div>
|
||||||
<p className="file-tile__description">
|
<p className="file-tile__description">
|
||||||
|
|
|
@ -167,6 +167,7 @@ export let DownloadLink = React.createClass({
|
||||||
path: React.PropTypes.string,
|
path: React.PropTypes.string,
|
||||||
hidden: React.PropTypes.bool,
|
hidden: React.PropTypes.bool,
|
||||||
deleteChecked: React.PropTypes.bool,
|
deleteChecked: React.PropTypes.bool,
|
||||||
|
onRemoveConfirmed: React.PropTypes.func,
|
||||||
},
|
},
|
||||||
tryDownload: function() {
|
tryDownload: function() {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -217,13 +218,18 @@ export let DownloadLink = React.createClass({
|
||||||
},
|
},
|
||||||
handleRemoveConfirmed: function() {
|
handleRemoveConfirmed: function() {
|
||||||
lbry.deleteFile(this.props.sdHash || this.props.streamName, this.state.deleteChecked);
|
lbry.deleteFile(this.props.sdHash || this.props.streamName, this.state.deleteChecked);
|
||||||
|
if (this.props.onRemoveConfirmed) {
|
||||||
|
this.props.onRemoveConfirmed();
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
modal: null,
|
modal: null,
|
||||||
|
attemptingRemove: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
state: 'not-started',
|
state: 'not-started',
|
||||||
|
hideOnDelete: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
@ -233,6 +239,7 @@ export let DownloadLink = React.createClass({
|
||||||
menuOpen: false,
|
menuOpen: false,
|
||||||
deleteChecked: false,
|
deleteChecked: false,
|
||||||
attemptingDownload: false,
|
attemptingDownload: false,
|
||||||
|
attemptingRemove: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeModal: function() {
|
closeModal: function() {
|
||||||
|
@ -256,7 +263,9 @@ export let DownloadLink = React.createClass({
|
||||||
];
|
];
|
||||||
|
|
||||||
let linkBlock;
|
let linkBlock;
|
||||||
if (this.state.attemptingDownload) {
|
if (this.state.attemptingRemove || this.props.state == 'not-started') {
|
||||||
|
linkBlock = <Link button="text" label="Download" icon="icon-download" onClick={this.handleClick} />;
|
||||||
|
} else if (this.state.attemptingDownload) {
|
||||||
linkBlock = <Link button="text" className="button-download button-download--bg"
|
linkBlock = <Link button="text" className="button-download button-download--bg"
|
||||||
label="Connecting..." icon="icon-download" />
|
label="Connecting..." icon="icon-download" />
|
||||||
} else if (this.props.state == 'downloading') {
|
} else if (this.props.state == 'downloading') {
|
||||||
|
@ -273,10 +282,6 @@ export let DownloadLink = React.createClass({
|
||||||
</DropDown>
|
</DropDown>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else if (this.props.state == 'not-started') {
|
|
||||||
linkBlock = (
|
|
||||||
<Link button="text" label="Download" icon="icon-download" onClick={this.handleClick} />
|
|
||||||
);
|
|
||||||
} else if (this.props.state == 'done') {
|
} else if (this.props.state == 'done') {
|
||||||
linkBlock = (
|
linkBlock = (
|
||||||
<DropDown button="alt" label="Open" onClick={this.handleClick} onCaretClick={this.openMenu}>
|
<DropDown button="alt" label="Open" onClick={this.handleClick} onCaretClick={this.openMenu}>
|
||||||
|
|
|
@ -178,7 +178,7 @@ var MyFilesPage = React.createClass({
|
||||||
|
|
||||||
seenUris[lbry_uri] = true;
|
seenUris[lbry_uri] = true;
|
||||||
|
|
||||||
content.push(<FileTile name={lbry_uri} sdHash={sd_hash} isMine={this.props.show == 'published'} local={true}
|
content.push(<FileTile name={lbry_uri} sdHash={sd_hash} isMine={this.props.show == 'published'} local={true} hideOnRemove={true}
|
||||||
metadata={metadata} completed={completed} stopped={stopped} pending={pending} path={download_path}
|
metadata={metadata} completed={completed} stopped={stopped} pending={pending} path={download_path}
|
||||||
{... this.state.filesAvailable !== null ? {available: this.state.filesAvailable[sd_hash]} : {}} />);
|
{... this.state.filesAvailable !== null ? {available: this.state.filesAvailable[sd_hash]} : {}} />);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue