Compare commits

...

3 commits

Author SHA1 Message Date
zeppi
57d51a4cdb fix rebase more 2021-11-13 16:23:56 -05:00
zeppi
424308ef09 fix rebase 2021-11-13 16:15:29 -05:00
bluerabbit001
bfffc53a94 Implement Download Progress
Implement Download Progress

Revert "Stream Key Button (#7127)"

I forgot to lint before merging. Reverting for now, will fix in a bit.

This reverts commit 5c8878353f.

Restore "Stream Key Button (#7127)" + lint and modifications

- Consolidate functionality into existing component.
- Use proper strings.

Localize sunset nag

Changed the text a bit so that we can re-use the existing 'Learn more'.

Don't allow assigning yourself as moderator

Also fixed split-string (hard to localize).

Comment: Swap the order of "Edit" and "Remove"

This order is more common.

Blocklist page: fix perpetual spinner when trying to refresh with no channels

There's nothing to do when you don't have a channel, so hide the button and ensure redux fails gracefully.

i18n

Livestream category improvements (#7115)

*  Remove old method of displaying active livestreams

Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.

* Fetch and store active-livestream info in redux

* Tiles can now query active-livestream state from redux instead of getting from parent.

*  ClaimTilesDiscover: revert and cleanup

- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.

- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....

* ClaimTilesDiscover: factor out options

Move the `option` code outside and passed in as a pre-calculated prop.

To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.

Instead of calculating `options` twice, we moved it to the props so both sides can use it.

It also makes the component a bit more readable.

The downside is that the prop-passing might not be clear.

* ClaimTilesDiscover: reduce ~17 renders at startup to just 2.

* ClaimTilesDiscover: fill with placeholder while waiting for claim_search

Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).

Fill up the space with placeholders to prevent layout shift.

* Add 'useFetchViewCount' to handle fetching from lists

This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).

*  ClaimListDiscover: revert and cleanup

- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.

- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.

* ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover

This will be initially used to append livestreams at the top.

*  Re-enable active livestream tiles using the new method

* doFetchActiveLivestreams: add interval check

- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.

* doFetchActiveLivestreams: add option check

We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.

* WildWest: limit livestream tiles + add ability to show more

Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.

This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.

* Use better tile-count on larger screens.

Used the same method as how the homepage does it.

