mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-02 18:25:12 +00:00
Web: Fix 'Download' not triggering until second attempt
## Issue 4669: `Download doesn't trigger on web until 2nd attempt` The issue only happens when _Autoplay_ is disabled in the User Settings and the video hasn't been loaded when _Download_ is clicked. The following code: `if (didClickDownloadButton && streamingUrl)` didn't triggered because: 1. `streamingUrl` has not resolved yet when the Effect ran. 2. When it did resolve, the parent component was also notified and unmounted things, causing `didClickDownloadButton` to reset. ## Approach Avoid the unnecessary unmounting by not using a conditional section wrapper within a return statement. React probably couldn't do the diffs when the conditional is at a section level.
This commit is contained in:
parent
d1db6fb3b3
commit
202269ebeb
2 changed files with 78 additions and 69 deletions
|
@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Fix related + search results loading slowly ([#4657](https://github.com/lbryio/lbry-desktop/pull/4657))
|
- Fix related + search results loading slowly ([#4657](https://github.com/lbryio/lbry-desktop/pull/4657))
|
||||||
- Fix partially untranslated text in the Upgrade Modal _community pr!_ ([#4722](https://github.com/lbryio/lbry-desktop/pull/4722))
|
- Fix partially untranslated text in the Upgrade Modal _community pr!_ ([#4722](https://github.com/lbryio/lbry-desktop/pull/4722))
|
||||||
- Fix floating player being paused after dragging _community pr!_ ([#4710](https://github.com/lbryio/lbry-desktop/pull/4710))
|
- Fix floating player being paused after dragging _community pr!_ ([#4710](https://github.com/lbryio/lbry-desktop/pull/4710))
|
||||||
|
- Web: Fix 'Download' not triggering until second attempt _community pr!_ ([#4721](https://github.com/lbryio/lbry-desktop/pull/4721))
|
||||||
|
|
||||||
## [0.47.1] - [2020-07-23]
|
## [0.47.1] - [2020-07-23]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// @flow
|
// @flow
|
||||||
import type { Node } from 'react';
|
|
||||||
import { SIMPLE_SITE } from 'config';
|
import { SIMPLE_SITE } from 'config';
|
||||||
import * as PAGES from 'constants/pages';
|
import * as PAGES from 'constants/pages';
|
||||||
import * as CS from 'constants/claim_search';
|
import * as CS from 'constants/claim_search';
|
||||||
|
@ -48,80 +47,89 @@ function FileActions(props: Props) {
|
||||||
editUri = buildURI(uriObject);
|
editUri = buildURI(uriObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ActionWrapper = (props: { children: Node }) =>
|
const lhsSection = (
|
||||||
isMobile ? (
|
<>
|
||||||
<React.Fragment>{props.children}</React.Fragment>
|
<Button
|
||||||
) : (
|
button="alt"
|
||||||
<div className="section__actions section__actions--no-margin">{props.children}</div>
|
icon={ICONS.SHARE}
|
||||||
);
|
label={__('Share')}
|
||||||
|
onClick={() => openModal(MODALS.SOCIAL_SHARE, { uri, webShareable })}
|
||||||
|
/>
|
||||||
|
|
||||||
return (
|
{!SIMPLE_SITE && (
|
||||||
<div className="media__actions">
|
<div className="button-group">
|
||||||
<ActionWrapper>
|
<Button
|
||||||
<Button
|
button="alt"
|
||||||
button="alt"
|
icon={ICONS.REPOST}
|
||||||
icon={ICONS.SHARE}
|
label={__('Repost')}
|
||||||
label={__('Share')}
|
requiresAuth={IS_WEB}
|
||||||
onClick={() => openModal(MODALS.SOCIAL_SHARE, { uri, webShareable })}
|
onClick={() => openModal(MODALS.REPOST, { uri })}
|
||||||
/>
|
/>
|
||||||
|
{claim.meta.reposted > 0 && (
|
||||||
{!SIMPLE_SITE && (
|
|
||||||
<div className="button-group">
|
|
||||||
<Button
|
<Button
|
||||||
button="alt"
|
button="alt"
|
||||||
icon={ICONS.REPOST}
|
label={claim.meta.reposted}
|
||||||
label={__('Repost')}
|
|
||||||
requiresAuth={IS_WEB}
|
requiresAuth={IS_WEB}
|
||||||
onClick={() => openModal(MODALS.REPOST, { uri })}
|
navigate={`/$/${PAGES.DISCOVER}?${CS.REPOSTED_URI_KEY}=${encodeURIComponent(uri)}`}
|
||||||
/>
|
/>
|
||||||
{claim.meta.reposted > 0 && (
|
)}
|
||||||
<Button
|
</div>
|
||||||
button="alt"
|
)}
|
||||||
label={claim.meta.reposted}
|
<ClaimSupportButton uri={uri} />
|
||||||
requiresAuth={IS_WEB}
|
</>
|
||||||
navigate={`/$/${PAGES.DISCOVER}?${CS.REPOSTED_URI_KEY}=${encodeURIComponent(uri)}`}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<ClaimSupportButton uri={uri} />
|
|
||||||
</ActionWrapper>
|
|
||||||
|
|
||||||
<ActionWrapper>
|
|
||||||
{!SIMPLE_SITE && <FileDownloadLink uri={uri} />}
|
|
||||||
|
|
||||||
{claimIsMine && (
|
|
||||||
<Button
|
|
||||||
button="alt"
|
|
||||||
icon={ICONS.EDIT}
|
|
||||||
label={__('Edit')}
|
|
||||||
navigate="/$/upload"
|
|
||||||
onClick={() => {
|
|
||||||
prepareEdit(claim, editUri, fileInfo);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{showDelete && (
|
|
||||||
<Button
|
|
||||||
title={__('Remove from your library')}
|
|
||||||
button="alt"
|
|
||||||
icon={ICONS.DELETE}
|
|
||||||
description={__('Delete')}
|
|
||||||
onClick={() => openModal(MODALS.CONFIRM_FILE_REMOVE, { uri })}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{!claimIsMine && !SIMPLE_SITE && (
|
|
||||||
<Button
|
|
||||||
title={__('Report content')}
|
|
||||||
button="alt"
|
|
||||||
icon={ICONS.REPORT}
|
|
||||||
href={`https://lbry.com/dmca/${claimId}`}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</ActionWrapper>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const rhsSection = (
|
||||||
|
<>
|
||||||
|
{!SIMPLE_SITE && <FileDownloadLink uri={uri} />}
|
||||||
|
|
||||||
|
{claimIsMine && (
|
||||||
|
<Button
|
||||||
|
button="alt"
|
||||||
|
icon={ICONS.EDIT}
|
||||||
|
label={__('Edit')}
|
||||||
|
navigate="/$/upload"
|
||||||
|
onClick={() => {
|
||||||
|
prepareEdit(claim, editUri, fileInfo);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{showDelete && (
|
||||||
|
<Button
|
||||||
|
title={__('Remove from your library')}
|
||||||
|
button="alt"
|
||||||
|
icon={ICONS.DELETE}
|
||||||
|
description={__('Delete')}
|
||||||
|
onClick={() => openModal(MODALS.CONFIRM_FILE_REMOVE, { uri })}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{!claimIsMine && !SIMPLE_SITE && (
|
||||||
|
<Button
|
||||||
|
title={__('Report content')}
|
||||||
|
button="alt"
|
||||||
|
icon={ICONS.REPORT}
|
||||||
|
href={`https://lbry.com/dmca/${claimId}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isMobile) {
|
||||||
|
return (
|
||||||
|
<div className="media__actions">
|
||||||
|
{lhsSection}
|
||||||
|
{rhsSection}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div className="media__actions">
|
||||||
|
<div className="section__actions section__actions--no-margin">{lhsSection}</div>
|
||||||
|
<div className="section__actions section__actions--no-margin">{rhsSection}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FileActions;
|
export default FileActions;
|
||||||
|
|
Loading…
Add table
Reference in a new issue