From e5b4aaf175c5bb0b239e6dbcadb5215ca840cca6 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sat, 21 Jan 2017 01:52:32 -0500 Subject: [PATCH] Revamp "file not available" message - Don't fade out tile - Display message in place of buttons with an option to bypass the message - Factor out message into its own FileUnavailableMessage component --- js/component/file-actions.js | 27 +++++++++++++++++++++++++-- js/component/file-tile.js | 23 +++-------------------- scss/all.scss | 1 + 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/js/component/file-actions.js b/js/component/file-actions.js index ec4a14e06..c670964ce 100644 --- a/js/component/file-actions.js +++ b/js/component/file-actions.js @@ -2,6 +2,7 @@ import React from 'react'; import lbry from '../lbry.js'; import {Link} from '../component/link.js'; import {Icon} from '../component/common.js'; +import FileUnavailableMessage from '../component/file-unavailable-message.js'; import Modal from './modal.js'; import FormField from './form.js'; import {DropDownMenu, DropDownMenuItem} from './menu.js'; @@ -71,6 +72,8 @@ export let FileActions = React.createClass({ deleteChecked: false, attemptingDownload: false, attemptingRemove: false, + available: null, + forceShowActions: false, } }, onFileInfoUpdate: function(fileInfo) { @@ -136,6 +139,11 @@ export let FileActions = React.createClass({ modal: 'confirmRemove', }); }, + showActions: function() { + this.setState({ + forceShowActions: true, + }); + }, handleRemoveConfirmed: function() { if (this.props.streamName) { lbry.removeFile(this.props.sdHash, this.props.streamName, this.state.deleteChecked); @@ -156,6 +164,15 @@ export let FileActions = React.createClass({ componentDidMount: function() { this._isMounted = true; this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate); + lbry.getPeersForBlobHash(this.props.sdHash, (peers) => { + if (!this._isMounted) { + return; + } + + this.setState({ + available: peers.length > 0, + }); + }); }, componentWillUnmount: function() { this._isMounted = false; @@ -168,6 +185,11 @@ export let FileActions = React.createClass({ { return
; } + + if (this.state.available === false && !this.state.forceShowActions) { + return ; + } + const openInFolderMessage = window.navigator.platform.startsWith('Mac') ? 'Open in Finder' : 'Open in Folder', showMenu = !!this.state.fileInfo; @@ -180,11 +202,12 @@ export let FileActions = React.createClass({ label = this.state.fileInfo ? progress.toFixed(0) + '% complete' : 'Connecting...', labelWithIcon = {label}; - linkBlock = + linkBlock = (
{labelWithIcon}
{labelWithIcon} -
; + + ); } else { linkBlock = ; } diff --git a/js/component/file-tile.js b/js/component/file-tile.js index 4ac887d2a..f4e3c747b 100644 --- a/js/component/file-tile.js +++ b/js/component/file-tile.js @@ -74,13 +74,6 @@ export let FileTileStream = React.createClass({ hidePrice: false } }, - componentWillMount: function() { - lbry.getPeersForBlobHash(this.props.sdHash, (peers) => { - this.setState({ - available: peers.length > 0, - }); - }); - }, componentDidMount: function() { this._isMounted = true; if (this.props.hideOnRemove) { @@ -114,26 +107,16 @@ export let FileTileStream = React.createClass({ } }, render: function() { - const isUnavailable = this.state.available === false; - - if (this.state.isHidden || (!lbry.getClientSetting('showUnavailable') && isUnavailable)) { + if (this.state.isHidden) { return null; } const metadata = this.props.metadata || {}, obscureNsfw = this.props.obscureNsfw && metadata.nsfw, - title = metadata.title ? metadata.title : ('lbry://' + this.props.name), - showAsAvailable = this.state.available !== false, - unavailableMessage = ("The content on LBRY is hosted by its users. It appears there are no " + - "users connected that have this file at the moment."); + title = metadata.title ? metadata.title : ('lbry://' + this.props.name); return (
- {isUnavailable - ?
- This file is not currently available. -
- : null} -
+
diff --git a/scss/all.scss b/scss/all.scss index 59b8867d1..1621fc47f 100644 --- a/scss/all.scss +++ b/scss/all.scss @@ -7,6 +7,7 @@ @import "component/_table"; @import "component/_file-actions.scss"; @import "component/_file-tile.scss"; +@import "component/_file-unavailable-message.scss"; @import "component/_menu.scss"; @import "component/_tooltiplink.scss"; @import "component/_tooltip.scss";