Fix video embeds in comments not playing and resize issues (#7163)

-- tmp revert --

This reverts commit 3b47edc3b9 to allow putting back in the original commits.

 Remove old method of displaying active livestreams

Completely remove it for now to make the commit deltas clearer.
We'll replace it with the new method at the end.

Fetch and store active-livestream info in redux

Tiles can now query active-livestream state from redux instead of getting from parent.

 ClaimTilesDiscover: revert and cleanup

- Simplify to just `uris` instead of having multiple arrays (`uris`, `modifiedUris`, `prevUris`)
- The `prevUris` is for CLS prevention. With this removal, the CLS issue is back, but we'll handle it differently later.
- Temporarily disable the view-count fetching. Code is left there so that I don't forget.

- `shouldPerformSearch` was never true when `prefixUris` is present. Corrected the logic.
- Aside: prefix and pin is so similar in function. Hm ....

ClaimTilesDiscover: factor out options

Move the `option` code outside and passed in as a pre-calculated prop.

To skip rendering while waiting for `claim_search`, we need to add `React.memo(areEqual)`. However, the flag that determines if we are fetching `claim_search` (fetchingClaimSearchByQuery[]) depends on the derived options as the key.

Instead of calculating `options` twice, we moved it to the props so both sides can use it.

It also makes the component a bit more readable.

The downside is that the prop-passing might not be clear.

ClaimTilesDiscover: reduce ~17 renders at startup to just 2.

ClaimTilesDiscover: fill with placeholder while waiting for claim_search

Livestream claims are fetched seperately, so they might already exists. While claim_search is running, the list only consists of livestreams (collapsed).

Fill up the space with placeholders to prevent layout shift.

Add 'useFetchViewCount' to handle fetching from lists

This effect also stashes fetched uris, so that we won't re-fetch the same uris during the same instance (e.g. during infinite scroll).

 ClaimListDiscover: revert and cleanup

- Removed the 'finalUris' stuff that was meant to "pause" visual changes when fetching. I think it'll be cleaner to use React.memo to achieve that.

- Added `renderUri` to make it clear which array that this component will render.
- Re-do the way we fetch view counts now that 'finalUris' is gone. Not the best method, but at least correct for now.

ClaimListDiscover: add prefixUris, similar to ClaimTilesDiscover

This will be initially used to append livestreams at the top.

 Re-enable active livestream tiles using the new method

doFetchActiveLivestreams: add interval and options checking

- Added a default minimum of 5 minutes between fetches. Clients can bypass this through `forceFetch` if needed.
- We'll need to support different 'orderBy', so adding an "options check" when determining if we just made the same fetch.

WildWest: limit livestream tiles + add ability to show more

Most likely this behavior will change in the future, so we'll leave `ClaimListDiscover` untouched and handle the logic at the page level.

This solution uses 2 `ClaimListDiscover` -- if the reduced livestream list is visible, it handles the header; else the normal list handles the header.

Fix homepage tiles not filtering blocked channels

7165 homepage queries don't take into account blocked channel ids (mute does)

resolveSearchOptions: was not grabbing redux data correctly.

Adjust comment fade-out height

6944 Comment expansion sometimes doesn't reveal extra text (already showing everything)

Reconcile some constants between JS and CSS.

force mp3 extension vs mpga

Fix autoplay next default value (#7173)

Fix missed render when blocklist is fetched

7176

Pitfalls of pausing render via React.memo:
  - We'll miss the `doClaimSearch()` since that is sparked by an `useEffect`.

Seems like we can't avoid having a redundant copy of the previously-displayed URIs.

Memoize 'mutedAndBlockedChannelIds'

It was being recalculated repeatedly.

This memoizes it, although it still re-calculates occasionally despite none of the source arrays changed. I think it is due to the state change in the Preference Sync.

Note: input selectors to `createSelector` needs to be extractions-only (i.e. must not have transformations). I think most of our `makeSelect*` selectors violate this and broke memoization.

Fix “Your Account” popup on mobile (#5652) (#7172)

* Fix “Your Account” popup on mobile (#5652)

* Update changelog

Co-authored-by: Branko Tomic <branko@spicefactory.co>

Fix issue where channel upload viewcounts were creating a new line (#7154)

* fix issue where viewcounts were creating a new line

* conditionally add large view css

* conditionally apply class based on if view count should be shown

* last couple touchups

* clean up the css

* add scss to flow config

* add scss component to flow config

use homepage LATEST for following discover (#7185)

Commentron now includes `replies` for `ByID` request

Wasn't aware of that, and that was causing 7146 ("show replies" visible when there are no replies).

Fix page titles for SiteLinks

Part of `7166 improve search metadata`, where page titles are important clues for Google to generate Site-Links.

Add icons (#7194)

fix playlist resolving collectionurls (#7178)

* fix playlist resolving collectionurls

* Update CHANGELOG.md

Co-authored-by: Thomas Zarebczan <tzarebczan@users.noreply.github.com>

Fix plant icon (#7195)

* Fix plant icon

* Also change phone icon name

Add Channel Mention selection ability (#7151)

* Add Channel Mention selection ability

* Fix mentioned user name being smaller than other text

* Improve logic for locating a mention

* Fix mentioning with enter on livestream

* Fix breaking for invalid URI query

* Handle punctuation after mention

* Fix name display and appeareance

* Use canonical url

* Fix missing search

i18n - ChannelMention and other fixes

Fix wrong 'recsysId' sent due to search-key mismatch

.../archives/C02FQBM00Q0/p1633044695010600

When querying a search key, it has to be an exact match. This was broken by the insertion of `free_only` in the fetch.

Added a function to generate the options, so that all clients stay in sync.

Fix linked-comment scrolling

I think this the best solution so far, at the expense of a slight delay in scrolling if the network call stalls.

- Added "fetching by ID" state so that we don't need to use the ugly N-retries method.
- `scrollIntoView` doesn't work if the element is already in the viewport, and the `scrollBy` adjustment doesn't take into account the y-position restoration that we perform on certain type of pages. Use `window.scrollTo` instead and taking into account current scroll position.

Prevent random description in Google Search results for "odysee" (#7206)

7166 improve search metadata

Depending on the search term and timing, Google extracts data from the sidebar or page content to use as the search-result description.

Defined `description` (on top of the existing `og:description` and `twitter:description`.

While I couldn't find a definitive doc saying that this is the solution, this is present in all other sites (and matches their description in a Google Search results).

Add favicon for Google Search results (#7205)

- A side-quest from "7166 improve search metadata".
- The favicon must be from the same domain as the homepage, so the CDN URL couldn't be used, hence the additional upload.
- The favicon also needs to be multiples of 48x48 and above.
    - Wanted to use SVG for the smallest size possible, but seems like Safari does not fully support it. Got Dejan to give me a reasonably-sized PNG.

https://developers.google.com/search/docs/advanced/appearance/favicon-in-search#guidelines

List own comments (#7171)

* Add option to pass in url-search params.

Impetus: allow linked comment ID and setting the discussion tab when clicking on the `ClaimPreview`.

* comment.list: fix typos and renamed variables

- Switch from 'author' to 'creator' to disambiguate between comment author and content author. For comment author, we'll use 'commenter' from now on.
- Corrected 'commenterClaimId' to 'creatorClaimId' (just a typo, no functional change).

* doCommentReset: change param from uri to claimId

This reduces one lookup as clients will always have the claimID ready, but might not have the full URI.

It was using URI previously just to match the other APIs.

* Add doCommentListOwn -- command to fetch own comments

Since the redux slice is set up based on content or channel ID (for Channel Discussion page), re-use the channel ID for the case of "own comments". We always clear each ID when fetching page-0, so no worries of conflict when actually browsing the Channel Discussion page.

* Comment: add option to hide the actions section

* Implement own-comments page

* Use new param to remove sort-pins-first.

comment.List currently always pushes pins to the top to support pagination. This new param removes this behavior.

Fix resolving invalid claims (#7210)

Update icons.js

--- tmp revert ---

This reverts commit de6c6f9bfd.

Add option to pass in url-search params.

Impetus: allow linked comment ID and setting the discussion tab when clicking on the `ClaimPreview`.

comment.list: fix typos and renamed variables

- Switch from 'author' to 'creator' to disambiguate between comment author and content author. For comment author, we'll use 'commenter' from now on.
- Corrected 'commenterClaimId' to 'creatorClaimId' (just a typo, no functional change).

doCommentReset: change param from uri to claimId

This reduces one lookup as clients will always have the claimID ready, but might not have the full URI.

It was using URI previously just to match the other APIs.

Add doCommentListOwn -- command to fetch own comments

Since the redux slice is set up based on content or channel ID (for Channel Discussion page), re-use the channel ID for the case of "own comments". We always clear each ID when fetching page-0, so no worries of conflict when actually browsing the Channel Discussion page.

Comment: add option to hide the actions section

Implement own-comments page

Use new param to remove sort-pins-first.

comment.List currently always pushes pins to the top to support pagination. This new param removes this behavior.

Corrected meta for "description" (patch for #7206)

It should be `name`, not `property`. Copy-paste error from the OG version.

Fix 'pinnedUrl' error.

Part of "6989 Fix console spam in dev"

EXTRA_SIDEBAR_LINKS should be a `SideNavLink` object, so trim down the return object from `GetLinksData`.

Temp workaround SDK 0 count

Temp workaround claims in channel count 0

patch creator analytics with hub without channel claim count

patch hubs claims_in_channel temporarily

OG: fix url for categories

Category cards are showing up as "odysee.com" cards in Facebook.

- `og:url` is supposed to be the canonical URL. It was hardcoded to "odysee.com", so every category was being redirected when the card is being generated.
- Removed `twitter:url`. The documentation says it will fall back to `og:url`, so there is not need to define both if it's the same.

OG: Technology category missing due to rename

- 'technology' was renamed to 'tech'.
- Leave both entries there for now. Not sure if other homepages still use the old link or not.

Fix spacing / centering live stream + comments section (#7225)

Add copy comment link menu option (#7224)

adjust css for toast message so that it behaves as expected (text truncation via ellipsis) (#7213)

Refactor commentsList

Remove expand/collapse from channel discussion page

Prevent comment content from breaking the layout on mobile

ESLint fix

Update Dark theme and fix playing issue

Fix playlist strings

Add sitemap to influence Sitelinks

Part of `7166 improve search metadata`

This is an experiment to influence the Sitelinks in our search results. Our current sitemap only consists of claims, so claims appear in Sitelinks more often. We (Julian) want categories to have higher priority, if possible.

For now, the sitemap will be defined in Google Console instead of robots.txt.

If it works, the file should be uploaded to sitemap.odysee.com, alongside the claim list sitemap.

Revert "Add sitemap to influence Sitelinks"

Seems like I messed up robots.txt?

This reverts commit 95654955b1.

Bump url-parse from 1.5.1 to 1.5.3 (#7230)

Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.1 to 1.5.3.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](https://github.com/unshiftio/url-parse/compare/1.5.1...1.5.3)

---
updated-dependencies:
- dependency-name: url-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

fix notifications page on unauthed app (#7226)

move file actions from lbry-redux

Send video bitrate and user bandwidth to Watchman (#7145)

* adding functionality to detect user download speed

* calculating bandwidth speed more intelligently

* saving download speed and updating it every 30s

* all the functionality should be done needs testing

* fix linting

* use a 1mb file for calculating bandwidth

* add optional chaining plugin to babel and get bitrate from texttrack

* allow optional chaining for flow

* ignore flow error

* disable bandwidth checking functionality

* fix flow error

Fix ESLint

Update Download Progress

Update CSS
2021-11-13 15:58:18 -05:00
13 changed files with 637 additions and 6 deletions

BIN
static/img/dark_loading.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

View file

@ -187,7 +187,7 @@ function ClaimPreviewTile(props: Props) {
<div className="placeholder claim-tile__title" />
<div
className={classnames('claim-tile__info placeholder', {
contains_view_count: shouldShowViewCount,
'contains_view_count': shouldShowViewCount,
})}
/>
</div>
@ -247,7 +247,7 @@ function ClaimPreviewTile(props: Props) {
<div>
<div
className={classnames('claim-tile__info', {
contains_view_count: shouldShowViewCount,
'contains_view_count': shouldShowViewCount,
})}
>
{isChannel ? (

View file

@ -0,0 +1,49 @@
import { connect } from 'react-redux';
import DownloadProgress from './view';
import { doSetPlayingUri, doStopDownload, doContinueDownloading, doPurchaseUriWrapper } from 'redux/actions/content';
import * as SETTINGS from 'constants/settings';
import { selectFileInfosByOutpoint } from 'redux/selectors/file_info';
import { selectPrimaryUri, selectPlayingUri } from 'redux/selectors/content';
import { makeSelectClientSetting } from 'redux/selectors/settings';
const select = (state) => {
const byOutpoint = selectFileInfosByOutpoint(state);
const runningByOutpoint = [];
const primaryUri = selectPrimaryUri(state);
const playingUri = selectPlayingUri(state);
const uri = playingUri ? playingUri.uri : null;
let primaryOutpoint = null;
let playingOutpoint = null;
for (const key in byOutpoint) {
const item = byOutpoint[key];
if (item && primaryUri && primaryUri.includes(`/${item.claim_name}`)) primaryOutpoint = item.outpoint;
if (item && uri && uri.includes(`/${item.claim_name}`)) playingOutpoint = item.outpoint;
if (item && item.status === 'running') {
runningByOutpoint.push(item);
}
}
return {
byOutpoint: selectFileInfosByOutpoint(state),
primary: {
uri: primaryUri,
outpoint: primaryOutpoint,
},
playing: {
uri,
outpoint: playingOutpoint,
},
currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state),
};
};
const perform = (dispatch) => ({
pause: () => dispatch(doSetPlayingUri({ uri: null })),
doContinueDownloading: (outpoint, force) => dispatch(doContinueDownloading(outpoint, force)),
stopDownload: (outpoint) => dispatch(doStopDownload(outpoint)),
download: (uri) => dispatch(doPurchaseUriWrapper(uri, false, true)),
});
export default connect(select, perform)(DownloadProgress);

View file

@ -0,0 +1,286 @@
// @flow
import React, { useState, useEffect } from 'react';
import { shell } from 'electron';
import Button from 'component/button';
import * as ICONS from 'constants/icons';
import { buildURI } from 'util/lbryURI';
import { formatBytes } from 'util/format-bytes';
import { areEqual, removeItem } from 'util/array';
import loadingIcon from '../../../static/img/white_loading.gif';
import darkLoadingIcon from '../../../static/img/dark_loading.gif';
import usePersistedState from 'effects/use-persisted-state';
type Props = {
byOutpoint: any,
primary: any,
playing: any,
currentTheme: string,
stopDownload: (outpoint: string) => void,
doContinueDownloading: (outpoint: string, force: boolean) => void,
download: (uri: string) => void,
};
function DownloadProgress({ byOutpoint, primary, playing, currentTheme, stopDownload, doContinueDownloading }: Props) {
const [isShow, setIsShow] = usePersistedState('download-progress', true);
const [downloading, setDownloading] = usePersistedState('download-progress-downloading', []);
const [cancelHash] = useState({});
const [initDownloadingHash] = useState({});
const [prevPlaying, setPrevPlaying] = useState({});
const [prevPrimary, setPrevPrimary] = useState({});
const handleCancel = (hash, value) => {
cancelHash[hash] = value;
};
const handleStopDownload = (outpoint) => {
const updated = [...downloading];
removeItem(updated, outpoint);
setDownloading(updated);
stopDownload(outpoint);
};
const runningByOutpoint = {};
const currentDownloading = [...downloading];
for (const key in byOutpoint) {
const item = byOutpoint[key];
if (item && item.status === 'running') runningByOutpoint[item.outpoint] = item;
}
Object.keys(runningByOutpoint)
.filter((outpoint) => downloading.indexOf(outpoint) === -1)
.map((outpoint) => {
if (primary.outpoint !== outpoint && playing.outpoint !== outpoint) {
currentDownloading.push(outpoint);
}
});
downloading
.filter((outpoint) => (byOutpoint[outpoint] && byOutpoint[outpoint].status !== 'running') || !byOutpoint[outpoint])
.map((outpoint) => {
removeItem(currentDownloading, outpoint);
});
if (!areEqual(downloading, currentDownloading)) setDownloading(currentDownloading);
if (currentDownloading.length === 0) return null;
if (playing.outpoint !== prevPlaying.outpoint) {
if (downloading.includes(prevPlaying.outpoint)) {
setTimeout(() => {
doContinueDownloading(prevPlaying.outpoint, true);
}, 1000);
}
setPrevPlaying(playing);
}
if (primary.outpoint !== prevPrimary.outpoint) {
if (downloading.includes(prevPrimary.outpoint)) {
setTimeout(() => {
doContinueDownloading(prevPrimary.outpoint, true);
}, 1000);
}
setPrevPrimary(primary);
}
currentDownloading.map((outpoint) => {
if (!initDownloadingHash[outpoint]) {
initDownloadingHash[outpoint] = true;
doContinueDownloading(outpoint, false);
}
});
if (!isShow) {
return (
<>
<Button
iconSize={40}
icon={ICONS.DOWNLOAD}
className="download-progress__toggle-button"
onClick={() => setIsShow(true)}
>
<div className="download-progress__current-downloading">
<span className="notification__bubble">
<span className="notification__count">{currentDownloading.length}</span>
</span>
</div>
</Button>
</>
);
}
return (
<div className="download-progress__header">
<Button className="download-progress__top-close-button" onClick={() => setIsShow(false)}>
<div />
</Button>
{currentDownloading.map((outpoint, index) => {
const item = runningByOutpoint[outpoint];
let releaseTime = '';
let isPlaying = false;
if (item.metadata && item.metadata.release_time) {
releaseTime = new Date(parseInt(item.metadata.release_time) * 1000).toISOString().split('T')[0];
}
if (outpoint === primary.outpoint || outpoint === playing.outpoint) {
isPlaying = true;
}
return (
<div key={item.outpoint}>
{index !== 0 && <hr className="download-progress__divider" />}
<DownloadProgressItem
fileName={item.suggested_file_name}
title={item.metadata.title}
releaseTime={releaseTime}
writtenBytes={item.written_bytes}
totalBytes={item.total_bytes}
addedOn={item.added_on}
directory={item.download_directory}
stopDownload={handleStopDownload}
outpoint={item.outpoint}
isCancel={cancelHash[item.outpoint]}
claimID={item.claim_id}
playing={isPlaying}
claimName={item.claim_name}
handleCancel={handleCancel}
currentTheme={currentTheme}
/>
</div>
);
})}
</div>
);
}
type DownloadProgressItemProps = {
fileName: string,
writtenBytes: number,
totalBytes: number,
addedOn: number,
title: string,
releaseTime: string,
directory: string,
outpoint: string,
isCancel: boolean,
claimID: string,
claimName: string,
playing: boolean,
currentTheme: string,
stopDownload: (outpoint: string) => void,
handleCancel: (hash: string, value: boolean) => void,
};
function DownloadProgressItem({
fileName,
writtenBytes,
totalBytes,
addedOn,
title,
releaseTime,
directory,
outpoint,
isCancel,
claimID,
claimName,
playing,
currentTheme,
stopDownload,
handleCancel,
}: DownloadProgressItemProps) {
const processStopDownload = () => {
handleCancel(outpoint, false);
stopDownload(outpoint);
};
const [percent, setPercent] = useState(0);
const [progressText, setProgressText] = useState('');
useEffect(() => {
const updatePercent = ((writtenBytes / totalBytes) * 100).toFixed(0);
setPercent(updatePercent);
let updateText = '';
const downloadSpeed = Math.ceil(writtenBytes / (Date.now() / 1000 - addedOn));
const remainingSecond = Math.ceil((totalBytes - writtenBytes) / downloadSpeed);
const remainingMinutes = Math.floor(remainingSecond / 60);
if (remainingMinutes > 0) {
updateText += __('%remainingMinutes% minutes %remainSecond% seconds remaining', {
remainingMinutes: remainingMinutes,
remainSecond: remainingSecond - 60 * remainingMinutes,
});
} else {
updateText += __('%remainSecond% seconds remaining', { remainSecond: remainingSecond - 60 * remainingMinutes });
}
updateText += ' -- ';
updateText += __('%written% of %total%', {
written: formatBytes(writtenBytes),
total: formatBytes(totalBytes),
});
updateText += ' ';
updateText += __('(%speed%/sec)', {
speed: formatBytes(downloadSpeed),
});
setProgressText(updateText);
}, [writtenBytes, totalBytes, addedOn]);
const openDownloadFolder = () => {
shell.openPath(directory);
};
return (
<div className="download-progress__state-container">
<div className="download-progress__state-bar">
<Button
label={title}
className="download-progress__state-filename"
navigate={buildURI({ claimName, claimID })}
/>
{playing ? (
currentTheme === 'light' ? (
<img src={loadingIcon} className="download-progress__playing-button" />
) : (
<img src={darkLoadingIcon} className="download-progress__playing-button" />
)
) : (
<div
className="download-progress__close-button"
onClick={() => {
handleCancel(outpoint, true);
}}
>
&times;
</div>
)}
</div>
<div className="download-progress__state-bar">
<a className="download-progress__state-filename-link" onClick={openDownloadFolder}>
{fileName}
</a>
<p className="download-progress__release-time">{releaseTime}</p>
</div>
<div className="download-progress__state-bar">
<div className="download-progress__bar-container">
<div className="download-progress__bar-content" style={{ width: `${percent}%` }} />
</div>
</div>
<p className="download-progress__count-time">{progressText}</p>
{isCancel && (
<div className="download-progress__cancel">
<p>{__('Do you cancel download this file?')}</p>
<div className="download-progress__cancel-confirm">
<Button label={__('Yes')} className="download-progress__cancel-ok" onClick={processStopDownload} />
<Button
label={__('No')}
className="download-progress__cancel-ok"
onClick={() => handleCancel(outpoint, false)}
/>
</div>
</div>
)}
</div>
);
}
export default DownloadProgress;

View file

@ -5,6 +5,7 @@ import classnames from 'classnames';
import SideNavigation from 'component/sideNavigation';
import SettingsSideNavigation from 'component/settingsSideNavigation';
import Header from 'component/header';
import DownloadProgress from 'component/downloadProgress';
/* @if TARGET='app' */
import StatusBar from 'component/common/status-bar';
/* @endif */
@ -135,6 +136,7 @@ function Page(props: Props) {
<StatusBar />
{/* @endif */}
</div>
<DownloadProgress />
</Fragment>
);
}

View file

@ -14,29 +14,30 @@ import {
} from 'redux/selectors/file_info';
import { makeSelectUrlsForCollectionId } from 'redux/selectors/collections';
import { doToast } from 'redux/actions/notifications';
import { doPurchaseUri } from 'redux/actions/file';
import { doPurchaseUri, doDeleteFile } from 'redux/actions/file';
import Lbry from 'lbry';
import * as SETTINGS from 'constants/settings';
import { makeSelectCostInfoForUri, Lbryio } from 'lbryinc';
import { makeSelectClientSetting, selectosNotificationsEnabled, selectDaemonSettings } from 'redux/selectors/settings';
const DOWNLOAD_POLL_INTERVAL = 1000;
var timeOutHash = {};
export function doUpdateLoadStatus(uri: string, outpoint: string) {
export function doUpdateLoadStatus(uri: any, outpoint: string) {
// Updates the loading status for a uri as it's downloading
// Calls file_list and checks the written_bytes value to see if the number has increased
// Not needed on web as users aren't actually downloading the file
// @if TARGET='app'
return (dispatch: Dispatch, getState: GetState) => {
const setNextStatusUpdate = () =>
setTimeout(() => {
(timeOutHash[outpoint] = setTimeout(() => {
// We need to check if outpoint still exists first because user are able to delete file (outpoint) while downloading.
// If a file is already deleted, no point to still try update load status
const byOutpoint = selectFileInfosByOutpoint(getState());
if (byOutpoint[outpoint]) {
dispatch(doUpdateLoadStatus(uri, outpoint));
}
}, DOWNLOAD_POLL_INTERVAL);
}, DOWNLOAD_POLL_INTERVAL));
Lbry.file_list({
outpoint,
@ -96,6 +97,25 @@ export function doUpdateLoadStatus(uri: string, outpoint: string) {
// @endif
}
export function doContinueDownloading(outpoint: string, force: boolean) {
return (dispatch: Dispatch) => {
if (!timeOutHash[outpoint] || force) {
dispatch(doUpdateLoadStatus(null, outpoint));
}
};
}
export function doStopDownload(outpoint: string) {
return (dispatch: Dispatch) => {
if (timeOutHash[outpoint]) {
clearInterval(timeOutHash[outpoint]);
timeOutHash[outpoint] = undefined;
}
dispatch(doDeleteFile(outpoint, false, false, null));
};
}
export function doSetPrimaryUri(uri: ?string) {
return (dispatch: Dispatch) => {
dispatch({

View file

@ -66,3 +66,4 @@
@import 'component/empty';
@import 'component/stripe-card';
@import 'component/wallet-tip-send';
@import 'component/download-progress';

View file

@ -720,6 +720,7 @@
margin: 0 0;
padding: var(--spacing-xxs) var(--spacing-xxs);
height: unset;
background-color: var(--color-header-background);
// label (with 'Add' text) hidden by default
.button__label {

View file

@ -0,0 +1,224 @@
.download-progress__header {
padding: 15px;
position: fixed;
bottom: 0;
right: 0;
width: 400px;
display: flex;
flex-direction: column;
background-color: var(--color-header-background); //var(--color-gray-9):dark-mode
border-radius: var(--border-radius);
// border: 1px solid var(--color-gray-3);
z-index: 9999;
}
.download-progress__top-close-button {
position: absolute;
top: 7px;
right: 15px;
font-size: 35px;
background-color: transparent;
width: 15px;
height: 15px;
div {
height: 2px;
width: 13px;
background-color: var(--color-gray-4);
border-radius: var(--border-radius);
}
}
.download-progress__state-container {
margin-top: 10px;
padding-bottom: 10px;
display: flex;
flex-direction: column;
width: 100%;
}
.download-progress__state-filename {
margin: 0;
font-weight: 800;
font-size: 13px;
flex: 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-right: 10px;
span.button__label {
color: var(--color-text);
}
}
.download-progress__state-filename-link {
margin: 0;
font-weight: 800;
font-size: 13px;
flex: 1;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-right: 10px;
text-decoration: underline;
cursor: pointer;
}
.download-progress__release-time {
margin: 0;
font-weight: 800;
font-size: 12px;
margin-left: auto;
font-style: italic;
}
.download-progress__state-bar {
display: flex;
flex-direction: row;
width: 100%;
align-items: center;
margin-bottom: 2px;
}
.download-progress__bar-container {
width: 100%;
background-color: var(--color-gray-5);
height: 6px;
border-radius: var(--border-radius);
}
.download-progress__bar-content {
border-radius: var(--border-radius);
height: 100%;
background-color: var(--color-primary);
}
.download-progress__close-button {
flex-shrink: 0;
margin-left: auto;
font-size: 20px;
cursor: pointer;
}
.download-progress__playing-button {
flex-shrink: 0;
margin-left: auto;
width: 29.6px;
height: 29.6px;
}
.download-progress__count-time {
font-size: 11px;
letter-spacing: -0.6px;
}
.download-progress__divider {
border-top: 1px solid var(--color-gray-6);
margin-left: -15px;
width: 110%;
}
.download-progress__cancel {
margin-top: 7px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.download-progress__cancel p {
margin: 0;
font-size: 12px;
margin: 0;
white-space: nowrap;
width: 285px;
overflow: hidden;
text-overflow: ellipsis;
}
.download-progress__cancel b {
font-size: 13px;
}
.download-progress__cancel-confirm {
width: 90px;
display: flex;
justify-content: space-around;
align-items: center;
}
.download-progress__cancel-ok {
border: none;
background-color: transparent;
font-size: 13px;
color: var(--color-text);
}
.download-progress__cancel-ok:hover {
color: var(--color-primary);
}
.download__container {
position: fixed;
bottom: 10px;
right: 10px;
width: 400px;
height: 300px;
border-radius: var(--border-radius);
box-shadow: 2px 2px 5px var(--color-gray-4);
background-color: var(--color-white);
transition: width 2s;
}
.download-progress__toggle-button {
position: fixed;
bottom: 10px;
right: 10px;
border: none;
background: var(--color-header-background);
color: var(--color-gray-6);
width: 50px;
height: 50px;
border-radius: var(--border-radius);
box-shadow: 0px 5px 4px var(--color-gray-4);
display: flex;
justify-content: center;
align-items: center;
}
.download_close_modal {
float: right;
margin-right: 10px;
font-size: 25px;
}
.download-progress__current-downloading {
position: fixed;
bottom: 25px;
right: 15px;
border: none;
width: 30px;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
animation-name: downloadcount;
animation-duration: 1.3s;
animation-iteration-count: infinite;
.notification__bubble {
height: 1.5rem;
width: 1.5rem;
border-radius: 50%;
background-color: var(--color-editor-tag);
position: absolute;
top: -0.5rem;
right: -0.5rem;
color: white;
font-size: var(--font-small);
font-weight: bold;
line-height: 1;
display: flex;
align-items: center;
justify-content: center;
}
.notification__bubble--small {
font-size: var(--font-xsmall);
}
.notification__bubble--inline {
@extend .notification__bubble;
top: 0.75rem;
right: 1rem;
}
}
@keyframes downloadcount {
0% {
transform: translateY(-10px);
}
50% {
transform: translateY(-3px);
}
100% {
transform: translateY(-10px);
}
}

View file

@ -121,6 +121,12 @@
overflow-x: hidden;
}
.menu__link-disable {
@extend .menu__link;
color: var(--color-text-subtitle)!important;
}
.menu__link--notification {
width: 100%;
display: flex;

18
ui/util/array.js Normal file
View file

@ -0,0 +1,18 @@
export function areEqual(first, second) {
if (first.length !== second.length) {
return false;
}
for (let i = 0; i < first.length; i++) {
if (!second.includes(first[i])) {
return false;
}
}
return true;
}
export function removeItem(array, item) {
const index = array.indexOf(item);
if (index > -1) {
array.splice(index, 1);
}
}

24
ui/util/livestream.js Normal file
View file

@ -0,0 +1,24 @@
// @flow
/**
* Helper to extract livestream claim uris from the output of
* `selectActiveLivestreams`.
*
* @param activeLivestreams Object obtained from `selectActiveLivestreams`.
* @param channelIds List of channel IDs to filter the results with.
* @returns {[]|Array<*>}
*/
export function getLivestreamUris(activeLivestreams: ?LivestreamInfo, channelIds: ?Array<string>) {
let values = (activeLivestreams && Object.values(activeLivestreams)) || [];
if (channelIds && channelIds.length > 0) {
// $FlowFixMe
values = values.filter((v) => channelIds.includes(v.creatorId) && Boolean(v.latestClaimUri));
} else {
// $FlowFixMe
values = values.filter((v) => Boolean(v.latestClaimUri));
}
// $FlowFixMe
return values.map((v) => v.latestClaimUri);
}