Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bfce236d8 |
No files matched your search
@@ -43,6 +43,8 @@ module.name_mapper='^web\/page\(.*\)$' -> '<PROJECT_ROOT>/web/page\1'
|
||||
module.name_mapper='^homepage\(.*\)$' -> '<PROJECT_ROOT>/ui/util/homepage\1'
|
||||
module.name_mapper='^scss\/component\(.*\)$' -> '<PROJECT_ROOT>/ui/scss/component/\1'
|
||||
|
||||
esproposal.optional_chaining=enable
|
||||
|
||||
; Extensions
|
||||
module.file_ext=.js
|
||||
module.file_ext=.jsx
|
||||
@@ -51,4 +53,5 @@ module.file_ext=.css
|
||||
module.file_ext=.scss
|
||||
|
||||
|
||||
|
||||
[strict]
|
||||
Regular → Executable
File mode changed.
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
// @flow
|
||||
|
||||
declare type FileListItem = {
|
||||
metadata: StreamMetadata,
|
||||
added_on: number,
|
||||
blobs_completed: number,
|
||||
blobs_in_stream: number,
|
||||
blobs_remaining: number,
|
||||
channel_claim_id: string,
|
||||
channel_name: string,
|
||||
claim_id: string,
|
||||
claim_name: string,
|
||||
completed: false,
|
||||
content_fee?: { txid: string },
|
||||
purchase_receipt?: { txid: string, amount: string },
|
||||
download_directory: string,
|
||||
download_path: string,
|
||||
file_name: string,
|
||||
key: string,
|
||||
mime_type: string,
|
||||
nout: number,
|
||||
outpoint: string,
|
||||
points_paid: number,
|
||||
protobuf: string,
|
||||
reflector_progress: number,
|
||||
sd_hash: string,
|
||||
status: string,
|
||||
stopped: false,
|
||||
stream_hash: string,
|
||||
stream_name: string,
|
||||
streaming_url: string,
|
||||
suggested_file_name: string,
|
||||
total_bytes: number,
|
||||
total_bytes_lower_bound: number,
|
||||
is_fully_reflected: boolean,
|
||||
// TODO: sdk plans to change `tx`
|
||||
// It isn't currently used by the apps
|
||||
tx: {},
|
||||
txid: string,
|
||||
uploading_to_reflector: boolean,
|
||||
written_bytes: number,
|
||||
};
|
||||
|
||||
declare type FileState = {
|
||||
failedPurchaseUris: Array<string>,
|
||||
purchasedUris: Array<string>,
|
||||
};
|
||||
|
||||
declare type PurchaseUriCompleted = {
|
||||
type: ACTIONS.PURCHASE_URI_COMPLETED,
|
||||
data: {
|
||||
uri: string,
|
||||
streamingUrl: string,
|
||||
},
|
||||
};
|
||||
|
||||
declare type PurchaseUriFailed = {
|
||||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: {
|
||||
uri: string,
|
||||
error: any,
|
||||
},
|
||||
};
|
||||
|
||||
declare type PurchaseUriStarted = {
|
||||
type: ACTIONS.PURCHASE_URI_STARTED,
|
||||
data: {
|
||||
uri: string,
|
||||
streamingUrl: string,
|
||||
},
|
||||
};
|
||||
|
||||
declare type DeletePurchasedUri = {
|
||||
type: ACTIONS.CLEAR_PURCHASED_URI_SUCCESS,
|
||||
data: {
|
||||
uri: string,
|
||||
},
|
||||
};
|
||||
@@ -75,6 +75,7 @@
|
||||
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
||||
"@babel/plugin-proposal-decorators": "^7.3.0",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.6.2",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||
"@babel/plugin-transform-flow-strip-types": "^7.2.3",
|
||||
"@babel/plugin-transform-runtime": "^7.4.3",
|
||||
|
||||
@@ -1638,6 +1638,7 @@
|
||||
"This link leads to an external website.": "This link leads to an external website.",
|
||||
"No Content Found": "No Content Found",
|
||||
"No Lists Found": "No Lists Found",
|
||||
"No matching playlists": "No matching playlists",
|
||||
"You have no lists! Create one from any playable content.": "You have no lists! Create one from any playable content.",
|
||||
"Pick": "Pick",
|
||||
"You have unpublished lists! %pick% one and publish it!": "You have unpublished lists! %pick% one and publish it!",
|
||||
@@ -2058,6 +2059,8 @@
|
||||
"MyAwesomeList": "MyAwesomeList",
|
||||
"My Awesome List": "My Awesome List",
|
||||
"This list has no items.": "This list has no items.",
|
||||
"1 item": "1 item",
|
||||
"%collectionCount% items": "%collectionCount% items",
|
||||
"Select File": "Select File",
|
||||
"File Selected": "File Selected",
|
||||
"Url": "Url",
|
||||
@@ -2175,10 +2178,21 @@
|
||||
"Card Last 4": "Card Last 4",
|
||||
"Search blocked channel name": "Search blocked channel name",
|
||||
"Discuss": "Discuss",
|
||||
"Play Next (SHIFT+N)": "Play Next (SHIFT+N)",
|
||||
"Play Previous (SHIFT+P)": "Play Previous (SHIFT+P)",
|
||||
"Finance": "Finance",
|
||||
"You followed @veritasium!": "You followed @veritasium!",
|
||||
"Downloading": "Downloading",
|
||||
"Do you cancel download this file?": "Do you cancel download this file?",
|
||||
"%remainingMinutes% minutes %remainSecond% seconds remaining": "%remainingMinutes% minutes %remainSecond% seconds remaining",
|
||||
"%remainSecond% seconds remaining": "%remainSecond% seconds remaining",
|
||||
"%written% of %total%": "%written% of %total%",
|
||||
"(%speed%/sec)": "(%speed%/sec)",
|
||||
"lbry.tv has been retired. You have been magically transported to Odysee.com. %more%": "lbry.tv has been retired. You have been magically transported to Odysee.com. %more%",
|
||||
"Show more livestreams": "Show more livestreams",
|
||||
"Creator": "Creator",
|
||||
"From comments": "From comments",
|
||||
"From search": "From search",
|
||||
"Manage tags": "Manage tags",
|
||||
"--end--": "--end--"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
+22
-6
@@ -10,6 +10,15 @@ import ElectronCookies from '@exponent/electron-cookies';
|
||||
import { generateInitialUrl } from 'util/url';
|
||||
// @endif
|
||||
import { MATOMO_ID, MATOMO_URL } from 'config';
|
||||
// import getConnectionSpeed from 'util/detect-user-bandwidth';
|
||||
|
||||
// let userDownloadBandwidthInBitsPerSecond;
|
||||
// async function getUserBandwidth() {
|
||||
// userDownloadBandwidthInBitsPerSecond = await getConnectionSpeed();
|
||||
// }
|
||||
|
||||
// get user bandwidth every minute, starting after an initial one minute wait
|
||||
// setInterval(getUserBandwidth, 1000 * 60);
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const devInternalApis = process.env.LBRY_API_URL && process.env.LBRY_API_URL.includes('dev');
|
||||
@@ -40,7 +49,7 @@ type Analytics = {
|
||||
tagFollowEvent: (string, boolean, ?string) => void,
|
||||
playerLoadedEvent: (?boolean) => void,
|
||||
playerStartedEvent: (?boolean) => void,
|
||||
videoStartEvent: (string, number, string, number, string, any) => void,
|
||||
videoStartEvent: (string, number, string, number, string, any, number) => void,
|
||||
videoIsPlaying: (boolean, any) => void,
|
||||
videoBufferEvent: (
|
||||
StreamClaim,
|
||||
@@ -111,7 +120,7 @@ function getDeviceType() {
|
||||
// variables initialized for watchman
|
||||
let amountOfBufferEvents = 0;
|
||||
let amountOfBufferTimeInMS = 0;
|
||||
let videoType, userId, claimUrl, playerPoweredBy, videoPlayer;
|
||||
let videoType, userId, claimUrl, playerPoweredBy, videoPlayer, bitrateAsBitsPerSecond;
|
||||
let lastSentTime;
|
||||
|
||||
// calculate data for backend, send them, and reset buffer data for next interval
|
||||
@@ -130,6 +139,9 @@ async function sendAndResetWatchmanData() {
|
||||
let protocol;
|
||||
if (videoType === 'application/x-mpegURL') {
|
||||
protocol = 'hls';
|
||||
// get bandwidth if it exists from the texttrack (so it's accurate if user changes quality)
|
||||
// $FlowFixMe
|
||||
bitrateAsBitsPerSecond = videoPlayer.textTracks?.().tracks_[0]?.activeCues[0]?.value?.bandwidth;
|
||||
} else {
|
||||
protocol = 'stb';
|
||||
}
|
||||
@@ -152,6 +164,9 @@ async function sendAndResetWatchmanData() {
|
||||
user_id: userId.toString(),
|
||||
position: Math.round(positionInVideo),
|
||||
rel_position: Math.round((positionInVideo / (totalDurationInSeconds * 1000)) * 100),
|
||||
bitrate: bitrateAsBitsPerSecond,
|
||||
bandwidth: undefined,
|
||||
// ...(userDownloadBandwidthInBitsPerSecond && {bandwidth: userDownloadBandwidthInBitsPerSecond}), // add bandwidth if populated
|
||||
};
|
||||
|
||||
// post to watchman
|
||||
@@ -202,7 +217,7 @@ async function sendWatchmanData(body) {
|
||||
}
|
||||
|
||||
const analytics: Analytics = {
|
||||
// receive buffer events from tracking plugin and jklj
|
||||
// receive buffer events from tracking plugin and save buffer amounts and times for backend call
|
||||
videoBufferEvent: async (claim, data) => {
|
||||
amountOfBufferEvents = amountOfBufferEvents + 1;
|
||||
amountOfBufferTimeInMS = amountOfBufferTimeInMS + data.bufferDuration;
|
||||
@@ -240,7 +255,7 @@ const analytics: Analytics = {
|
||||
startWatchmanIntervalIfNotRunning();
|
||||
}
|
||||
},
|
||||
videoStartEvent: (claimId, timeToStartVideo, poweredBy, passedUserId, canonicalUrl, passedPlayer) => {
|
||||
videoStartEvent: (claimId, duration, poweredBy, passedUserId, canonicalUrl, passedPlayer, videoBitrate) => {
|
||||
// populate values for watchman when video starts
|
||||
userId = passedUserId;
|
||||
claimUrl = canonicalUrl;
|
||||
@@ -248,9 +263,10 @@ const analytics: Analytics = {
|
||||
|
||||
videoType = passedPlayer.currentSource().type;
|
||||
videoPlayer = passedPlayer;
|
||||
bitrateAsBitsPerSecond = videoBitrate;
|
||||
|
||||
sendPromMetric('time_to_start', timeToStartVideo);
|
||||
sendMatomoEvent('Media', 'TimeToStart', claimId, timeToStartVideo);
|
||||
sendPromMetric('time_to_start', duration);
|
||||
sendMatomoEvent('Media', 'TimeToStart', claimId, duration);
|
||||
},
|
||||
error: (message) => {
|
||||
return new Promise((resolve) => {
|
||||
|
||||
+13
-11
@@ -327,17 +327,19 @@ function App(props: Props) {
|
||||
|
||||
// Load IMA3 SDK for aniview: DISABLED FOR NOW
|
||||
// @if TARGET='web'
|
||||
useEffect(() => {
|
||||
const script = document.createElement('script');
|
||||
script.src = `https://imasdk.googleapis.com/js/sdkloader/ima3.js`;
|
||||
script.async = true;
|
||||
// $FlowFixMe
|
||||
document.body.appendChild(script);
|
||||
return () => {
|
||||
// $FlowFixMe
|
||||
document.body.removeChild(script);
|
||||
};
|
||||
});
|
||||
// useEffect(() => {
|
||||
// if (ENABLE_PREROLL_ADS) {
|
||||
// const script = document.createElement('script');
|
||||
// script.src = `https://imasdk.googleapis.com/js/sdkloader/ima3.js`;
|
||||
// script.async = true;
|
||||
// // $FlowFixMe
|
||||
// document.body.appendChild(script);
|
||||
// return () => {
|
||||
// // $FlowFixMe
|
||||
// document.body.removeChild(script);
|
||||
// };
|
||||
// }
|
||||
// });
|
||||
// @endif
|
||||
|
||||
// @if TARGET='app'
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
makeSelectClaimIsMine,
|
||||
makeSelectClaimIsPending,
|
||||
makeSelectClaimIsNsfw,
|
||||
doFileGet,
|
||||
makeSelectReflectingClaimForUri,
|
||||
makeSelectClaimWasPurchased,
|
||||
makeSelectStreamingUrlForUri,
|
||||
@@ -25,7 +24,7 @@ import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { makeSelectHasVisitedUri } from 'redux/selectors/content';
|
||||
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
|
||||
import { selectModerationBlockList } from 'redux/selectors/comments';
|
||||
|
||||
import { doFileGet } from 'redux/actions/file';
|
||||
import ClaimPreview from './view';
|
||||
import formatMediaDuration from 'util/formatMediaDuration';
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
makeSelectIsUriResolving,
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectTitleForUri,
|
||||
doFileGet,
|
||||
makeSelectChannelForClaimUri,
|
||||
makeSelectClaimIsNsfw,
|
||||
makeSelectClaimIsStreamPlaceholder,
|
||||
@@ -14,6 +13,7 @@ import {
|
||||
import { selectMutedChannels } from 'redux/selectors/blocked';
|
||||
import { makeSelectViewCountForUri, selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
|
||||
import { makeSelectIsActiveLivestream } from 'redux/selectors/livestream';
|
||||
import { doFileGet } from 'redux/actions/file';
|
||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import ClaimPreviewTile from './view';
|
||||
import formatMediaDuration from 'util/formatMediaDuration';
|
||||
|
||||
@@ -191,9 +191,11 @@ function ClaimPreviewTile(props: Props) {
|
||||
</div>
|
||||
<div className="placeholder__wrapper">
|
||||
<div className="placeholder claim-tile__title" />
|
||||
<div className={classnames('claim-tile__info placeholder', {
|
||||
'contains_view_count': shouldShowViewCount,
|
||||
})} />
|
||||
<div
|
||||
className={classnames('claim-tile__info placeholder', {
|
||||
contains_view_count: shouldShowViewCount,
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
@@ -253,9 +255,11 @@ function ClaimPreviewTile(props: Props) {
|
||||
<ClaimMenuList uri={uri} collectionId={listId} channelUri={channelUri} />
|
||||
</div>
|
||||
<div>
|
||||
<div className={classnames('claim-tile__info', {
|
||||
'contains_view_count': shouldShowViewCount,
|
||||
})}>
|
||||
<div
|
||||
className={classnames('claim-tile__info', {
|
||||
contains_view_count: shouldShowViewCount,
|
||||
})}
|
||||
>
|
||||
{isChannel ? (
|
||||
<div className="claim-tile__about--channel">
|
||||
<SubscribeButton uri={repostedChannelUri || uri} />
|
||||
|
||||
@@ -65,7 +65,7 @@ export default function CollectionContent(props: Props) {
|
||||
titleActions={
|
||||
<div className="card__title-actions--link">
|
||||
{/* TODO: BUTTON TO SAVE COLLECTION - Probably save/copy modal */}
|
||||
<Button label={'View List'} button="link" navigate={`/$/${PAGES.LIST}/${id}`} />
|
||||
<Button label={__('View List')} button="link" navigate={`/$/${PAGES.LIST}/${id}`} />
|
||||
</div>
|
||||
}
|
||||
body={
|
||||
|
||||
@@ -175,7 +175,7 @@ export default function CollectionsListMine(props: Props) {
|
||||
{filteredCollections &&
|
||||
filteredCollections.length > 0 &&
|
||||
filteredCollections.map((key) => <CollectionPreviewTile tileLayout collectionId={key} key={key} />)}
|
||||
{!filteredCollections.length && <div className="empty main--empty">{__('No matching collections')}</div>}
|
||||
{!filteredCollections.length && <div className="empty main--empty">{__('No matching playlists')}</div>}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -104,7 +104,11 @@ class DateTime extends React.Component<Props, State> {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <span className="date_time" title={moment(date).format(`MMMM Do, YYYY ${clockFormat}`)}>{DateTime.getTimeAgoStr(date)}</span>;
|
||||
return (
|
||||
<span className="date_time" title={moment(date).format(`MMMM Do, YYYY ${clockFormat}`)}>
|
||||
{DateTime.getTimeAgoStr(date)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import { connect } from 'react-redux';
|
||||
import DownloadProgress from './view';
|
||||
import { doSetPlayingUri, doStopDownload, doContinueDownloading, doPurchaseUriWrapper } from 'redux/actions/content';
|
||||
import { selectFileInfosByOutpoint, SETTINGS } from 'lbry-redux';
|
||||
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);
|
||||
@@ -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 'lbry-redux';
|
||||
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);
|
||||
}}
|
||||
>
|
||||
×
|
||||
</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;
|
||||
@@ -7,6 +7,7 @@ import SideNavigation from 'component/sideNavigation';
|
||||
import SettingsSideNavigation from 'component/settingsSideNavigation';
|
||||
import Header from 'component/header';
|
||||
/* @if TARGET='app' */
|
||||
import DownloadProgress from '../downloadProgress';
|
||||
import StatusBar from 'component/common/status-bar';
|
||||
/* @endif */
|
||||
import usePersistedState from 'effects/use-persisted-state';
|
||||
@@ -102,7 +103,7 @@ function Page(props: Props) {
|
||||
setSidebarOpen(false);
|
||||
}
|
||||
// TODO: make sure setState callback for usePersistedState uses useCallback to it doesn't cause effect to re-run
|
||||
}, [isOnFilePage, isMediumScreen]);
|
||||
}, [isOnFilePage, isMediumScreen, setSidebarOpen]);
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@@ -150,6 +151,9 @@ function Page(props: Props) {
|
||||
</React.Suspense>
|
||||
)}
|
||||
{/* @endif */}
|
||||
{/* @if TARGET='app' */}
|
||||
<DownloadProgress />
|
||||
{/* @endif */}
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
||||
import { selectPurchaseUriSuccess, doClearPurchasedUriSuccess } from 'lbry-redux';
|
||||
import { selectPurchaseUriSuccess } from 'lbry-redux';
|
||||
import { selectFollowedTags } from 'redux/selectors/tags';
|
||||
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
|
||||
import { selectHomepageData, selectLanguage } from 'redux/selectors/settings';
|
||||
import { doSignOut } from 'redux/actions/app';
|
||||
import { doClearPurchasedUriSuccess } from 'redux/actions/file';
|
||||
|
||||
import { selectUnseenNotificationCount } from 'redux/selectors/notifications';
|
||||
|
||||
import SideNavigation from './view';
|
||||
|
||||
@@ -30,11 +30,9 @@ const select = (state, props) => {
|
||||
const urlParams = new URLSearchParams(search);
|
||||
const autoplay = urlParams.get('autoplay');
|
||||
const uri = props.uri;
|
||||
|
||||
// TODO: eventually this should be received from DB and not local state (https://github.com/lbryio/lbry-desktop/issues/6796)
|
||||
const position = urlParams.get('t') !== null ? urlParams.get('t') : makeSelectContentPositionForUri(uri)(state);
|
||||
const userId = selectUser(state) && selectUser(state).id;
|
||||
const internalFeature = selectUser(state) && selectUser(state).internal_feature;
|
||||
const playingUri = selectPlayingUri(state);
|
||||
const collectionId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) || (playingUri && playingUri.collectionId);
|
||||
const isMarkdownOrComment = playingUri && (playingUri.source === 'markdown' || playingUri.source === 'comment');
|
||||
@@ -52,7 +50,6 @@ const select = (state, props) => {
|
||||
return {
|
||||
position,
|
||||
userId,
|
||||
internalFeature,
|
||||
collectionId,
|
||||
nextRecommendedUri,
|
||||
previousListUri,
|
||||
|
||||
@@ -26,19 +26,13 @@ const VERSION = '0.0.1';
|
||||
* */
|
||||
|
||||
// TEST PRE-ROLL WITH THIS TAG:
|
||||
// const macroUrl = 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonly&cmsid=496&vid=short_onecue&correlator=';
|
||||
|
||||
// live channel
|
||||
// b354389c7adb506d0bd9a4
|
||||
|
||||
// ford ad
|
||||
// 612fb75a42715a07645a614c
|
||||
// https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonly&cmsid=496&vid=short_onecue&correlator=
|
||||
|
||||
// Modified to work with IMA
|
||||
const macroUrl =
|
||||
`https://vast.aniview.com/api/adserver61/vast/` +
|
||||
`?AV_PUBLISHERID=60afcbc58cfdb065440d2426` +
|
||||
`&AV_CHANNELID=612fb75a42715a07645a614c` +
|
||||
`&AV_CHANNELID=60b354389c7adb506d0bd9a4` +
|
||||
`&AV_URL=[URL]` +
|
||||
`&cb=[CACHEBUSTING]` +
|
||||
`&AV_WIDTH=[WIDTH]` +
|
||||
@@ -51,7 +45,7 @@ const macroUrl =
|
||||
`&skiptimer=5` +
|
||||
`&logo=true` +
|
||||
`&usevslot=true` +
|
||||
`&vastretry=2` +
|
||||
`&vastretry=5` +
|
||||
`&hidecontrols=false`;
|
||||
|
||||
const defaults = {
|
||||
@@ -75,16 +69,16 @@ class AniviewPlugin extends Component {
|
||||
this.player = player;
|
||||
|
||||
// request ads whenever there's new video content
|
||||
player.on('contentchanged', () => {
|
||||
/* player.on('contentchanged', () => {
|
||||
// in a real plugin, you might fetch your ad inventory here
|
||||
player.trigger('adsready');
|
||||
});
|
||||
}); */
|
||||
|
||||
// Plugin event listeners
|
||||
player.on('readyforpreroll', (event) => this.onReadyForPreroll(event));
|
||||
// player.on('readyforpreroll', (event) => this.onReadyForPreroll(event));
|
||||
}
|
||||
|
||||
onReadyForPreroll(event) {
|
||||
/* onReadyForPreroll(event) {
|
||||
// send event when ad is playing to remove loading spinner
|
||||
this.player.one('adplaying', () => {
|
||||
this.player.trigger('ads-ad-started');
|
||||
@@ -94,7 +88,7 @@ class AniviewPlugin extends Component {
|
||||
this.player.one('adended', () => {
|
||||
this.player.ads.endLinearAdMode();
|
||||
});
|
||||
}
|
||||
} */
|
||||
|
||||
log(...args) {
|
||||
if (this.options_.debug) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import qualityLevels from 'videojs-contrib-quality-levels';
|
||||
import isUserTyping from 'util/detect-typing';
|
||||
// @if TARGET='web'
|
||||
// Disabled for now.
|
||||
import './plugins/videojs-aniview/plugin';
|
||||
// import './plugins/videojs-aniview/plugin';
|
||||
// @endif
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
|
||||
@@ -60,8 +60,7 @@ type Props = {
|
||||
adUrl: ?string,
|
||||
claimId: ?string,
|
||||
userId: ?number,
|
||||
allowPreRoll: ?boolean,
|
||||
internalFeatureEnabled: ?boolean,
|
||||
// allowPreRoll: ?boolean,
|
||||
shareTelemetry: boolean,
|
||||
replay: boolean,
|
||||
videoTheaterMode: boolean,
|
||||
@@ -78,30 +77,6 @@ type Props = {
|
||||
// muted?: boolean,
|
||||
// };
|
||||
|
||||
function hitsTwentyPercent() {
|
||||
// from 0 - 999
|
||||
var rand = Math.floor(Math.random() * (1000 + 1));
|
||||
|
||||
console.log(rand);
|
||||
console.log('rand');
|
||||
|
||||
setTimeout(function(){
|
||||
console.log('play here');
|
||||
player.play()
|
||||
}, 1000)
|
||||
|
||||
return true
|
||||
|
||||
|
||||
if (rand > 799) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const videoPlaybackRates = [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 1.75, 2];
|
||||
|
||||
const IS_IOS =
|
||||
@@ -203,8 +178,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
adUrl,
|
||||
claimId,
|
||||
userId,
|
||||
allowPreRoll,
|
||||
internalFeatureEnabled,
|
||||
// allowPreRoll,
|
||||
shareTelemetry,
|
||||
replay,
|
||||
videoTheaterMode,
|
||||
@@ -565,14 +539,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
// this seems like a weird thing to have to check for here
|
||||
if (!player) return;
|
||||
|
||||
// always have ads on if internal feature is on,
|
||||
// otherwise if not authed, roll for 20% to see an ad
|
||||
const shouldShowAnAd = internalFeatureEnabled || (allowPreRoll && hitsTwentyPercent());
|
||||
|
||||
if (shouldShowAnAd) {
|
||||
vjs.aniview();
|
||||
}
|
||||
|
||||
// Add various event listeners to player
|
||||
player.one('play', onInitialPlay);
|
||||
player.on('play', resolveCtrlText);
|
||||
@@ -613,7 +579,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
|
||||
// I think this is a callback function
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
|
||||
onPlayerReady(player, videoNode);
|
||||
});
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ type Props = {
|
||||
setVideoPlaybackRate: (number) => void,
|
||||
authenticated: boolean,
|
||||
userId: number,
|
||||
internalFeature: boolean,
|
||||
homepageData?: { [string]: HomepageCat },
|
||||
shareTelemetry: boolean,
|
||||
isFloating: boolean,
|
||||
@@ -99,7 +98,6 @@ function VideoViewer(props: Props) {
|
||||
homepageData,
|
||||
authenticated,
|
||||
userId,
|
||||
internalFeature,
|
||||
shareTelemetry,
|
||||
isFloating,
|
||||
doPlayUri,
|
||||
@@ -154,7 +152,6 @@ function VideoViewer(props: Props) {
|
||||
};
|
||||
}, [embedded, videoPlaybackRate]);
|
||||
|
||||
// TODO: analytics functionality
|
||||
function doTrackingBuffered(e: Event, data: any) {
|
||||
fetch(source, { method: 'HEAD', cache: 'no-store' }).then((response) => {
|
||||
data.playerPoweredBy = response.headers.get('x-powered-by');
|
||||
@@ -162,37 +159,37 @@ function VideoViewer(props: Props) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Analytics functionality that is run on first video start
|
||||
* @param e - event from videojs (from the plugin?)
|
||||
* @param data - only has secondsToLoad property
|
||||
*/
|
||||
function doTrackingFirstPlay(e: Event, data: any) {
|
||||
// how long until the video starts
|
||||
let timeToStartVideo = data.secondsToLoad;
|
||||
let timeToStart = data.secondsToLoad;
|
||||
|
||||
// TODO: what's happening here briefly?
|
||||
if (!IS_WEB) {
|
||||
if (desktopPlayStartTime !== undefined) {
|
||||
const differenceToAdd = Date.now() - desktopPlayStartTime;
|
||||
timeToStartVideo += differenceToAdd;
|
||||
}
|
||||
if (desktopPlayStartTime !== undefined) {
|
||||
const differenceToAdd = Date.now() - desktopPlayStartTime;
|
||||
timeToStart += differenceToAdd;
|
||||
}
|
||||
|
||||
// send matomo event (embedded is boolean)
|
||||
analytics.playerStartedEvent(embedded);
|
||||
|
||||
// figure out what server the video is served from and then run start analytic event
|
||||
fetch(source, { method: 'HEAD', cache: 'no-store' }).then((response) => {
|
||||
// server string such as 'eu-p6'
|
||||
let playerPoweredBy = response.headers.get('x-powered-by') || '';
|
||||
// convert bytes to bits, and then divide by seconds
|
||||
const contentInBits = Number(claim.value.source.size) * 8;
|
||||
const durationInSeconds = claim.value.video && claim.value.video.duration;
|
||||
let bitrateAsBitsPerSecond;
|
||||
if (durationInSeconds) {
|
||||
bitrateAsBitsPerSecond = Math.round(contentInBits / durationInSeconds);
|
||||
}
|
||||
|
||||
// populates data for watchman, sends prom and matomo event
|
||||
analytics.videoStartEvent(claimId, timeToStartVideo, playerPoweredBy, userId, claim.canonical_url, this);
|
||||
fetch(source, { method: 'HEAD', cache: 'no-store' }).then((response) => {
|
||||
let playerPoweredBy = response.headers.get('x-powered-by') || '';
|
||||
analytics.videoStartEvent(
|
||||
claimId,
|
||||
timeToStart,
|
||||
playerPoweredBy,
|
||||
userId,
|
||||
claim.canonical_url,
|
||||
this,
|
||||
bitrateAsBitsPerSecond
|
||||
);
|
||||
});
|
||||
|
||||
// hit backend to mark a view
|
||||
doAnalyticsView(uri, timeToStartVideo).then(() => {
|
||||
doAnalyticsView(uri, timeToStart).then(() => {
|
||||
claimRewards();
|
||||
});
|
||||
}
|
||||
@@ -275,7 +272,6 @@ function VideoViewer(props: Props) {
|
||||
clearPosition(uri);
|
||||
}, [adUrl, autoplayNext, clearPosition, collectionId, embedded, ended, setAdUrl, uri]);
|
||||
|
||||
// MORE ON PLAY STUFF
|
||||
function onPlay(player) {
|
||||
setEnded(false);
|
||||
setIsLoading(false);
|
||||
@@ -456,28 +452,29 @@ function VideoViewer(props: Props) {
|
||||
</>
|
||||
)}
|
||||
|
||||
<VideoJs
|
||||
adUrl={adUrl}
|
||||
source={adUrl || source}
|
||||
sourceType={forcePlayer || adUrl ? 'video/mp4' : contentType}
|
||||
isAudio={isAudio}
|
||||
poster={isAudio || (embedded && !autoplayIfEmbedded) ? thumbnail : ''}
|
||||
onPlayerReady={onPlayerReady}
|
||||
startMuted={autoplayIfEmbedded}
|
||||
toggleVideoTheaterMode={toggleVideoTheaterMode}
|
||||
autoplay={!embedded || autoplayIfEmbedded}
|
||||
autoplaySetting={autoplayNext}
|
||||
claimId={claimId}
|
||||
userId={userId}
|
||||
allowPreRoll={!authenticated} // used to not include embeds, removed for now
|
||||
internalFeatureEnabled={internalFeature}
|
||||
shareTelemetry={shareTelemetry}
|
||||
replay={replay}
|
||||
videoTheaterMode={videoTheaterMode}
|
||||
playNext={doPlayNext}
|
||||
playPrevious={doPlayPrevious}
|
||||
embedded={embedded}
|
||||
/>
|
||||
{!isFetchingAd && (
|
||||
<VideoJs
|
||||
adUrl={adUrl}
|
||||
source={adUrl || source}
|
||||
sourceType={forcePlayer || adUrl ? 'video/mp4' : contentType}
|
||||
isAudio={isAudio}
|
||||
poster={isAudio || (embedded && !autoplayIfEmbedded) ? thumbnail : ''}
|
||||
onPlayerReady={onPlayerReady}
|
||||
startMuted={autoplayIfEmbedded}
|
||||
toggleVideoTheaterMode={toggleVideoTheaterMode}
|
||||
autoplay={!embedded || autoplayIfEmbedded}
|
||||
autoplaySetting={autoplayNext}
|
||||
claimId={claimId}
|
||||
userId={userId}
|
||||
allowPreRoll={!embedded && !authenticated}
|
||||
shareTelemetry={shareTelemetry}
|
||||
replay={replay}
|
||||
videoTheaterMode={videoTheaterMode}
|
||||
playNext={doPlayNext}
|
||||
playPrevious={doPlayPrevious}
|
||||
embedded={embedded}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,13 @@ export const PLAY_VIDEO_STARTED = 'PLAY_VIDEO_STARTED';
|
||||
export const FETCH_AVAILABILITY_STARTED = 'FETCH_AVAILABILITY_STARTED';
|
||||
export const FETCH_AVAILABILITY_COMPLETED = 'FETCH_AVAILABILITY_COMPLETED';
|
||||
export const FILE_DELETE = 'FILE_DELETE';
|
||||
export const FETCH_FILE_INFO_FAILED = 'FETCH_FILE_INFO_FAILED';
|
||||
export const DOWNLOADING_CANCELED = 'DOWNLOADING_CANCELED';
|
||||
export const SET_FILE_LIST_SORT = 'SET_FILE_LIST_SORT';
|
||||
export const PURCHASE_URI_STARTED = 'PURCHASE_URI_STARTED';
|
||||
export const PURCHASE_URI_COMPLETED = 'PURCHASE_URI_COMPLETED';
|
||||
export const PURCHASE_URI_FAILED = 'PURCHASE_URI_FAILED';
|
||||
export const CLEAR_PURCHASED_URI_SUCCESS = 'CLEAR_PURCHASED_URI_SUCCESS';
|
||||
|
||||
// Search
|
||||
export const SEARCH_START = 'SEARCH_START';
|
||||
|
||||
@@ -102,7 +102,9 @@ export default function CollectionPage(props: Props) {
|
||||
|
||||
const subTitle = (
|
||||
<div>
|
||||
<span className="collection__subtitle">{collectionCount} items</span>
|
||||
<span className="collection__subtitle">
|
||||
{collectionCount === 1 ? __('1 item') : __('%collectionCount% items', { collectionCount })}
|
||||
</span>
|
||||
{uri && <ClaimAuthor uri={uri} />}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -32,28 +32,30 @@ export default function NotificationSettingsPage(props: Props) {
|
||||
const lbryIoParams = verificationToken ? { auth_token: verificationToken } : undefined;
|
||||
|
||||
React.useEffect(() => {
|
||||
Lbryio.call('tag', 'list', lbryIoParams)
|
||||
.then(setTags)
|
||||
.catch((e) => {
|
||||
setError(true);
|
||||
});
|
||||
if (isAuthenticated) {
|
||||
Lbryio.call('tag', 'list', lbryIoParams)
|
||||
.then(setTags)
|
||||
.catch((e) => {
|
||||
setError(true);
|
||||
});
|
||||
|
||||
Lbryio.call('user_email', 'status', lbryIoParams)
|
||||
.then((res) => {
|
||||
const enabledEmails =
|
||||
res.emails &&
|
||||
Object.keys(res.emails).reduce((acc, email) => {
|
||||
const isEnabled = res.emails[email];
|
||||
return [...acc, { email, isEnabled }];
|
||||
}, []);
|
||||
Lbryio.call('user_email', 'status', lbryIoParams)
|
||||
.then((res) => {
|
||||
const enabledEmails =
|
||||
res.emails &&
|
||||
Object.keys(res.emails).reduce((acc, email) => {
|
||||
const isEnabled = res.emails[email];
|
||||
return [...acc, { email, isEnabled }];
|
||||
}, []);
|
||||
|
||||
setTagMap(res.tags);
|
||||
setEnabledEmails(enabledEmails);
|
||||
})
|
||||
.catch((e) => {
|
||||
setError(true);
|
||||
});
|
||||
}, []);
|
||||
setTagMap(res.tags);
|
||||
setEnabledEmails(enabledEmails);
|
||||
})
|
||||
.catch((e) => {
|
||||
setError(true);
|
||||
});
|
||||
}
|
||||
}, [isAuthenticated]);
|
||||
|
||||
function handleChangeTag(name, newIsEnabled) {
|
||||
const tagParams = newIsEnabled ? { add: name } : { remove: name };
|
||||
|
||||
@@ -505,6 +505,7 @@ export function doAnalyticsBuffer(uri, bufferData) {
|
||||
const fileSizeInBits = fileSize * 8;
|
||||
const bitRate = parseInt(fileSizeInBits / fileDurationInSeconds);
|
||||
const userId = user && user.id.toString();
|
||||
// if there's a logged in user, send buffer event data to watchman
|
||||
if (userId) {
|
||||
analytics.videoBufferEvent(claim, {
|
||||
timeAtBuffer,
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
SETTINGS,
|
||||
makeSelectFileInfoForUri,
|
||||
selectFileInfosByOutpoint,
|
||||
doPurchaseUri,
|
||||
makeSelectUriIsStreamable,
|
||||
selectDownloadingByOutpoint,
|
||||
makeSelectClaimForUri,
|
||||
@@ -19,26 +18,28 @@ import {
|
||||
doToast,
|
||||
makeSelectUrlsForCollectionId,
|
||||
} from 'lbry-redux';
|
||||
import { doPurchaseUri, doDeleteFile } from 'redux/actions/file';
|
||||
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,
|
||||
@@ -53,6 +54,7 @@ export function doUpdateLoadStatus(uri: string, outpoint: string) {
|
||||
setNextStatusUpdate();
|
||||
} else if (fileInfo.completed) {
|
||||
// TODO this isn't going to get called if they reload the client before
|
||||
|
||||
// the download finished
|
||||
dispatch({
|
||||
type: ACTIONS.DOWNLOADING_COMPLETED,
|
||||
@@ -98,6 +100,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({
|
||||
@@ -117,8 +138,8 @@ export function doSetPlayingUri({
|
||||
uri: ?string,
|
||||
source?: string,
|
||||
commentId?: string,
|
||||
pathname: string,
|
||||
collectionId: string,
|
||||
pathname?: string,
|
||||
collectionId?: string,
|
||||
}) {
|
||||
return (dispatch: Dispatch) => {
|
||||
dispatch({
|
||||
@@ -140,7 +161,7 @@ export function doPurchaseUriWrapper(uri: string, cost: number, saveFile: boolea
|
||||
}
|
||||
}
|
||||
|
||||
dispatch(doPurchaseUri(uri, { costInfo: cost }, saveFile, onSuccess));
|
||||
dispatch(doPurchaseUri(uri, { cost }, saveFile, onSuccess));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+137
-7
@@ -1,3 +1,4 @@
|
||||
// @flow
|
||||
import * as ACTIONS from 'constants/action_types';
|
||||
// @if TARGET='app'
|
||||
import { shell } from 'electron';
|
||||
@@ -7,22 +8,28 @@ import {
|
||||
batchActions,
|
||||
doAbandonClaim,
|
||||
makeSelectFileInfoForUri,
|
||||
selectDownloadingByOutpoint,
|
||||
makeSelectStreamingUrlForUri,
|
||||
makeSelectClaimForUri,
|
||||
selectBalance,
|
||||
ABANDON_STATES,
|
||||
} from 'lbry-redux';
|
||||
import { doHideModal } from 'redux/actions/app';
|
||||
import { goBack } from 'connected-react-router';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { selectPlayingUri } from 'redux/selectors/content';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
type Dispatch = (action: any) => any;
|
||||
type GetState = () => { file: FileState };
|
||||
|
||||
export function doOpenFileInFolder(path) {
|
||||
export function doOpenFileInFolder(path: string) {
|
||||
return () => {
|
||||
shell.showItemInFolder(path);
|
||||
};
|
||||
}
|
||||
|
||||
export function doOpenFileInShell(path) {
|
||||
return (dispatch) => {
|
||||
export function doOpenFileInShell(path: string) {
|
||||
return (dispatch: Dispatch) => {
|
||||
const success = shell.openPath(path);
|
||||
if (!success) {
|
||||
dispatch(doOpenFileInFolder(path));
|
||||
@@ -30,8 +37,8 @@ export function doOpenFileInShell(path) {
|
||||
};
|
||||
}
|
||||
|
||||
export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim, cb) {
|
||||
return (dispatch) => {
|
||||
export function doDeleteFile(outpoint: string, deleteFromComputer?: boolean, abandonClaim?: boolean, cb: any) {
|
||||
return (dispatch: Dispatch) => {
|
||||
if (abandonClaim) {
|
||||
const [txid, nout] = outpoint.split(':');
|
||||
dispatch(doAbandonClaim(txid, Number(nout), cb));
|
||||
@@ -53,8 +60,13 @@ export function doDeleteFile(outpoint, deleteFromComputer, abandonClaim, cb) {
|
||||
};
|
||||
}
|
||||
|
||||
export function doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim, doGoBack) {
|
||||
return (dispatch, getState) => {
|
||||
export function doDeleteFileAndMaybeGoBack(
|
||||
uri: string,
|
||||
deleteFromComputer?: boolean,
|
||||
abandonClaim?: boolean,
|
||||
doGoBack: (any) => void
|
||||
) {
|
||||
return (dispatch: Dispatch, getState: GetState) => {
|
||||
const state = getState();
|
||||
const playingUri = selectPlayingUri(state);
|
||||
const { outpoint } = makeSelectFileInfoForUri(uri)(state) || '';
|
||||
@@ -88,3 +100,121 @@ export function doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim
|
||||
dispatch(batchActions(...actions));
|
||||
};
|
||||
}
|
||||
|
||||
export function doFileGet(uri: string, saveFile: boolean = true, onSuccess?: (GetResponse) => any) {
|
||||
return (dispatch: Dispatch, getState: () => any) => {
|
||||
const state = getState();
|
||||
const { nout, txid } = makeSelectClaimForUri(uri)(state);
|
||||
const outpoint = `${txid}:${nout}`;
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_FILE_INFO_STARTED,
|
||||
data: {
|
||||
outpoint,
|
||||
},
|
||||
});
|
||||
|
||||
// set save_file argument to True to save the file (old behaviour)
|
||||
Lbry.get({ uri, save_file: saveFile })
|
||||
.then((streamInfo: GetResponse) => {
|
||||
const timeout = streamInfo === null || typeof streamInfo !== 'object' || streamInfo.error === 'Timeout';
|
||||
if (timeout) {
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_FILE_INFO_FAILED,
|
||||
data: { outpoint },
|
||||
});
|
||||
|
||||
dispatch(doToast({ message: `File timeout for uri ${uri}`, isError: true }));
|
||||
} else {
|
||||
if (streamInfo.purchase_receipt || streamInfo.content_fee) {
|
||||
dispatch({
|
||||
type: ACTIONS.PURCHASE_URI_COMPLETED,
|
||||
data: { uri, purchaseReceipt: streamInfo.purchase_receipt || streamInfo.content_fee },
|
||||
});
|
||||
}
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_FILE_INFO_COMPLETED,
|
||||
data: {
|
||||
fileInfo: streamInfo,
|
||||
outpoint: outpoint,
|
||||
},
|
||||
});
|
||||
|
||||
if (onSuccess) {
|
||||
onSuccess(streamInfo);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
dispatch({
|
||||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: { uri, error },
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.FETCH_FILE_INFO_FAILED,
|
||||
data: { outpoint },
|
||||
});
|
||||
|
||||
dispatch(
|
||||
doToast({
|
||||
message: `Failed to view ${uri}, please try again. If this problem persists, visit https://lbry.com/faq/support for support.`,
|
||||
isError: true,
|
||||
})
|
||||
);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function doPurchaseUri(
|
||||
uri: string,
|
||||
costInfo: { cost: number },
|
||||
saveFile: boolean = true,
|
||||
onSuccess?: (GetResponse) => any
|
||||
) {
|
||||
return (dispatch: Dispatch, getState: GetState) => {
|
||||
dispatch({
|
||||
type: ACTIONS.PURCHASE_URI_STARTED,
|
||||
data: { uri },
|
||||
});
|
||||
|
||||
const state = getState();
|
||||
const balance = selectBalance(state);
|
||||
const fileInfo = makeSelectFileInfoForUri(uri)(state);
|
||||
const downloadingByOutpoint = selectDownloadingByOutpoint(state);
|
||||
const alreadyDownloading = fileInfo && !!downloadingByOutpoint[fileInfo.outpoint];
|
||||
const alreadyStreaming = makeSelectStreamingUrlForUri(uri)(state);
|
||||
|
||||
if (!saveFile && (alreadyDownloading || alreadyStreaming)) {
|
||||
dispatch({
|
||||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: { uri, error: `Already fetching uri: ${uri}` },
|
||||
});
|
||||
|
||||
if (onSuccess) {
|
||||
onSuccess(fileInfo);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const { cost } = costInfo;
|
||||
if (parseFloat(cost) > balance) {
|
||||
dispatch({
|
||||
type: ACTIONS.PURCHASE_URI_FAILED,
|
||||
data: { uri, error: 'Insufficient credits' },
|
||||
});
|
||||
|
||||
Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(doFileGet(uri, saveFile, onSuccess));
|
||||
};
|
||||
}
|
||||
|
||||
export function doClearPurchasedUriSuccess() {
|
||||
return {
|
||||
type: ACTIONS.CLEAR_PURCHASED_URI_SUCCESS,
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import { selectClaimsByUri, selectIsFetchingClaimListMine, selectMyClaims } from 'lbry-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
export const selectState = state => state.fileInfo || {};
|
||||
export const selectState = (state) => state.fileInfo || {};
|
||||
|
||||
export const selectFileInfosByOutpoint = createSelector(selectState, state => state.byOutpoint || {});
|
||||
export const selectFileInfosByOutpoint = createSelector(selectState, (state) => state.byOutpoint || {});
|
||||
|
||||
export const selectIsFetchingFileList = createSelector(selectState, state => state.isFetchingFileList);
|
||||
export const selectIsFetchingFileList = createSelector(selectState, (state) => state.isFetchingFileList);
|
||||
|
||||
export const selectIsFetchingFileListDownloadedOrPublished = createSelector(
|
||||
selectIsFetchingFileList,
|
||||
@@ -13,31 +13,31 @@ export const selectIsFetchingFileListDownloadedOrPublished = createSelector(
|
||||
(isFetchingFileList, isFetchingClaimListMine) => isFetchingFileList || isFetchingClaimListMine
|
||||
);
|
||||
|
||||
export const makeSelectFileInfoForUri = uri =>
|
||||
export const makeSelectFileInfoForUri = (uri) =>
|
||||
createSelector(selectClaimsByUri, selectFileInfosByOutpoint, (claims, byOutpoint) => {
|
||||
const claim = claims[uri];
|
||||
const outpoint = claim ? `${claim.txid}:${claim.nout}` : undefined;
|
||||
return outpoint ? byOutpoint[outpoint] : undefined;
|
||||
});
|
||||
|
||||
export const selectDownloadingByOutpoint = createSelector(selectState, state => state.downloadingByOutpoint || {});
|
||||
export const selectDownloadingByOutpoint = createSelector(selectState, (state) => state.downloadingByOutpoint || {});
|
||||
|
||||
export const makeSelectDownloadingForUri = uri =>
|
||||
export const makeSelectDownloadingForUri = (uri) =>
|
||||
createSelector(selectDownloadingByOutpoint, makeSelectFileInfoForUri(uri), (byOutpoint, fileInfo) => {
|
||||
if (!fileInfo) return false;
|
||||
return byOutpoint[fileInfo.outpoint];
|
||||
});
|
||||
|
||||
export const selectUrisLoading = createSelector(selectState, state => state.urisLoading || {});
|
||||
export const selectUrisLoading = createSelector(selectState, (state) => state.urisLoading || {});
|
||||
|
||||
export const makeSelectLoadingForUri = uri => createSelector(selectUrisLoading, byUri => byUri && byUri[uri]);
|
||||
export const makeSelectLoadingForUri = (uri) => createSelector(selectUrisLoading, (byUri) => byUri && byUri[uri]);
|
||||
|
||||
export const selectFileInfosDownloaded = createSelector(
|
||||
selectFileInfosByOutpoint,
|
||||
selectMyClaims,
|
||||
(byOutpoint, myClaims) =>
|
||||
Object.values(byOutpoint).filter(fileInfo => {
|
||||
const myClaimIds = myClaims.map(claim => claim.claim_id);
|
||||
Object.values(byOutpoint).filter((fileInfo) => {
|
||||
const myClaimIds = myClaims.map((claim) => claim.claim_id);
|
||||
|
||||
return fileInfo && myClaimIds.indexOf(fileInfo.claim_id) === -1 && (fileInfo.completed || fileInfo.written_bytes);
|
||||
})
|
||||
@@ -59,7 +59,7 @@ export const selectDownloadingFileInfos = createSelector(
|
||||
const outpoints = Object.keys(downloadingByOutpoint);
|
||||
const fileInfos = [];
|
||||
|
||||
outpoints.forEach(outpoint => {
|
||||
outpoints.forEach((outpoint) => {
|
||||
const fileInfo = fileInfosByOutpoint[outpoint];
|
||||
|
||||
if (fileInfo) fileInfos.push(fileInfo);
|
||||
@@ -69,10 +69,10 @@ export const selectDownloadingFileInfos = createSelector(
|
||||
}
|
||||
);
|
||||
|
||||
export const selectTotalDownloadProgress = createSelector(selectDownloadingFileInfos, fileInfos => {
|
||||
export const selectTotalDownloadProgress = createSelector(selectDownloadingFileInfos, (fileInfos) => {
|
||||
const progress = [];
|
||||
|
||||
fileInfos.forEach(fileInfo => {
|
||||
fileInfos.forEach((fileInfo) => {
|
||||
progress.push((fileInfo.written_bytes / fileInfo.total_bytes) * 100);
|
||||
});
|
||||
|
||||
@@ -82,4 +82,4 @@ export const selectTotalDownloadProgress = createSelector(selectDownloadingFileI
|
||||
return -1;
|
||||
});
|
||||
|
||||
export const selectFileInfoErrors = createSelector(selectState, state => state.errors || {});
|
||||
export const selectFileInfoErrors = createSelector(selectState, (state) => state.errors || {});
|
||||
@@ -68,3 +68,4 @@
|
||||
@import 'component/empty';
|
||||
@import 'component/stripe-card';
|
||||
@import 'component/wallet-tip-send';
|
||||
@import 'component/download-progress';
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,11 @@
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.menu__link-disable {
|
||||
@extend .menu__link;
|
||||
color: var(--color-text-subtitle) !important;
|
||||
}
|
||||
|
||||
.menu__link--notification {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
const imageAddr = 'https://upload.wikimedia.org/wikipedia/commons/b/b9/Pizigani_1367_Chart_1MB.jpg';
|
||||
const downloadSize = 1093957; // this must match with the image above
|
||||
|
||||
let startTime, endTime;
|
||||
async function measureConnectionSpeed() {
|
||||
startTime = new Date().getTime();
|
||||
const cacheBuster = '?nnn=' + startTime;
|
||||
|
||||
const download = new Image();
|
||||
download.src = imageAddr + cacheBuster;
|
||||
// this returns when the image is finished downloading
|
||||
await download.decode();
|
||||
endTime = new Date().getTime();
|
||||
const duration = (endTime - startTime) / 1000;
|
||||
const bitsLoaded = downloadSize * 8;
|
||||
const speedBps = (bitsLoaded / duration).toFixed(2);
|
||||
return Math.round(Number(speedBps));
|
||||
}
|
||||
|
||||
module.exports = measureConnectionSpeed;
|
||||
@@ -69,3 +69,4 @@
|
||||
@import '../../ui/scss/component/empty';
|
||||
@import '../../ui/scss/component/stripe-card';
|
||||
@import '../../ui/scss/component/wallet-tip-send';
|
||||
@import '../../ui/scss/component/download-progress';
|
||||
@@ -149,7 +149,7 @@ const webConfig = {
|
||||
test: /\.jsx?$/,
|
||||
options: {
|
||||
presets: ['@babel/env', '@babel/react', '@babel/flow'],
|
||||
plugins: ['@babel/plugin-proposal-object-rest-spread', '@babel/plugin-proposal-class-properties'],
|
||||
plugins: ['@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-object-rest-spread', '@babel/plugin-proposal-class-properties'],
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -329,6 +329,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375"
|
||||
integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg==
|
||||
|
||||
"@babel/helper-plugin-utils@^7.14.5":
|
||||
version "7.14.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.14.5.tgz#5ac822ce97eec46741ab70a517971e443a70c5a9"
|
||||
integrity sha512-/37qQCE3K0vvZKwoK4XU/irIJQdIfCJuhU5eKnNxpFDsOkgFaUAwbv+RYw6eYgsC0E4hS7r5KqGULUogqui0fQ==
|
||||
|
||||
"@babel/helper-remap-async-to-generator@^7.12.1":
|
||||
version "7.12.1"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.12.1.tgz#8c4dbbf916314f6047dc05e6a2217074238347fd"
|
||||
@@ -390,6 +395,13 @@
|
||||
dependencies:
|
||||
"@babel/types" "^7.12.1"
|
||||
|
||||
"@babel/helper-skip-transparent-expression-wrappers@^7.14.5":
|
||||
version "7.15.4"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.15.4.tgz#707dbdba1f4ad0fa34f9114fc8197aec7d5da2eb"
|
||||
integrity sha512-BMRLsdh+D1/aap19TycS4eD1qELGrCBJwzaY9IE8LrpJtJb+H7rQkPIdsfgnMtLBA6DJls7X9z93Z4U8h7xw0A==
|
||||
dependencies:
|
||||
"@babel/types" "^7.15.4"
|
||||
|
||||
"@babel/helper-split-export-declaration@^7.10.1":
|
||||
version "7.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz#c6f4be1cbc15e3a868e4c64a17d5d31d754da35f"
|
||||
@@ -426,6 +438,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz#c9a1f021917dcb5ccf0d4e453e399022981fc9ed"
|
||||
integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==
|
||||
|
||||
"@babel/helper-validator-identifier@^7.14.9":
|
||||
version "7.15.7"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz#220df993bfe904a4a6b02ab4f3385a5ebf6e2389"
|
||||
integrity sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==
|
||||
|
||||
"@babel/helper-validator-option@^7.12.1", "@babel/helper-validator-option@^7.12.11":
|
||||
version "7.12.11"
|
||||
resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.12.11.tgz#d66cb8b7a3e7fe4c6962b32020a131ecf0847f4f"
|
||||
@@ -590,6 +607,15 @@
|
||||
"@babel/helper-skip-transparent-expression-wrappers" "^7.12.1"
|
||||
"@babel/plugin-syntax-optional-chaining" "^7.8.0"
|
||||
|
||||
"@babel/plugin-proposal-optional-chaining@^7.14.5":
|
||||
version "7.14.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.14.5.tgz#fa83651e60a360e3f13797eef00b8d519695b603"
|
||||
integrity sha512-ycz+VOzo2UbWNI1rQXxIuMOzrDdHGrI23fRiz/Si2R4kv2XZQ1BK8ccdHwehMKBlcH/joGW/tzrUmo67gbJHlQ==
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.14.5"
|
||||
"@babel/helper-skip-transparent-expression-wrappers" "^7.14.5"
|
||||
"@babel/plugin-syntax-optional-chaining" "^7.8.3"
|
||||
|
||||
"@babel/plugin-proposal-private-methods@^7.12.1":
|
||||
version "7.12.1"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.12.1.tgz#86814f6e7a21374c980c10d38b4493e703f4a389"
|
||||
@@ -694,7 +720,7 @@
|
||||
dependencies:
|
||||
"@babel/helper-plugin-utils" "^7.8.0"
|
||||
|
||||
"@babel/plugin-syntax-optional-chaining@^7.8.0":
|
||||
"@babel/plugin-syntax-optional-chaining@^7.8.0", "@babel/plugin-syntax-optional-chaining@^7.8.3":
|
||||
version "7.8.3"
|
||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz#4f69c2ab95167e0180cd5336613f8c5788f7d48a"
|
||||
integrity sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==
|
||||
@@ -1230,6 +1256,14 @@
|
||||
lodash "^4.17.19"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@babel/types@^7.15.4":
|
||||
version "7.15.6"
|
||||
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.15.6.tgz#99abdc48218b2881c058dd0a7ab05b99c9be758f"
|
||||
integrity sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==
|
||||
dependencies:
|
||||
"@babel/helper-validator-identifier" "^7.14.9"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@datapunt/matomo-tracker-js@^0.1.4":
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@datapunt/matomo-tracker-js/-/matomo-tracker-js-0.1.4.tgz#1226f0964d2c062bf9392e9c2fd89838262b10df"
|
||||
@@ -16391,9 +16425,9 @@ url-parse-lax@^3.0.0:
|
||||
prepend-http "^2.0.0"
|
||||
|
||||
url-parse@^1.1.1, url-parse@^1.1.8, url-parse@^1.4.3:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.1.tgz#d5fa9890af8a5e1f274a2c98376510f6425f6e3b"
|
||||
integrity sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==
|
||||
version "1.5.3"
|
||||
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.3.tgz#71c1303d38fb6639ade183c2992c8cc0686df862"
|
||||
integrity sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ==
|
||||
dependencies:
|
||||
querystringify "^2.1.1"
|
||||
requires-port "^1.0.0"
|
||||
|
||||
Reference in new issue
Block a user