Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4f62dbefe |
No files matched your search
+2
-2
@@ -11,7 +11,7 @@ WEB_SERVER_PORT=1337
|
||||
LBRY_WEB_API=https://api.na-backend.odysee.com
|
||||
LBRY_WEB_STREAMING_API=https://cdn.lbryplayer.xyz
|
||||
LBRY_WEB_BUFFER_API=https://collector-service.api.lbry.tv/api/v1/events/video
|
||||
COMMENT_SERVER_API=https://comments.odysee.com/api/v2
|
||||
COMMENT_SERVER_API=https://comments.odysee.tv/api/v2
|
||||
COMMENT_SERVER_NAME=Odysee
|
||||
SEARCH_SERVER_API=https://lighthouse.odysee.com/search
|
||||
SOCKETY_SERVER_API=wss://sockety.odysee.com/ws
|
||||
@@ -80,7 +80,7 @@ SIMPLE_SITE=false
|
||||
|
||||
ENABLE_COMMENT_REACTIONS=true
|
||||
ENABLE_FILE_REACTIONS=true
|
||||
ENABLE_CREATOR_REACTIONS=false
|
||||
ENABLE_CREATOR_REACTIONS=true
|
||||
ENABLE_NO_SOURCE_CLAIMS=false
|
||||
ENABLE_PREROLL_ADS=false
|
||||
CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS=4
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@
|
||||
.*\.typeface\.json
|
||||
.*/node_modules/findup/.*
|
||||
.*/node_modules/react-plastic/.*
|
||||
|
||||
.*/node_modules/raf-schd/.*
|
||||
.*/node_modules/react-beautiful-dnd/.*
|
||||
|
||||
[include]
|
||||
|
||||
|
||||
+31
-2
@@ -5,21 +5,50 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## [Unreleased for Desktop]
|
||||
|
||||
## [0.52.1-alpha.3] - [2021-12-31]
|
||||
## [0.52.4] - [2022-02-15]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed active channel ([#7481](https://github.com/lbryio/lbry-desktop/pull/7481))
|
||||
- Remove extra search button in header ([#7482](https://github.com/lbryio/lbry-desktop/pull/7482))
|
||||
|
||||
## [0.52.3] - [2022-02-15]
|
||||
|
||||
### Fixed
|
||||
- Fixed comment editing and pinning ([#7476](https://github.com/lbryio/lbry-desktop/pull/7476))
|
||||
- Fixed mac header ([#7479](https://github.com/lbryio/lbry-desktop/pull/7479))
|
||||
- Fixed markdown display and lbry url embedding ([#7474](https://github.com/lbryio/lbry-desktop/pull/7474))
|
||||
|
||||
## [0.52.2] - [2022-02-11]
|
||||
|
||||
### Added
|
||||
|
||||
- Reenabled generating thumbs from video ([#7384](https://github.com/lbryio/lbry-desktop/pull/7409))
|
||||
- Brought in playlist drag and drop playlist reordering _odysee team!_ ([#7442](https://github.com/lbryio/lbry-desktop/pull/7442))
|
||||
- Added duration overlays to ClaimPreview component ([#7420](https://github.com/lbryio/lbry-desktop/pull/7420))
|
||||
- Some Horizontal Scroll groundwork from _odysee team!_
|
||||
- Comment Emotes and Stickers and Mentions refactors from _odysee team!_ ([#7435](https://github.com/lbryio/lbry-desktop/pull/7435))
|
||||
- Seek forward and back from _odysee team!_ () ([#7460](https://github.com/lbryio/lbry-desktop/pull/7460))
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgraded Electron to v15 ([#7384](https://github.com/lbryio/lbry-desktop/pull/7384))
|
||||
- Performance improvements in some selectors ([#7370](https://github.com/lbryio/lbry-desktop/pull/7370))
|
||||
- More Header refactoring from _odysee team!_ ([#7441](https://github.com/lbryio/lbry-desktop/pull/7441))
|
||||
- Header refactoring from _odysee team!_ ([#7440](https://github.com/lbryio/lbry-desktop/pull/7440))
|
||||
- Data hosting ui _incomplete_ ([#7438](https://github.com/lbryio/lbry-desktop/pull/7438))
|
||||
- Updated c: control tags from _odysee team!_ ([#7433](https://github.com/lbryio/lbry-desktop/pull/7433))
|
||||
- Nav keycodes (alt+left) no longer navigate while textarea is focused ([#7458](https://github.com/lbryio/lbry-desktop/pull/7458))
|
||||
- Improved comment-server selection ui/ux ([#7455](https://github.com/lbryio/lbry-desktop/pull/7455))
|
||||
- Improved Data Hosting settings ([#7563](https://github.com/lbryio/lbry-desktop/pull/7563))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Several fallout bugs from recent changes
|
||||
- Added duration overlays to ClaimPreview component ([#7420](https://github.com/lbryio/lbry-desktop/pull/7420))
|
||||
|
||||
## [0.52.1]
|
||||
|
||||
### Skipped patch version
|
||||
|
||||
## [0.52.0] - [2021-12-31]
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { TO_TRAY_WHEN_CLOSED } from 'constants/settings';
|
||||
import setupBarMenu from './menu/setupBarMenu';
|
||||
import * as PAGES from 'constants/pages';
|
||||
const remote = require('@electron/remote/main');
|
||||
const shell = require('electron').shell;
|
||||
function GetAppLangCode() {
|
||||
// https://www.electronjs.org/docs/api/locales
|
||||
// 1. Gets the user locale.
|
||||
@@ -190,6 +191,11 @@ export default appState => {
|
||||
});
|
||||
|
||||
window.webContents.setWindowOpenHandler((details) => {
|
||||
// Only open http and https links to prevent
|
||||
// security issues.
|
||||
if (['https:', 'http:'].includes(new URL(details.url).protocol)) {
|
||||
shell.openExternal(details.url);
|
||||
}
|
||||
return { action: 'deny' };
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as ACTIONS from 'constants/action_types';
|
||||
import { Lbryio } from 'lbryinc';
|
||||
import { selectClaimsByUri } from 'redux/selectors/claims';
|
||||
import { selectClaimForUri } from 'redux/selectors/claims';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function doFetchCostInfoForUri(uri) {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const claim = selectClaimsByUri(state)[uri];
|
||||
const claim = selectClaimForUri(state, uri);
|
||||
|
||||
if (!claim) return;
|
||||
|
||||
|
||||
Vendored
+1
-2
@@ -24,9 +24,8 @@ declare type CollectionGroup = {
|
||||
}
|
||||
|
||||
declare type CollectionEditParams = {
|
||||
claims?: Array<Claim>,
|
||||
uris?: Array<string>,
|
||||
remove?: boolean,
|
||||
claimIds?: Array<string>,
|
||||
replace?: boolean,
|
||||
order?: { from: number, to: number },
|
||||
type?: string,
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
declare type CommentServerDetails = {
|
||||
name: string,
|
||||
url: string,
|
||||
}
|
||||
|
||||
declare type WalletServerDetails = {
|
||||
|
||||
};
|
||||
+5
-6
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lbry",
|
||||
"version": "0.52.1-alpha.5",
|
||||
"version": "0.52.4",
|
||||
"description": "A browser for the LBRY network, a digital marketplace controlled by its users.",
|
||||
"keywords": [
|
||||
"lbry"
|
||||
@@ -44,10 +44,10 @@
|
||||
"postinstall:warning": "echo '\n\nWARNING\n\nNot all node modules were installed because NODE_ENV is set to \"production\".\nThis should only be set after installing dependencies with \"yarn\". The app will not work.\n\n'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron/remote": "^2.0.1",
|
||||
"@emotion/react": "^11.6.0",
|
||||
"@emotion/styled": "^11.6.0",
|
||||
"@mui/material": "^5.2.1",
|
||||
"@electron/remote": "^2.0.1",
|
||||
"@ungap/from-entries": "^0.2.1",
|
||||
"auto-launch": "^5.0.5",
|
||||
"electron-dl": "^3.2.0",
|
||||
@@ -62,7 +62,8 @@
|
||||
"parse-duration": "^1.0.0",
|
||||
"proxy-polyfill": "0.1.6",
|
||||
"re-reselect": "^4.0.0",
|
||||
"react-datetime-picker": "^3.2.1",
|
||||
"react-beautiful-dnd": "^13.1.0",
|
||||
"react-datetime-picker": "^3.4.3",
|
||||
"remove-markdown": "^0.3.0",
|
||||
"rss": "^1.2.2",
|
||||
"source-map-explorer": "^2.5.2",
|
||||
@@ -211,13 +212,11 @@
|
||||
"strip-markdown": "^3.0.3",
|
||||
"style-loader": "^0.23.1",
|
||||
"terser-webpack-plugin": "^4.2.3",
|
||||
"three": "^0.125.0",
|
||||
"three-full": "^17.1.0",
|
||||
"three-full": "^28.0.1",
|
||||
"tiny-relative-date": "^1.3.0",
|
||||
"tree-kill": "^1.1.0",
|
||||
"unist-util-visit": "^2.0.3",
|
||||
"uuid": "^8.3.2",
|
||||
"vast-client": "^3.1.1",
|
||||
"video.js": "^7.14.3",
|
||||
"videojs-contrib-quality-levels": "^2.0.9",
|
||||
"videojs-event-tracking": "^1.0.1",
|
||||
|
||||
@@ -2247,5 +2247,43 @@
|
||||
"This support is priced in $USD.": "This support is priced in $USD.",
|
||||
"The current exchange rate for the submitted LBC amount is ~ $%exchange_amount%.": "The current exchange rate for the submitted LBC amount is ~ $%exchange_amount%.",
|
||||
"Amount of $%input_amount% LBC in USB is lower than price of $%price_amount%": "Amount of $%input_amount% LBC in USB is lower than price of $%price_amount%",
|
||||
"Hosting for content you have downloaded": "Hosting for content you have downloaded",
|
||||
"Hosting content selected by the network": "Hosting content selected by the network",
|
||||
"Remove all unavailable claims": "Remove all unavailable claims",
|
||||
"Drag": "Drag",
|
||||
"Move Top": "Move Top",
|
||||
"Move Bottom": "Move Bottom",
|
||||
"Move Up": "Move Up",
|
||||
"Move Down": "Move Down",
|
||||
"Trending for #Game": "Trending for #Game",
|
||||
"Help the P2P data network by hosting data.": "Help the P2P data network by hosting data.",
|
||||
"History hosting lets you choose how much storage to use helping content you've consumed.": "History hosting lets you choose how much storage to use helping content you've consumed.",
|
||||
"Automatic hosting lets you delegate some amount of storage for the network to automatically download ad host.": "Automatic hosting lets you delegate some amount of storage for the network to automatically download ad host.",
|
||||
"Playing videos may exceed your history hosting limit until cleanup runs every 30 minutes.": "Playing videos may exceed your history hosting limit until cleanup runs every 30 minutes.",
|
||||
"History: Limit (GB)": "History: Limit (GB)",
|
||||
"Automatic: Allow (GB)": "Automatic: Allow (GB)",
|
||||
"Automatic hosting lets you delegate some amount of storage for the network to automatically download and host.": "Automatic hosting lets you delegate some amount of storage for the network to automatically download and host.",
|
||||
"History Hosting": "History Hosting",
|
||||
"Automatic Hosting": "Automatic Hosting",
|
||||
"History Hosting lets you choose how much storage to use helping content you've consumed.": "History Hosting lets you choose how much storage to use helping content you've consumed.",
|
||||
"Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.": "Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.",
|
||||
"Help improve the P2P data network (and make LBRY happy) by hosting data.": "Help improve the P2P data network (and make LBRY happy) by hosting data.",
|
||||
"Limit Hosting of Content History": "Limit Hosting of Content History",
|
||||
"Remove custom comment server": "Remove custom comment server",
|
||||
"Use Https": "Use Https",
|
||||
"Server URL": "Server URL",
|
||||
"Use https": "Use https",
|
||||
"Custom Servers": "Custom Servers",
|
||||
"Add A Server": "Add A Server",
|
||||
"Autoplay Next is off.": "Autoplay Next is off.",
|
||||
"Shuffle is on.": "Shuffle is on.",
|
||||
"Shuffle is off.": "Shuffle is off.",
|
||||
"Loop is on.": "Loop is on.",
|
||||
"Loop is off.": "Loop is off.",
|
||||
"View History Hosting lets you choose how much storage to use helping content you've consumed.": "View History Hosting lets you choose how much storage to use helping content you've consumed.",
|
||||
"Clean Now": "Clean Now",
|
||||
"Enable Automatic Hosting": "Enable Automatic Hosting",
|
||||
"Download and serve arbitrary data on the network.": "Download and serve arbitrary data on the network.",
|
||||
"View History Hosting": "View History Hosting",
|
||||
"--end--": "--end--"
|
||||
}
|
||||
+3
-9
@@ -49,9 +49,6 @@ type Analytics = {
|
||||
readyState: number,
|
||||
}
|
||||
) => Promise<any>,
|
||||
adsFetchedEvent: () => void,
|
||||
adsReceivedEvent: (any) => void,
|
||||
adsErrorEvent: (any) => void,
|
||||
emailProvidedEvent: () => void,
|
||||
emailVerifiedEvent: () => void,
|
||||
rewardEligibleEvent: () => void,
|
||||
@@ -168,10 +165,7 @@ async function sendWatchmanData(body) {
|
||||
});
|
||||
|
||||
return response;
|
||||
} catch (err) {
|
||||
console.log('ERROR FROM WATCHMAN BACKEND');
|
||||
console.log(err);
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
const analytics: Analytics = {
|
||||
@@ -213,7 +207,7 @@ const analytics: Analytics = {
|
||||
startWatchmanIntervalIfNotRunning();
|
||||
}
|
||||
},
|
||||
videoStartEvent: (claimId, duration, poweredBy, passedUserId, canonicalUrl, passedPlayer, videoBitrate) => {
|
||||
videoStartEvent: (claimId, timeToStartVideo, poweredBy, passedUserId, canonicalUrl, passedPlayer, videoBitrate) => {
|
||||
// populate values for watchman when video starts
|
||||
userId = passedUserId;
|
||||
claimUrl = canonicalUrl;
|
||||
@@ -224,7 +218,7 @@ const analytics: Analytics = {
|
||||
bitrateAsBitsPerSecond = videoBitrate;
|
||||
|
||||
// sendPromMetric('time_to_start', duration);
|
||||
sendMatomoEvent('Media', 'TimeToStart', claimId, duration);
|
||||
sendMatomoEvent('Media', 'TimeToStart', claimId, timeToStartVideo);
|
||||
},
|
||||
error: (message) => {
|
||||
return new Promise((resolve) => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { doFetchAccessToken, doUserSetReferrer } from 'redux/actions/user';
|
||||
import { selectUser, selectAccessToken, selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
|
||||
import { doFetchChannelListMine, doFetchCollectionListMine, doResolveUris } from 'redux/actions/claims';
|
||||
import { selectMyChannelUrls } from 'redux/selectors/claims';
|
||||
import { selectMyChannelUrls, selectMyChannelClaimIds } from 'redux/selectors/claims';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
||||
import {
|
||||
@@ -48,6 +48,7 @@ const select = (state) => ({
|
||||
syncFatalError: selectSyncFatalError(state),
|
||||
activeChannelClaim: selectActiveChannelClaim(state),
|
||||
myChannelUrls: selectMyChannelUrls(state),
|
||||
myChannelClaimIds: selectMyChannelClaimIds(state),
|
||||
subscriptions: selectSubscriptions(state),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// @flow
|
||||
import { SIMPLE_SITE } from 'config';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
@@ -39,33 +38,31 @@ function ChannelStakedIndicator(props: Props) {
|
||||
const icon = getChannelIcon(level);
|
||||
|
||||
return (
|
||||
SIMPLE_SITE && (
|
||||
<Tooltip
|
||||
label={
|
||||
<div className="channel-staked__tooltip">
|
||||
<div className="channel-staked__tooltip-icons">
|
||||
<LevelIcon icon={icon} isControlling={isControlling} size={isControlling ? 14 : 10} />
|
||||
</div>
|
||||
<Tooltip
|
||||
title={
|
||||
<div className="channel-staked__tooltip">
|
||||
<div className="channel-staked__tooltip-icons">
|
||||
<LevelIcon icon={icon} isControlling={isControlling} size={isControlling ? 14 : 10} />
|
||||
</div>
|
||||
|
||||
<div className="channel-staked__tooltip-text">
|
||||
<span>{__('Level %current_level%', { current_level: level })}</span>
|
||||
<div className="channel-staked__amount">
|
||||
<LbcSymbol postfix={<CreditAmount amount={amount} showLBC={false} />} size={14} />
|
||||
</div>
|
||||
<div className="channel-staked__tooltip-text">
|
||||
<span>{__('Level %current_level%', { current_level: level })}</span>
|
||||
<div className="channel-staked__amount">
|
||||
<LbcSymbol postfix={<CreditAmount amount={amount} showLBC={false} />} size={14} />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div
|
||||
className={classnames('channel-staked__wrapper', {
|
||||
'channel-staked__wrapper--large': large,
|
||||
'channel-staked__wrapper--inline': inline,
|
||||
})}
|
||||
>
|
||||
<LevelIcon icon={icon} large={large} isControlling={isControlling} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
>
|
||||
<div
|
||||
className={classnames('channel-staked__wrapper', {
|
||||
'channel-staked__wrapper--large': large,
|
||||
'channel-staked__wrapper--inline': inline,
|
||||
})}
|
||||
>
|
||||
<LevelIcon icon={icon} large={large} isControlling={isControlling} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,15 +79,7 @@ const ClaimCollectionAdd = (props: Props) => {
|
||||
.filter((list) => (isChannel ? list.type === 'collection' : list.type === 'playlist'))
|
||||
.map((l) => {
|
||||
const { id } = l;
|
||||
return (
|
||||
<CollectionSelectItem
|
||||
claim={claim}
|
||||
collectionId={id}
|
||||
uri={permanentUrl}
|
||||
key={id}
|
||||
category={'builtin'}
|
||||
/>
|
||||
);
|
||||
return <CollectionSelectItem collectionId={id} uri={permanentUrl} key={id} category={'builtin'} />;
|
||||
})}
|
||||
{unpublished &&
|
||||
(Object.values(unpublished): any)
|
||||
@@ -96,13 +88,7 @@ const ClaimCollectionAdd = (props: Props) => {
|
||||
.map((l) => {
|
||||
const { id } = l;
|
||||
return (
|
||||
<CollectionSelectItem
|
||||
claim={claim}
|
||||
collectionId={id}
|
||||
uri={permanentUrl}
|
||||
key={id}
|
||||
category={'unpublished'}
|
||||
/>
|
||||
<CollectionSelectItem collectionId={id} uri={permanentUrl} key={id} category={'unpublished'} />
|
||||
);
|
||||
})}
|
||||
{published &&
|
||||
@@ -110,13 +96,7 @@ const ClaimCollectionAdd = (props: Props) => {
|
||||
// $FlowFixMe
|
||||
const { id } = l;
|
||||
return (
|
||||
<CollectionSelectItem
|
||||
claim={claim}
|
||||
collectionId={id}
|
||||
uri={permanentUrl}
|
||||
key={id}
|
||||
category={'published'}
|
||||
/>
|
||||
<CollectionSelectItem collectionId={id} uri={permanentUrl} key={id} category={'published'} />
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
+110
-43
@@ -1,4 +1,7 @@
|
||||
// @flow
|
||||
|
||||
// $FlowFixMe
|
||||
import { Draggable } from 'react-beautiful-dnd';
|
||||
import { MAIN_CLASS } from 'constants/classnames';
|
||||
import type { Node } from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
@@ -44,7 +47,13 @@ type Props = {
|
||||
collectionId?: string,
|
||||
showNoSourceClaims?: boolean,
|
||||
onClick?: (e: any, claim?: ?Claim, index?: number) => void,
|
||||
noEmpty: boolean,
|
||||
maxClaimRender?: number,
|
||||
excludeUris?: Array<string>,
|
||||
loadedCallback?: (number) => void,
|
||||
swipeLayout: boolean,
|
||||
showEdit?: boolean,
|
||||
droppableProvided?: any,
|
||||
unavailableUris?: Array<string>,
|
||||
};
|
||||
|
||||
export default function ClaimList(props: Props) {
|
||||
@@ -75,7 +84,13 @@ export default function ClaimList(props: Props) {
|
||||
collectionId,
|
||||
showNoSourceClaims,
|
||||
onClick,
|
||||
noEmpty,
|
||||
maxClaimRender,
|
||||
excludeUris = [],
|
||||
loadedCallback,
|
||||
swipeLayout = false,
|
||||
showEdit,
|
||||
droppableProvided,
|
||||
unavailableUris,
|
||||
} = props;
|
||||
|
||||
const [currentSort, setCurrentSort] = usePersistedState(persistedStorageKey, SORT_NEW);
|
||||
@@ -85,8 +100,18 @@ export default function ClaimList(props: Props) {
|
||||
const timedOut = uris === null;
|
||||
const urisLength = (uris && uris.length) || 0;
|
||||
|
||||
const tileUris = (prefixUris || []).concat(uris);
|
||||
const sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || [];
|
||||
let tileUris = (prefixUris || []).concat(uris || []);
|
||||
tileUris = tileUris.filter((uri) => !excludeUris.includes(uri));
|
||||
|
||||
const totalLength = tileUris.length;
|
||||
|
||||
if (maxClaimRender) tileUris = tileUris.slice(0, maxClaimRender);
|
||||
|
||||
let sortedUris = (urisLength > 0 && (currentSort === SORT_NEW ? tileUris : tileUris.slice().reverse())) || [];
|
||||
|
||||
React.useEffect(() => {
|
||||
if (typeof loadedCallback === 'function') loadedCallback(totalLength);
|
||||
}, [totalLength]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const noResultMsg = searchInLanguage
|
||||
? __('No results. Contents may be hidden by the Language filter.')
|
||||
@@ -96,11 +121,21 @@ export default function ClaimList(props: Props) {
|
||||
setCurrentSort(currentSort === SORT_NEW ? SORT_OLD : SORT_NEW);
|
||||
}
|
||||
|
||||
function handleClaimClicked(e, claim, index) {
|
||||
if (onClick) {
|
||||
onClick(e, claim, index);
|
||||
}
|
||||
}
|
||||
const handleClaimClicked = React.useCallback(
|
||||
(e, claim, index) => {
|
||||
if (onClick) {
|
||||
onClick(e, claim, index);
|
||||
}
|
||||
},
|
||||
[onClick]
|
||||
);
|
||||
|
||||
const customShouldHide = React.useCallback((claim: StreamClaim) => {
|
||||
// Hack to hide spee.ch thumbnail publishes
|
||||
// If it meets these requirements, it was probably uploaded here:
|
||||
// https://github.com/lbryio/lbry-redux/blob/master/src/redux/actions/publish.js#L74-L79
|
||||
return claim.name.length === 24 && !claim.name.includes(' ') && claim.value.author === 'Spee.ch';
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = debounce((e) => {
|
||||
@@ -123,8 +158,32 @@ export default function ClaimList(props: Props) {
|
||||
}
|
||||
}, [loading, onScrollBottom, urisLength, pageSize, page]);
|
||||
|
||||
const getClaimPreview = (uri: string, index: number, draggableProvided?: any) => (
|
||||
<ClaimPreview
|
||||
uri={uri}
|
||||
indexInContainer={index}
|
||||
type={type}
|
||||
active={activeUri && uri === activeUri}
|
||||
hideMenu={hideMenu}
|
||||
includeSupportAction={includeSupportAction}
|
||||
showUnresolvedClaim={showUnresolvedClaims}
|
||||
properties={renderProperties || (type !== 'small' ? undefined : false)}
|
||||
renderActions={renderActions}
|
||||
showUserBlocked={showHiddenByUser}
|
||||
showHiddenByUser={showHiddenByUser}
|
||||
collectionId={collectionId}
|
||||
showNoSourceClaims={showNoSourceClaims}
|
||||
customShouldHide={customShouldHide}
|
||||
onClick={handleClaimClicked}
|
||||
swipeLayout={swipeLayout}
|
||||
showEdit={showEdit}
|
||||
dragHandleProps={draggableProvided && draggableProvided.dragHandleProps}
|
||||
unavailableUris={unavailableUris}
|
||||
/>
|
||||
);
|
||||
|
||||
return tileLayout && !header ? (
|
||||
<section className="claim-grid">
|
||||
<section className={classnames('claim-grid', { 'swipe-list': swipeLayout })}>
|
||||
{urisLength > 0 &&
|
||||
tileUris.map((uri) => (
|
||||
<ClaimPreviewTile
|
||||
@@ -134,11 +193,10 @@ export default function ClaimList(props: Props) {
|
||||
properties={renderProperties}
|
||||
collectionId={collectionId}
|
||||
showNoSourceClaims={showNoSourceClaims}
|
||||
swipeLayout={swipeLayout}
|
||||
/>
|
||||
))}
|
||||
{!timedOut && urisLength === 0 && !loading && !noEmpty && (
|
||||
<div className="empty main--empty">{empty || noResultMsg}</div>
|
||||
)}
|
||||
{!timedOut && urisLength === 0 && !loading && <div className="empty main--empty">{empty || noResultMsg}</div>}
|
||||
{timedOut && timedOutMessage && <div className="empty main--empty">{timedOutMessage}</div>}
|
||||
</section>
|
||||
) : (
|
||||
@@ -178,43 +236,52 @@ export default function ClaimList(props: Props) {
|
||||
{urisLength > 0 && (
|
||||
<ul
|
||||
className={classnames('ul--no-style', {
|
||||
card: !(tileLayout || type === 'small'),
|
||||
card: !(tileLayout || swipeLayout || type === 'small'),
|
||||
'claim-list--card-body': tileLayout,
|
||||
'swipe-list': swipeLayout,
|
||||
})}
|
||||
{...(droppableProvided && droppableProvided.droppableProps)}
|
||||
ref={droppableProvided && droppableProvided.innerRef}
|
||||
>
|
||||
{sortedUris.map((uri, index) => (
|
||||
<React.Fragment key={uri}>
|
||||
{injectedItem && index === 4 && <li>{injectedItem}</li>}
|
||||
<ClaimPreview
|
||||
uri={uri}
|
||||
indexInContainer={index}
|
||||
type={type}
|
||||
active={activeUri && uri === activeUri}
|
||||
hideMenu={hideMenu}
|
||||
includeSupportAction={includeSupportAction}
|
||||
showUnresolvedClaim={showUnresolvedClaims}
|
||||
properties={renderProperties || (type !== 'small' ? undefined : false)}
|
||||
renderActions={renderActions}
|
||||
showUserBlocked={showHiddenByUser}
|
||||
showHiddenByUser={showHiddenByUser}
|
||||
collectionId={collectionId}
|
||||
showNoSourceClaims={showNoSourceClaims}
|
||||
customShouldHide={(claim: StreamClaim) => {
|
||||
// Hack to hide spee.ch thumbnail publishes
|
||||
// If it meets these requirements, it was probably uploaded here:
|
||||
// https://github.com/lbryio/lbry-redux/blob/master/src/redux/actions/publish.js#L74-L79
|
||||
return claim.name.length === 24 && !claim.name.includes(' ') && claim.value.author === 'Spee.ch';
|
||||
{injectedItem && sortedUris.some((uri, index) => index === 4) && <li>{injectedItem}</li>}
|
||||
|
||||
{sortedUris.map((uri, index) =>
|
||||
droppableProvided ? (
|
||||
<Draggable key={uri} draggableId={uri} index={index}>
|
||||
{(draggableProvided, draggableSnapshot) => {
|
||||
// Restrict dragging to vertical axis
|
||||
// https://github.com/atlassian/react-beautiful-dnd/issues/958#issuecomment-980548919
|
||||
let transform = draggableProvided.draggableProps.style.transform;
|
||||
|
||||
if (draggableSnapshot.isDragging && transform) {
|
||||
transform = transform.replace(/\(.+,/, '(0,');
|
||||
}
|
||||
|
||||
const style = {
|
||||
...draggableProvided.draggableProps.style,
|
||||
transform,
|
||||
};
|
||||
|
||||
return (
|
||||
<li ref={draggableProvided.innerRef} {...draggableProvided.draggableProps} style={style}>
|
||||
{/* https://github.com/atlassian/react-beautiful-dnd/issues/1756 */}
|
||||
<div style={{ display: 'none' }} {...draggableProvided.dragHandleProps} />
|
||||
|
||||
{getClaimPreview(uri, index, draggableProvided)}
|
||||
</li>
|
||||
);
|
||||
}}
|
||||
onClick={(e, claim, index) => handleClaimClicked(e, claim, index)}
|
||||
/>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</Draggable>
|
||||
) : (
|
||||
getClaimPreview(uri, index)
|
||||
)
|
||||
)}
|
||||
|
||||
{droppableProvided && droppableProvided.placeholder}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{!timedOut && urisLength === 0 && !loading && !noEmpty && (
|
||||
<div className="empty empty--centered">{empty || noResultMsg}</div>
|
||||
)}
|
||||
{!timedOut && urisLength === 0 && !loading && <div className="empty empty--centered">{empty || noResultMsg}</div>}
|
||||
{!loading && timedOut && timedOutMessage && <div className="empty empty--centered">{timedOutMessage}</div>}
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -94,6 +94,13 @@ type Props = {
|
||||
doClaimSearch: ({}) => void,
|
||||
doToggleTagFollowDesktop: (string) => void,
|
||||
doFetchViewCount: (claimIdCsv: string) => void,
|
||||
|
||||
loadedCallback?: (number) => void,
|
||||
maxClaimRender?: number,
|
||||
useSkeletonScreen?: boolean,
|
||||
excludeUris?: Array<string>,
|
||||
|
||||
swipeLayout: boolean,
|
||||
};
|
||||
|
||||
function ClaimListDiscover(props: Props) {
|
||||
@@ -157,6 +164,11 @@ function ClaimListDiscover(props: Props) {
|
||||
empty,
|
||||
claimsByUri,
|
||||
doFetchViewCount,
|
||||
loadedCallback,
|
||||
maxClaimRender,
|
||||
useSkeletonScreen = true,
|
||||
excludeUris = [],
|
||||
swipeLayout = false,
|
||||
} = props;
|
||||
const didNavigateForward = history.action === 'PUSH';
|
||||
const { search } = location;
|
||||
@@ -493,6 +505,21 @@ function ClaimListDiscover(props: Props) {
|
||||
}
|
||||
|
||||
function resolveOrderByOption(orderBy: string | Array<string>, sortBy: string | Array<string>) {
|
||||
// let order_by; // peterson 038692cafc793616cceaf10b88909fecde07ad0b
|
||||
//
|
||||
// switch (orderBy) {
|
||||
// case CS.ORDER_BY_TRENDING:
|
||||
// order_by = CS.ORDER_BY_TRENDING_VALUE;
|
||||
// break;
|
||||
// case CS.ORDER_BY_NEW:
|
||||
// order_by = CS.ORDER_BY_NEW_VALUE;
|
||||
// break;
|
||||
// case CS.ORDER_BY_NEW_ASC:
|
||||
// order_by = CS.ORDER_BY_NEW_ASC_VALUE;
|
||||
// break;
|
||||
// default:
|
||||
// order_by = CS.ORDER_BY_TOP_VALUE;
|
||||
// }
|
||||
const order_by =
|
||||
orderBy === CS.ORDER_BY_TRENDING
|
||||
? CS.ORDER_BY_TRENDING_VALUE
|
||||
@@ -569,8 +596,12 @@ function ClaimListDiscover(props: Props) {
|
||||
searchOptions={options}
|
||||
showNoSourceClaims={showNoSourceClaims}
|
||||
empty={empty}
|
||||
maxClaimRender={maxClaimRender}
|
||||
excludeUris={excludeUris}
|
||||
loadedCallback={loadedCallback}
|
||||
swipeLayout={swipeLayout}
|
||||
/>
|
||||
{loading && (
|
||||
{loading && useSkeletonScreen && (
|
||||
<div className="claim-grid">
|
||||
{new Array(dynamicPageSize).fill(1).map((x, i) => (
|
||||
<ClaimPreviewTile key={i} placeholder="loading" />
|
||||
@@ -602,8 +633,13 @@ function ClaimListDiscover(props: Props) {
|
||||
searchOptions={options}
|
||||
showNoSourceClaims={hasNoSource || showNoSourceClaims}
|
||||
empty={empty}
|
||||
maxClaimRender={maxClaimRender}
|
||||
excludeUris={excludeUris}
|
||||
loadedCallback={loadedCallback}
|
||||
swipeLayout={swipeLayout}
|
||||
/>
|
||||
{loading &&
|
||||
useSkeletonScreen &&
|
||||
new Array(dynamicPageSize)
|
||||
.fill(1)
|
||||
.map((x, i) => (
|
||||
|
||||
@@ -157,11 +157,9 @@ function ClaimMenuList(props: Props) {
|
||||
doToast({
|
||||
message: source ? __('Item removed from %name%', { name }) : __('Item added to %name%', { name }),
|
||||
});
|
||||
doCollectionEdit(collectionId, {
|
||||
claims: [contentClaim],
|
||||
remove: source,
|
||||
type: 'playlist',
|
||||
});
|
||||
if (contentClaim) {
|
||||
doCollectionEdit(collectionId, { uris: [contentClaim.permanent_url], remove: source, type: 'playlist' });
|
||||
}
|
||||
}
|
||||
|
||||
function handleFollow() {
|
||||
|
||||
@@ -10,17 +10,12 @@ import {
|
||||
selectDateForUri,
|
||||
} from 'redux/selectors/claims';
|
||||
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
||||
import {
|
||||
makeSelectCollectionIsMine,
|
||||
makeSelectUrlsForCollectionId,
|
||||
makeSelectIndexForUrlInCollection,
|
||||
} from 'redux/selectors/collections';
|
||||
import { makeSelectCollectionIsMine } from 'redux/selectors/collections';
|
||||
|
||||
import { doResolveUri } from 'redux/actions/claims';
|
||||
import { doCollectionEdit } from 'redux/actions/collections';
|
||||
import { doFileGet } from 'redux/actions/file';
|
||||
import { selectBanStateForUri } from 'lbryinc';
|
||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { selectLanguage, selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { makeSelectHasVisitedUri } from 'redux/selectors/content';
|
||||
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
|
||||
import { isClaimNsfw } from 'util/claim';
|
||||
@@ -50,15 +45,13 @@ const select = (state, props) => {
|
||||
streamingUrl: props.uri && makeSelectStreamingUrlForUri(props.uri)(state),
|
||||
wasPurchased: props.uri && makeSelectClaimWasPurchased(props.uri)(state),
|
||||
isCollectionMine: makeSelectCollectionIsMine(props.collectionId)(state),
|
||||
collectionUris: makeSelectUrlsForCollectionId(props.collectionId)(state),
|
||||
collectionIndex: makeSelectIndexForUrlInCollection(props.uri, props.collectionId)(state),
|
||||
lang: selectLanguage(state),
|
||||
};
|
||||
};
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
resolveUri: (uri) => dispatch(doResolveUri(uri)),
|
||||
getFile: (uri) => dispatch(doFileGet(uri, false)),
|
||||
editCollection: (id, params) => dispatch(doCollectionEdit(id, params)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(ClaimPreview);
|
||||
@@ -9,8 +9,11 @@ import * as COLLECTIONS_CONSTS from 'constants/collections';
|
||||
import { isChannelClaim } from 'util/claim';
|
||||
import { formatLbryUrlForWeb } from 'util/url';
|
||||
import { formatClaimPreviewTitle } from 'util/formatAriaLabel';
|
||||
import { toCompactNotation } from 'util/string';
|
||||
import Tooltip from 'component/common/tooltip';
|
||||
import FileThumbnail from 'component/fileThumbnail';
|
||||
import UriIndicator from 'component/uriIndicator';
|
||||
import PreviewOverlayProperties from 'component/previewOverlayProperties';
|
||||
import ClaimTags from 'component/claimTags';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
@@ -26,10 +29,8 @@ import ClaimMenuList from 'component/claimMenuList';
|
||||
import ClaimPreviewLoading from './claim-preview-loading';
|
||||
import ClaimPreviewHidden from './claim-preview-no-mature';
|
||||
import ClaimPreviewNoContent from './claim-preview-no-content';
|
||||
import CollectionEditButtons from './collection-buttons';
|
||||
|
||||
import CollectionEditButtons from 'component/collectionEditButtons';
|
||||
import AbandonedChannelPreview from 'component/abandonedChannelPreview';
|
||||
import PreviewOverlayProperties from 'component/previewOverlayProperties';
|
||||
|
||||
// preview images used on the landing page and on the channel page
|
||||
type Props = {
|
||||
@@ -50,7 +51,7 @@ type Props = {
|
||||
type: string,
|
||||
banState: { blacklisted?: boolean, filtered?: boolean, muted?: boolean, blocked?: boolean },
|
||||
hasVisitedUri: boolean,
|
||||
channelIsBlocked: boolean,
|
||||
blockedUris: Array<string>,
|
||||
actions: boolean | Node | string | number,
|
||||
properties: boolean | Node | string | number | ((Claim) => Node),
|
||||
empty?: Node,
|
||||
@@ -69,15 +70,17 @@ type Props = {
|
||||
repostUrl?: string,
|
||||
hideMenu?: boolean,
|
||||
collectionId?: string,
|
||||
editCollection: (string, CollectionEditParams) => void,
|
||||
isCollectionMine: boolean,
|
||||
collectionUris: Array<Collection>,
|
||||
collectionIndex?: number,
|
||||
disableNavigation?: boolean,
|
||||
mediaDuration?: string,
|
||||
date?: any,
|
||||
indexInContainer?: number, // The index order of this component within 'containerId'.
|
||||
channelSubCount?: number,
|
||||
swipeLayout: boolean,
|
||||
lang: string,
|
||||
showEdit?: boolean,
|
||||
dragHandleProps?: any,
|
||||
unavailableUris?: Array<string>,
|
||||
};
|
||||
|
||||
const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
@@ -98,7 +101,6 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
streamingUrl,
|
||||
mediaDuration,
|
||||
// user properties
|
||||
channelIsBlocked,
|
||||
hasVisitedUri,
|
||||
// component
|
||||
history,
|
||||
@@ -130,34 +132,40 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
hideMenu = false,
|
||||
// repostUrl,
|
||||
collectionId,
|
||||
collectionIndex,
|
||||
editCollection,
|
||||
isCollectionMine,
|
||||
collectionUris,
|
||||
disableNavigation,
|
||||
indexInContainer,
|
||||
channelSubCount,
|
||||
swipeLayout = false,
|
||||
lang,
|
||||
showEdit,
|
||||
dragHandleProps,
|
||||
unavailableUris,
|
||||
} = props;
|
||||
|
||||
const isCollection = claim && claim.value_type === 'collection';
|
||||
const collectionClaimId = isCollection && claim && claim.claim_id;
|
||||
const listId = collectionId || collectionClaimId || null;
|
||||
const listId = collectionId || collectionClaimId;
|
||||
const WrapperElement = wrapperElement || 'li';
|
||||
const shouldFetch =
|
||||
claim === undefined || (claim !== null && claim.value_type === 'channel' && isEmpty(claim.meta) && !pending);
|
||||
const abandoned = !isResolvingUri && !claim;
|
||||
const isMyCollection = listId && (isCollectionMine || listId.includes('-'));
|
||||
if (isMyCollection && claim === null && unavailableUris) unavailableUris.push(uri);
|
||||
|
||||
const shouldHideActions = hideActions || isMyCollection || type === 'small' || type === 'tooltip';
|
||||
const canonicalUrl = claim && claim.canonical_url;
|
||||
const lastCollectionIndex = collectionUris ? collectionUris.length - 1 : 0;
|
||||
const channelSubscribers = React.useMemo(() => {
|
||||
if (channelSubCount === undefined) {
|
||||
return <span />;
|
||||
}
|
||||
const formattedSubCount = Number(channelSubCount).toLocaleString();
|
||||
const formattedSubCount = toCompactNotation(channelSubCount, lang, 10000);
|
||||
return (
|
||||
<span className="claim-preview__channel-sub-count">
|
||||
{channelSubCount === 1 ? __('1 Follower') : __('%formattedSubCount% Followers', { formattedSubCount })}
|
||||
</span>
|
||||
<Tooltip title={channelSubCount} followCursor placement="top">
|
||||
<span className="claim-preview__channel-sub-count">
|
||||
{channelSubCount === 1 ? __('1 Follower') : __('%formattedSubCount% Followers', { formattedSubCount })}
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}, [channelSubCount]);
|
||||
const isValid = uri && isURIValid(uri);
|
||||
@@ -177,6 +185,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
claim && claim.repost_channel_url && claim.value_type === 'channel'
|
||||
? claim.permanent_url || claim.canonical_url
|
||||
: undefined;
|
||||
const repostedContentUri = claim && (claim.reposted_claim ? claim.reposted_claim.permanent_url : claim.permanent_url);
|
||||
|
||||
// Get channel title ( use name as fallback )
|
||||
let channelTitle = null;
|
||||
@@ -226,7 +235,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
((abandoned && !showUnresolvedClaim) || (!claimIsMine && obscureNsfw && nsfw));
|
||||
|
||||
// This will be replaced once blocking is done at the wallet server level
|
||||
if (claim && !claimIsMine && (banState.blacklisted || banState.filtered)) {
|
||||
if (!shouldHide && !claimIsMine && (banState.blacklisted || banState.filtered)) {
|
||||
shouldHide = true;
|
||||
}
|
||||
|
||||
@@ -308,6 +317,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
'claim-preview__wrapper--small': type === 'small',
|
||||
'claim-preview__active': active,
|
||||
})}
|
||||
key={uri}
|
||||
>
|
||||
<>
|
||||
{!hideRepostLabel && <ClaimRepostAuthor uri={uri} />}
|
||||
@@ -321,18 +331,14 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
'claim-preview--channel': isChannelUri,
|
||||
'claim-preview--visited': !isChannelUri && !claimIsMine && hasVisitedUri,
|
||||
'claim-preview--pending': pending,
|
||||
'claim-preview--collection-mine': isMyCollection && listId && type === 'listview',
|
||||
'claim-preview--collection-mine': isMyCollection && showEdit,
|
||||
'swipe-list__item': swipeLayout,
|
||||
})}
|
||||
>
|
||||
{isMyCollection && listId && type === 'listview' && (
|
||||
<CollectionEditButtons
|
||||
collectionIndex={collectionIndex}
|
||||
editCollection={editCollection}
|
||||
listId={listId}
|
||||
lastCollectionIndex={lastCollectionIndex}
|
||||
claim={claim}
|
||||
/>
|
||||
{isMyCollection && showEdit && (
|
||||
<CollectionEditButtons uri={uri} collectionId={listId} dragHandleProps={dragHandleProps} />
|
||||
)}
|
||||
|
||||
{isChannelUri && claim ? (
|
||||
<UriIndicator focusable={false} uri={uri} link>
|
||||
<ChannelThumbnail uri={uri} small={type === 'inline'} />
|
||||
@@ -343,7 +349,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
<NavLink aria-hidden tabIndex={-1} {...navLinkProps}>
|
||||
<FileThumbnail thumbnail={thumbnailUrl}>
|
||||
<div className="claim-preview__hover-actions">
|
||||
{isPlayable && <FileWatchLaterLink focusable={false} uri={uri} />}
|
||||
{isPlayable && <FileWatchLaterLink focusable={false} uri={repostedContentUri} />}
|
||||
</div>
|
||||
{/* @if TARGET='app' */}
|
||||
<div className="claim-preview__hover-actions">
|
||||
@@ -353,7 +359,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
</div>
|
||||
{/* @endif */}
|
||||
<div className="claim-preview__file-property-overlay">
|
||||
<PreviewOverlayProperties uri={uri} properties={properties} />
|
||||
<PreviewOverlayProperties uri={uri} />
|
||||
</div>
|
||||
</FileThumbnail>
|
||||
</NavLink>
|
||||
@@ -392,8 +398,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
<ChannelThumbnail uri={signingChannel.permanent_url} xsmall />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isChannelUri && !channelIsBlocked && !claimIsMine && (
|
||||
{isChannelUri && !banState.muted && !claimIsMine && (
|
||||
<SubscribeButton
|
||||
uri={repostedChannelUri || (uri.startsWith('lbry://') ? uri : `lbry://${uri}`)}
|
||||
/>
|
||||
|
||||
@@ -42,6 +42,7 @@ type Props = {
|
||||
properties?: (Claim) => void,
|
||||
collectionId?: string,
|
||||
viewCount: string,
|
||||
swipeLayout: boolean,
|
||||
};
|
||||
|
||||
// preview image cards used in related video functionality, channel overview page and homepage
|
||||
@@ -66,6 +67,7 @@ function ClaimPreviewTile(props: Props) {
|
||||
collectionId,
|
||||
mediaDuration,
|
||||
viewCount,
|
||||
swipeLayout = false,
|
||||
} = props;
|
||||
const isRepost = claim && claim.repost_channel_url;
|
||||
const isCollection = claim && claim.value_type === 'collection';
|
||||
@@ -84,6 +86,7 @@ function ClaimPreviewTile(props: Props) {
|
||||
const thumbnailUrl = useGetThumbnail(uri, claim, streamingUrl, getFile, placeholder) || thumbnail;
|
||||
const canonicalUrl = claim && claim.canonical_url;
|
||||
const permanentUrl = claim && claim.permanent_url;
|
||||
const repostedContentUri = claim && (claim.reposted_claim ? claim.reposted_claim.permanent_url : claim.permanent_url);
|
||||
const listId = collectionId || collectionClaimId;
|
||||
const navigateUrl =
|
||||
formatLbryUrlForWeb(canonicalUrl || uri || '/') + (listId ? generateListSearchUrlParams(listId) : '');
|
||||
@@ -168,6 +171,7 @@ function ClaimPreviewTile(props: Props) {
|
||||
onClick={handleClick}
|
||||
className={classnames('card claim-preview--tile', {
|
||||
'claim-preview__wrapper--channel': isChannel,
|
||||
'swipe-list__item claim-preview--horizontal-tile': swipeLayout,
|
||||
})}
|
||||
>
|
||||
<NavLink {...navLinkProps} role="none" tabIndex={-1} aria-hidden>
|
||||
@@ -175,7 +179,7 @@ function ClaimPreviewTile(props: Props) {
|
||||
{!isChannel && (
|
||||
<React.Fragment>
|
||||
<div className="claim-preview__hover-actions">
|
||||
{isPlayable && <FileWatchLaterLink focusable={false} uri={uri} />}
|
||||
{isPlayable && <FileWatchLaterLink focusable={false} uri={repostedContentUri} />}
|
||||
</div>
|
||||
{/* @if TARGET='app' */}
|
||||
<div className="claim-preview__hover-actions">
|
||||
|
||||
@@ -9,7 +9,6 @@ import { doToggleTagFollowDesktop } from 'redux/actions/tags';
|
||||
import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { selectMutedAndBlockedChannelIds } from 'redux/selectors/blocked';
|
||||
import { ENABLE_NO_SOURCE_CLAIMS } from 'config';
|
||||
import * as CS from 'constants/claim_search';
|
||||
|
||||
import ClaimListDiscover from './view';
|
||||
|
||||
@@ -68,8 +67,6 @@ function resolveSearchOptions(props) {
|
||||
let streamTypesParam;
|
||||
if (streamTypes) {
|
||||
streamTypesParam = streamTypes;
|
||||
} else if (!hasNoSource && streamTypes !== null) {
|
||||
streamTypesParam = [CS.FILE_VIDEO, CS.FILE_AUDIO];
|
||||
}
|
||||
|
||||
const options = {
|
||||
|
||||
@@ -55,20 +55,6 @@ function CollectionActions(props: Props) {
|
||||
const claimId = claim && claim.claim_id;
|
||||
const webShareable = true; // collections have cost?
|
||||
|
||||
/*
|
||||
A bit too much dependency with both ordering and shuffling depending on a single list item index selector
|
||||
For now when they click edit, we'll toggle shuffle off for them.
|
||||
*/
|
||||
const handleSetShowEdit = (setting) => {
|
||||
doToggleShuffleList(collectionId, false);
|
||||
setShowEdit(setting);
|
||||
};
|
||||
|
||||
const handlePublishMode = () => {
|
||||
doToggleShuffleList(collectionId, false);
|
||||
push(`?${PAGE_VIEW_QUERY}=${EDIT_PAGE}`);
|
||||
};
|
||||
|
||||
const doPlay = React.useCallback(
|
||||
(playUri) => {
|
||||
const navigateUrl = formatLbryUrlForWeb(playUri);
|
||||
@@ -138,7 +124,7 @@ function CollectionActions(props: Props) {
|
||||
title={uri ? __('Update') : __('Publish')}
|
||||
label={uri ? __('Update') : __('Publish')}
|
||||
className={classnames('button--file-action')}
|
||||
onClick={() => handlePublishMode()}
|
||||
onClick={() => push(`?${PAGE_VIEW_QUERY}=${EDIT_PAGE}`)}
|
||||
icon={ICONS.PUBLISH}
|
||||
iconColor={collectionHasEdits && 'red'}
|
||||
iconSize={18}
|
||||
@@ -165,26 +151,28 @@ function CollectionActions(props: Props) {
|
||||
</>
|
||||
);
|
||||
|
||||
const infoButton = (
|
||||
<Button
|
||||
title={__('Info')}
|
||||
className={classnames('button-toggle', {
|
||||
'button-toggle--active': showInfo,
|
||||
})}
|
||||
icon={ICONS.MORE}
|
||||
onClick={() => setShowInfo(!showInfo)}
|
||||
/>
|
||||
);
|
||||
const infoButtons = (
|
||||
<div className="section">
|
||||
{uri && (
|
||||
<Button
|
||||
title={__('Info')}
|
||||
className={classnames('button-toggle', {
|
||||
'button-toggle--active': showInfo,
|
||||
})}
|
||||
icon={ICONS.MORE}
|
||||
onClick={() => setShowInfo(!showInfo)}
|
||||
/>
|
||||
)}
|
||||
|
||||
const showEditButton = (
|
||||
<Button
|
||||
title={__('Edit')}
|
||||
className={classnames('button-toggle', {
|
||||
'button-toggle--active': showEdit,
|
||||
})}
|
||||
icon={ICONS.EDIT}
|
||||
onClick={() => handleSetShowEdit(!showEdit)}
|
||||
/>
|
||||
{isMyCollection && (
|
||||
<Button
|
||||
title={__('Edit')}
|
||||
className={classnames('button-toggle', { 'button-toggle--active': showEdit })}
|
||||
icon={ICONS.EDIT}
|
||||
onClick={() => setShowEdit(!showEdit)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
if (isMobile) {
|
||||
@@ -192,7 +180,7 @@ function CollectionActions(props: Props) {
|
||||
<div className="media__actions">
|
||||
{lhsSection}
|
||||
{rhsSection}
|
||||
{uri && <span>{infoButton}</span>}
|
||||
{infoButtons}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
@@ -202,10 +190,8 @@ function CollectionActions(props: Props) {
|
||||
{lhsSection}
|
||||
{rhsSection}
|
||||
</div>
|
||||
<div className="section">
|
||||
{uri && infoButton}
|
||||
{showEditButton}
|
||||
</div>
|
||||
|
||||
{infoButtons}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { connect } from 'react-redux';
|
||||
import CollectionContent from './view';
|
||||
import { selectClaimForUri, selectClaimIsMine } from 'redux/selectors/claims';
|
||||
import { selectClaimForUri } from 'redux/selectors/claims';
|
||||
import {
|
||||
makeSelectUrlsForCollectionId,
|
||||
makeSelectNameForCollectionId,
|
||||
makeSelectCollectionForId,
|
||||
makeSelectCollectionIsMine,
|
||||
} from 'redux/selectors/collections';
|
||||
import { selectPlayingUri, selectListLoop, selectListShuffle } from 'redux/selectors/content';
|
||||
import { doToggleLoopList, doToggleShuffleList } from 'redux/actions/content';
|
||||
import { doCollectionEdit } from 'redux/actions/collections';
|
||||
|
||||
const select = (state, props) => {
|
||||
const playingUri = selectPlayingUri(state);
|
||||
@@ -24,7 +26,7 @@ const select = (state, props) => {
|
||||
collection: makeSelectCollectionForId(props.id)(state),
|
||||
collectionUrls: makeSelectUrlsForCollectionId(props.id)(state),
|
||||
collectionName: makeSelectNameForCollectionId(props.id)(state),
|
||||
isMine: selectClaimIsMine(state, claim),
|
||||
isMyCollection: makeSelectCollectionIsMine(props.id)(state),
|
||||
loop,
|
||||
shuffle,
|
||||
};
|
||||
@@ -33,4 +35,5 @@ const select = (state, props) => {
|
||||
export default connect(select, {
|
||||
doToggleLoopList,
|
||||
doToggleShuffleList,
|
||||
doCollectionEdit,
|
||||
})(CollectionContent);
|
||||
@@ -1,5 +1,10 @@
|
||||
// @flow
|
||||
|
||||
// $FlowFixMe
|
||||
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
|
||||
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import ClaimList from 'component/claimList';
|
||||
import Card from 'component/common/card';
|
||||
import Button from 'component/button';
|
||||
@@ -11,7 +16,7 @@ import * as ICONS from 'constants/icons';
|
||||
type Props = {
|
||||
id: string,
|
||||
url: string,
|
||||
isMine: boolean,
|
||||
isMyCollection: boolean,
|
||||
collectionUrls: Array<Claim>,
|
||||
collectionName: string,
|
||||
collection: any,
|
||||
@@ -20,10 +25,35 @@ type Props = {
|
||||
doToggleLoopList: (string, boolean) => void,
|
||||
doToggleShuffleList: (string, string, boolean) => void,
|
||||
createUnpublishedCollection: (string, Array<any>, ?string) => void,
|
||||
doCollectionEdit: (string, CollectionEditParams) => void,
|
||||
};
|
||||
|
||||
export default function CollectionContent(props: Props) {
|
||||
const { collectionUrls, collectionName, id, url, loop, shuffle, doToggleLoopList, doToggleShuffleList } = props;
|
||||
const {
|
||||
isMyCollection,
|
||||
collectionUrls,
|
||||
collectionName,
|
||||
id,
|
||||
url,
|
||||
loop,
|
||||
shuffle,
|
||||
doToggleLoopList,
|
||||
doToggleShuffleList,
|
||||
doCollectionEdit,
|
||||
} = props;
|
||||
|
||||
const [showEdit, setShowEdit] = React.useState(false);
|
||||
|
||||
function handleOnDragEnd(result) {
|
||||
const { source, destination } = result;
|
||||
|
||||
if (!destination) return;
|
||||
|
||||
const { index: from } = source;
|
||||
const { index: to } = destination;
|
||||
|
||||
doCollectionEdit(id, { order: { from, to } });
|
||||
}
|
||||
|
||||
return (
|
||||
<Card
|
||||
@@ -63,20 +93,39 @@ 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}`} />
|
||||
</div>
|
||||
<>
|
||||
<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}`} />
|
||||
</div>
|
||||
|
||||
{isMyCollection && (
|
||||
<Button
|
||||
title={__('Edit')}
|
||||
className={classnames('button-toggle', { 'button-toggle--active': showEdit })}
|
||||
icon={ICONS.EDIT}
|
||||
onClick={() => setShowEdit(!showEdit)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
body={
|
||||
<ClaimList
|
||||
isCardBody
|
||||
type="small"
|
||||
activeUri={url}
|
||||
uris={collectionUrls}
|
||||
collectionId={id}
|
||||
empty={__('List is Empty')}
|
||||
/>
|
||||
<DragDropContext onDragEnd={handleOnDragEnd}>
|
||||
<Droppable droppableId="list__ordering">
|
||||
{(DroppableProvided) => (
|
||||
<ClaimList
|
||||
isCardBody
|
||||
type="small"
|
||||
activeUri={url}
|
||||
uris={collectionUrls}
|
||||
collectionId={id}
|
||||
empty={__('List is Empty')}
|
||||
showEdit={showEdit}
|
||||
droppableProvided={DroppableProvided}
|
||||
/>
|
||||
)}
|
||||
</Droppable>
|
||||
</DragDropContext>
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -22,6 +22,7 @@ import * as ACTIONS from 'constants/action_types';
|
||||
import CollectionForm from './view';
|
||||
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
|
||||
import { doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
|
||||
import { doCollectionEdit } from 'redux/actions/collections';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
@@ -44,12 +45,13 @@ const select = (state, props) => ({
|
||||
collectionClaimIds: makeSelectClaimIdsForCollectionId(props.collectionId)(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
const perform = (dispatch, ownProps) => ({
|
||||
publishCollectionUpdate: (params) => dispatch(doCollectionPublishUpdate(params)),
|
||||
publishCollection: (params, collectionId) => dispatch(doCollectionPublish(params, collectionId)),
|
||||
clearCollectionErrors: () => dispatch({ type: ACTIONS.CLEAR_COLLECTION_ERRORS }),
|
||||
setActiveChannel: (claimId) => dispatch(doSetActiveChannel(claimId)),
|
||||
setIncognito: (incognito) => dispatch(doSetIncognito(incognito)),
|
||||
doCollectionEdit: (params) => dispatch(doCollectionEdit(ownProps.collectionId, params)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(CollectionForm);
|
||||
@@ -1,4 +1,7 @@
|
||||
// @flow
|
||||
|
||||
// $FlowFixMe
|
||||
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import Button from 'component/button';
|
||||
@@ -54,6 +57,7 @@ type Props = {
|
||||
onDone: (string) => void,
|
||||
setActiveChannel: (string) => void,
|
||||
setIncognito: (boolean) => void,
|
||||
doCollectionEdit: (CollectionEditParams) => void,
|
||||
};
|
||||
|
||||
function CollectionForm(props: Props) {
|
||||
@@ -87,6 +91,7 @@ function CollectionForm(props: Props) {
|
||||
setActiveChannel,
|
||||
setIncognito,
|
||||
onDone,
|
||||
doCollectionEdit,
|
||||
} = props;
|
||||
const activeChannelName = activeChannelClaim && activeChannelClaim.name;
|
||||
let prefix = 'lbry://';
|
||||
@@ -196,6 +201,17 @@ function CollectionForm(props: Props) {
|
||||
return collectionParams;
|
||||
}
|
||||
|
||||
function handleOnDragEnd(result) {
|
||||
const { source, destination } = result;
|
||||
|
||||
if (!destination) return;
|
||||
|
||||
const { index: from } = source;
|
||||
const { index: to } = destination;
|
||||
|
||||
doCollectionEdit({ order: { from, to } });
|
||||
}
|
||||
|
||||
function handleLanguageChange(index, code) {
|
||||
let langs = [...languageParam];
|
||||
if (index === 0) {
|
||||
@@ -257,12 +273,18 @@ function CollectionForm(props: Props) {
|
||||
|
||||
// on mount, if we get a collectionChannel, set it.
|
||||
React.useEffect(() => {
|
||||
if (hasClaim && !initialized) {
|
||||
if (collectionChannel) {
|
||||
setActiveChannel(collectionChannel);
|
||||
setIncognito(false);
|
||||
} else if (!collectionChannel && hasClaim) {
|
||||
setIncognito(true);
|
||||
if (!initialized) {
|
||||
if (hasClaim) {
|
||||
if (collectionChannel) {
|
||||
setActiveChannel(collectionChannel);
|
||||
setIncognito(false);
|
||||
} else if (!collectionChannel && hasClaim) {
|
||||
setIncognito(true);
|
||||
}
|
||||
} else {
|
||||
if (incognito) {
|
||||
setIncognito(true);
|
||||
}
|
||||
}
|
||||
setInitialized(true);
|
||||
}
|
||||
@@ -271,9 +293,10 @@ function CollectionForm(props: Props) {
|
||||
// every time activechannel or incognito changes, set it.
|
||||
React.useEffect(() => {
|
||||
if (initialized) {
|
||||
if (activeChannelId) {
|
||||
if (activeChannelId && !incognito) {
|
||||
setParam({ channel_id: activeChannelId });
|
||||
} else if (incognito) {
|
||||
}
|
||||
if (incognito) {
|
||||
setParam({ channel_id: undefined });
|
||||
}
|
||||
}
|
||||
@@ -286,7 +309,6 @@ function CollectionForm(props: Props) {
|
||||
}
|
||||
}, [uri, hasClaim]);
|
||||
|
||||
console.log('params', params);
|
||||
return (
|
||||
<>
|
||||
<div className={classnames('main--contained', { 'card--disabled': disabled })}>
|
||||
@@ -357,12 +379,19 @@ function CollectionForm(props: Props) {
|
||||
</div>
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<ClaimList
|
||||
uris={collectionUrls}
|
||||
collectionId={collectionId}
|
||||
empty={__('This list has no items.')}
|
||||
type={'listview'}
|
||||
/>
|
||||
<DragDropContext onDragEnd={handleOnDragEnd}>
|
||||
<Droppable droppableId="list__ordering">
|
||||
{(DroppableProvided) => (
|
||||
<ClaimList
|
||||
uris={collectionUrls}
|
||||
collectionId={collectionId}
|
||||
empty={__('This list has no items.')}
|
||||
showEdit
|
||||
droppableProvided={DroppableProvided}
|
||||
/>
|
||||
)}
|
||||
</Droppable>
|
||||
</DragDropContext>
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<Card
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doCollectionEdit } from 'redux/actions/collections';
|
||||
import { makeSelectIndexForUrlInCollection, makeSelectUrlsForCollectionId } from 'redux/selectors/collections';
|
||||
import CollectionButtons from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
const { uri, collectionId } = props;
|
||||
|
||||
return {
|
||||
collectionIndex: makeSelectIndexForUrlInCollection(uri, collectionId, true)(state),
|
||||
collectionUris: makeSelectUrlsForCollectionId(collectionId)(state),
|
||||
};
|
||||
};
|
||||
|
||||
const perform = (dispatch, ownProps) => {
|
||||
const { collectionId } = ownProps;
|
||||
|
||||
return {
|
||||
editCollection: (params) => dispatch(doCollectionEdit(collectionId, params)),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(select, perform)(CollectionButtons);
|
||||
@@ -0,0 +1,92 @@
|
||||
// @flow
|
||||
import * as ICONS from 'constants/icons';
|
||||
import Button from 'component/button';
|
||||
import Icon from 'component/common/icon';
|
||||
import React from 'react';
|
||||
|
||||
type Props = {
|
||||
collectionIndex?: number,
|
||||
collectionUris: Array<Collection>,
|
||||
dragHandleProps?: any,
|
||||
uri: string,
|
||||
editCollection: (CollectionEditParams) => void,
|
||||
};
|
||||
|
||||
export default function CollectionButtons(props: Props) {
|
||||
const { collectionIndex: foundIndex, collectionUris, dragHandleProps, uri, editCollection } = props;
|
||||
|
||||
const [confirmDelete, setConfirmDelete] = React.useState(false);
|
||||
|
||||
const lastCollectionIndex = collectionUris ? collectionUris.length - 1 : 0;
|
||||
const collectionIndex = Number(foundIndex);
|
||||
|
||||
const orderButton = (className: string, title: string, icon: string, disabled: boolean, handleClick?: () => void) => (
|
||||
<Button
|
||||
className={`button-collection-manage ${className}`}
|
||||
icon={icon}
|
||||
title={title}
|
||||
disabled={disabled}
|
||||
onClick={() => handleClick && handleClick()}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="collection-preview__edit-buttons"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<div className="collection-preview__edit-group" {...dragHandleProps}>
|
||||
<div className="button-collection-manage button-collection-drag top-left bottom-left">
|
||||
<Icon icon={ICONS.DRAG} title={__('Drag')} size={20} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="collection-preview__edit-group">
|
||||
{orderButton('', __('Move Top'), ICONS.UP_TOP, collectionIndex === 0, () =>
|
||||
editCollection({ order: { from: collectionIndex, to: 0 } })
|
||||
)}
|
||||
|
||||
{orderButton('', __('Move Bottom'), ICONS.DOWN_BOTTOM, collectionIndex === lastCollectionIndex, () =>
|
||||
editCollection({ order: { from: collectionIndex, to: lastCollectionIndex } })
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="collection-preview__edit-group">
|
||||
{orderButton('', __('Move Up'), ICONS.UP, collectionIndex === 0, () =>
|
||||
editCollection({ order: { from: collectionIndex, to: collectionIndex - 1 } })
|
||||
)}
|
||||
|
||||
{orderButton('', __('Move Down'), ICONS.DOWN, collectionIndex === lastCollectionIndex, () =>
|
||||
editCollection({ order: { from: collectionIndex, to: collectionIndex + 1 } })
|
||||
)}
|
||||
</div>
|
||||
|
||||
{!confirmDelete ? (
|
||||
<div className="collection-preview__edit-group collection-preview__delete ">
|
||||
<Button
|
||||
className="button-collection-manage button-collection-delete top-right bottom-right"
|
||||
icon={ICONS.DELETE}
|
||||
title={__('Remove')}
|
||||
onClick={() => setConfirmDelete(true)}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="collection-preview__edit-group collection-preview__delete">
|
||||
<Button
|
||||
className="button-collection-manage button-collection-delete-cancel top-right"
|
||||
icon={ICONS.REMOVE}
|
||||
title={__('Cancel')}
|
||||
onClick={() => setConfirmDelete(false)}
|
||||
/>
|
||||
|
||||
{orderButton('button-collection-delete-confirm bottom-right', __('Remove'), ICONS.DELETE, false, () =>
|
||||
editCollection({ uris: [uri], remove: true })
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -5,10 +5,12 @@ import { doCollectionEdit } from 'redux/actions/collections';
|
||||
import CollectionSelectItem from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
const { collectionId, uri } = props;
|
||||
|
||||
return {
|
||||
collection: makeSelectCollectionForId(props.collectionId)(state),
|
||||
hasClaim: makeSelectCollectionForIdHasClaimUrl(props.collectionId, props.uri)(state),
|
||||
collectionPending: makeSelectClaimIsPending(props.collectionId)(state),
|
||||
collection: makeSelectCollectionForId(collectionId)(state),
|
||||
hasClaim: makeSelectCollectionForIdHasClaimUrl(collectionId, uri)(state),
|
||||
collectionPending: makeSelectClaimIsPending(collectionId)(state),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -11,15 +11,15 @@ type Props = {
|
||||
category: string,
|
||||
edited: boolean,
|
||||
editCollection: (string, CollectionEditParams) => void,
|
||||
claim: Claim,
|
||||
uri: string,
|
||||
collectionPending: Collection,
|
||||
};
|
||||
|
||||
function CollectionSelectItem(props: Props) {
|
||||
const { collection, hasClaim, category, editCollection, claim, collectionPending } = props;
|
||||
const { collection, hasClaim, category, editCollection, uri, collectionPending } = props;
|
||||
const { name, id } = collection;
|
||||
const handleChange = (e) => {
|
||||
editCollection(id, { claims: [claim], remove: hasClaim });
|
||||
editCollection(id, { uris: [uri], remove: hasClaim });
|
||||
};
|
||||
|
||||
let icon;
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
selectTotalStakedAmountForChannelUri,
|
||||
selectStakedLevelForChannelUri,
|
||||
makeSelectClaimForUri,
|
||||
selectThumbnailForUri,
|
||||
selectHasChannels,
|
||||
selectMyClaimIdsRaw,
|
||||
} from 'redux/selectors/claims';
|
||||
import { doCommentUpdate, doCommentList } from 'redux/actions/comments';
|
||||
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { doClearPlayingUri } from 'redux/actions/content';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import {
|
||||
selectLinkedCommentAncestors,
|
||||
selectOthersReactsForComment,
|
||||
@@ -19,31 +21,34 @@ import { selectPlayingUri } from 'redux/selectors/content';
|
||||
import Comment from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
const { comment, uri } = props;
|
||||
const { comment_id, author_uri } = comment || {};
|
||||
|
||||
const activeChannelClaim = selectActiveChannelClaim(state);
|
||||
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
|
||||
const reactionKey = activeChannelId ? `${props.commentId}:${activeChannelId}` : props.commentId;
|
||||
const reactionKey = activeChannelId ? `${comment_id}:${activeChannelId}` : comment_id;
|
||||
|
||||
return {
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
thumbnail: props.authorUri && selectThumbnailForUri(state, props.authorUri),
|
||||
channelIsBlocked: props.authorUri && makeSelectChannelIsMuted(props.authorUri)(state),
|
||||
commentingEnabled: true,
|
||||
myChannelIds: selectMyClaimIdsRaw(state),
|
||||
claim: makeSelectClaimForUri(uri)(state),
|
||||
thumbnail: author_uri && selectThumbnailForUri(state, author_uri),
|
||||
channelIsBlocked: author_uri && makeSelectChannelIsMuted(author_uri)(state),
|
||||
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
||||
othersReacts: selectOthersReactsForComment(state, reactionKey),
|
||||
activeChannelClaim,
|
||||
hasChannels: selectHasChannels(state),
|
||||
playingUri: selectPlayingUri(state),
|
||||
stakedLevel: selectTotalStakedAmountForChannelUri(state, props.authorUri),
|
||||
stakedLevel: selectStakedLevelForChannelUri(state, author_uri),
|
||||
linkedCommentAncestors: selectLinkedCommentAncestors(state),
|
||||
totalReplyPages: makeSelectTotalReplyPagesForParentId(props.commentId)(state),
|
||||
totalReplyPages: makeSelectTotalReplyPagesForParentId(comment_id)(state),
|
||||
};
|
||||
};
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
|
||||
updateComment: (commentId, comment) => dispatch(doCommentUpdate(commentId, comment)),
|
||||
fetchReplies: (uri, parentId, page, pageSize, sortBy) =>
|
||||
dispatch(doCommentList(uri, parentId, page, pageSize, sortBy)),
|
||||
doToast: (options) => dispatch(doToast(options)),
|
||||
});
|
||||
const perform = {
|
||||
doClearPlayingUri,
|
||||
doCommentUpdate,
|
||||
fetchReplies: doCommentList,
|
||||
doToast,
|
||||
};
|
||||
|
||||
export default connect(select, perform)(Comment);
|
||||
@@ -12,7 +12,7 @@ import DateTime from 'component/dateTime';
|
||||
import Button from 'component/button';
|
||||
import Expandable from 'component/expandable';
|
||||
import MarkdownPreview from 'component/common/markdown-preview';
|
||||
import Tooltip from 'component/common/tooltip';
|
||||
import CommentBadge from 'component/common/comment-badge'; // have this?
|
||||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
import { Menu, MenuButton } from '@reach/menu-button';
|
||||
import Icon from 'component/common/icon';
|
||||
@@ -27,23 +27,21 @@ import CommentMenuList from 'component/commentMenuList';
|
||||
import UriIndicator from 'component/uriIndicator';
|
||||
import CreditAmount from 'component/common/credit-amount';
|
||||
import OptimizedImage from 'component/optimizedImage';
|
||||
import { getChannelFromClaim } from 'util/claim';
|
||||
import { parseSticker } from 'util/comments';
|
||||
import { useIsMobile } from 'effects/use-screensize';
|
||||
|
||||
const AUTO_EXPAND_ALL_REPLIES = false;
|
||||
|
||||
type Props = {
|
||||
comment: Comment,
|
||||
myChannelIds: ?Array<string>,
|
||||
clearPlayingUri: () => void,
|
||||
uri: string,
|
||||
claim: StreamClaim,
|
||||
author: ?string, // LBRY Channel Name, e.g. @channel
|
||||
authorUri: string, // full LBRY Channel URI: lbry://@channel#123...
|
||||
commentId: string, // sha256 digest identifying the comment
|
||||
message: string, // comment body
|
||||
timePosted: number, // Comment timestamp
|
||||
channelIsBlocked: boolean, // if the channel is blacklisted in the app
|
||||
claimIsMine: boolean, // if you control the claim which this comment was posted on
|
||||
commentIsMine: boolean, // if this comment was signed by an owned channel
|
||||
updateComment: (string, string) => void,
|
||||
doCommentUpdate: (string, string) => void,
|
||||
fetchReplies: (string, string, number, number, number) => void,
|
||||
totalReplyPages: number,
|
||||
commentModBlock: (string) => void,
|
||||
@@ -55,7 +53,6 @@ type Props = {
|
||||
isTopLevel?: boolean,
|
||||
threadDepth: number,
|
||||
hideActions?: boolean,
|
||||
isPinned: boolean,
|
||||
othersReacts: ?{
|
||||
like: number,
|
||||
dislike: number,
|
||||
@@ -64,11 +61,6 @@ type Props = {
|
||||
activeChannelClaim: ?ChannelClaim,
|
||||
playingUri: ?PlayingUri,
|
||||
stakedLevel: number,
|
||||
supportAmount: number,
|
||||
numDirectReplies: number,
|
||||
isModerator: boolean,
|
||||
isGlobalMod: boolean,
|
||||
isFiat: boolean,
|
||||
supportDisabled: boolean,
|
||||
setQuickReply: (any) => void,
|
||||
quickReply: any,
|
||||
@@ -76,19 +68,15 @@ type Props = {
|
||||
|
||||
const LENGTH_TO_COLLAPSE = 300;
|
||||
|
||||
function Comment(props: Props) {
|
||||
function CommentView(props: Props) {
|
||||
const {
|
||||
comment,
|
||||
myChannelIds,
|
||||
clearPlayingUri,
|
||||
claim,
|
||||
uri,
|
||||
author,
|
||||
authorUri,
|
||||
timePosted,
|
||||
message,
|
||||
channelIsBlocked,
|
||||
commentIsMine,
|
||||
commentId,
|
||||
updateComment,
|
||||
doCommentUpdate,
|
||||
fetchReplies,
|
||||
totalReplyPages,
|
||||
linkedCommentId,
|
||||
@@ -99,39 +87,61 @@ function Comment(props: Props) {
|
||||
isTopLevel,
|
||||
threadDepth,
|
||||
hideActions,
|
||||
isPinned,
|
||||
othersReacts,
|
||||
playingUri,
|
||||
stakedLevel,
|
||||
supportAmount,
|
||||
numDirectReplies,
|
||||
isModerator,
|
||||
isGlobalMod,
|
||||
isFiat,
|
||||
supportDisabled,
|
||||
setQuickReply,
|
||||
quickReply,
|
||||
} = props;
|
||||
|
||||
const {
|
||||
channel_url: authorUri,
|
||||
channel_name: author,
|
||||
channel_id: channelId,
|
||||
comment_id: commentId,
|
||||
comment: message,
|
||||
is_fiat: isFiat,
|
||||
is_global_mod: isGlobalMod,
|
||||
is_moderator: isModerator,
|
||||
is_pinned: isPinned,
|
||||
support_amount: supportAmount,
|
||||
replies: numDirectReplies,
|
||||
timestamp,
|
||||
} = comment;
|
||||
|
||||
const timePosted = timestamp * 1000;
|
||||
const commentIsMine = channelId && myChannelIds && myChannelIds.includes(channelId);
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const {
|
||||
push,
|
||||
replace,
|
||||
location: { pathname, search },
|
||||
} = useHistory();
|
||||
|
||||
const isLinkedComment = linkedCommentId && linkedCommentId === commentId;
|
||||
const isInLinkedCommentChain =
|
||||
linkedCommentId &&
|
||||
linkedCommentAncestors[linkedCommentId] &&
|
||||
linkedCommentAncestors[linkedCommentId].includes(commentId);
|
||||
const showRepliesOnMount = isInLinkedCommentChain || AUTO_EXPAND_ALL_REPLIES;
|
||||
|
||||
const [isReplying, setReplying] = React.useState(false);
|
||||
const [isEditing, setEditing] = useState(false);
|
||||
const [editedMessage, setCommentValue] = useState(message);
|
||||
const [charCount, setCharCount] = useState(editedMessage.length);
|
||||
const [showReplies, setShowReplies] = useState(false);
|
||||
const [page, setPage] = useState(0);
|
||||
const [showReplies, setShowReplies] = useState(showRepliesOnMount); // on mount
|
||||
const [page, setPage] = useState(showRepliesOnMount ? 1 : 0);
|
||||
const [advancedEditor] = usePersistedState('comment-editor-mode', false);
|
||||
const [displayDeadComment, setDisplayDeadComment] = React.useState(false);
|
||||
const likesCount = (othersReacts && othersReacts.like) || 0;
|
||||
const dislikesCount = (othersReacts && othersReacts.dislike) || 0;
|
||||
const totalLikesAndDislikes = likesCount + dislikesCount;
|
||||
const slimedToDeath = totalLikesAndDislikes >= 5 && dislikesCount / totalLikesAndDislikes > 0.8;
|
||||
const commentByOwnerOfContent = claim && claim.signing_channel && claim.signing_channel.permanent_url === authorUri;
|
||||
const contentChannelClaim = getChannelFromClaim(claim);
|
||||
const commentByOwnerOfContent = contentChannelClaim && contentChannelClaim.permanent_url === authorUri;
|
||||
const stickerFromMessage = parseSticker(message);
|
||||
|
||||
let channelOwnerOfContent;
|
||||
@@ -142,19 +152,6 @@ function Comment(props: Props) {
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// Auto-expand (limited to linked-comments for now, but can be for all)
|
||||
useEffect(() => {
|
||||
const isInLinkedCommentChain =
|
||||
linkedCommentId &&
|
||||
linkedCommentAncestors[linkedCommentId] &&
|
||||
linkedCommentAncestors[linkedCommentId].includes(commentId);
|
||||
|
||||
if (isInLinkedCommentChain || AUTO_EXPAND_ALL_REPLIES) {
|
||||
setShowReplies(true);
|
||||
setPage(1);
|
||||
}
|
||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
useEffect(() => {
|
||||
if (isEditing) {
|
||||
setCharCount(editedMessage.length);
|
||||
@@ -193,7 +190,7 @@ function Comment(props: Props) {
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
updateComment(commentId, editedMessage);
|
||||
doCommentUpdate(commentId, editedMessage);
|
||||
if (setQuickReply) setQuickReply({ ...quickReply, comment_id: commentId, comment: editedMessage });
|
||||
setEditing(false);
|
||||
}
|
||||
@@ -214,6 +211,34 @@ function Comment(props: Props) {
|
||||
replace(`${pathname}?${urlParams.toString()}`);
|
||||
}
|
||||
|
||||
// find a way to enable linked comments - probably use share url.
|
||||
// const linkedCommentRef = React.useCallback(
|
||||
// (node) => {
|
||||
// if (node !== null && window.pendingLinkedCommentScroll) {
|
||||
// const ROUGH_HEADER_HEIGHT = 125; // @see: --header-height
|
||||
// delete window.pendingLinkedCommentScroll;
|
||||
//
|
||||
// const mobileChatElem = document.querySelector('.MuiPaper-root .card--enable-overflow');
|
||||
// const drawerElem = document.querySelector('.MuiDrawer-root');
|
||||
// const elem = (isMobile && mobileChatElem) || window;
|
||||
//
|
||||
// if (elem) {
|
||||
// // $FlowFixMe
|
||||
// elem.scrollTo({
|
||||
// top:
|
||||
// node.getBoundingClientRect().top +
|
||||
// // $FlowFixMe
|
||||
// (mobileChatElem && drawerElem ? drawerElem.getBoundingClientRect().top * -1 : elem.scrollY) -
|
||||
// ROUGH_HEADER_HEIGHT,
|
||||
// left: 0,
|
||||
// behavior: 'smooth',
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// [isMobile]
|
||||
// );
|
||||
|
||||
return (
|
||||
<li
|
||||
className={classnames('comment', {
|
||||
@@ -225,7 +250,7 @@ function Comment(props: Props) {
|
||||
>
|
||||
<div
|
||||
className={classnames('comment__content', {
|
||||
[COMMENT_HIGHLIGHTED]: linkedCommentId && linkedCommentId === commentId,
|
||||
[COMMENT_HIGHLIGHTED]: isLinkedComment,
|
||||
'comment--slimed': slimedToDeath && !displayDeadComment,
|
||||
})}
|
||||
>
|
||||
@@ -240,21 +265,8 @@ function Comment(props: Props) {
|
||||
<div className="comment__body-container">
|
||||
<div className="comment__meta">
|
||||
<div className="comment__meta-information">
|
||||
{isGlobalMod && (
|
||||
<Tooltip label={__('Admin')}>
|
||||
<span className="comment__badge comment__badge--global-mod">
|
||||
<Icon icon={ICONS.BADGE_MOD} size={20} />
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
{isModerator && (
|
||||
<Tooltip label={__('Moderator')}>
|
||||
<span className="comment__badge comment__badge--mod">
|
||||
<Icon icon={ICONS.BADGE_MOD} size={20} />
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
{isGlobalMod && <CommentBadge label={__('Admin')} icon={ICONS.BADGE_MOD} />}
|
||||
{isModerator && <CommentBadge label={__('Moderator')} icon={ICONS.BADGE_MOD} />}
|
||||
|
||||
{!author ? (
|
||||
<span className="comment__author">{__('Anonymous')}</span>
|
||||
@@ -314,6 +326,7 @@ function Comment(props: Props) {
|
||||
charCount={charCount}
|
||||
onChange={handleEditMessageChanged}
|
||||
textAreaMaxLength={FF_MAX_CHARS_IN_COMMENT}
|
||||
handleSubmit={handleSubmit}
|
||||
/>
|
||||
<div className="section__actions section__actions--no-margin">
|
||||
<Button button="primary" type="submit" label={__('Done')} disabled={message === editedMessage} />
|
||||
@@ -358,6 +371,7 @@ function Comment(props: Props) {
|
||||
className="comment__action"
|
||||
onClick={handleCommentReply}
|
||||
icon={ICONS.REPLY}
|
||||
iconSize={isMobile && 12}
|
||||
/>
|
||||
)}
|
||||
{ENABLE_COMMENT_REACTIONS && <CommentReactions uri={uri} commentId={commentId} />}
|
||||
@@ -431,4 +445,4 @@ function Comment(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
export default Comment;
|
||||
export default CommentView;
|
||||
@@ -21,7 +21,6 @@ type Props = {
|
||||
// --- select ---
|
||||
claim: ?Claim,
|
||||
claimIsMine: boolean,
|
||||
contentChannelPermanentUrl: any,
|
||||
activeChannelClaim: ?ChannelClaim,
|
||||
playingUri: ?PlayingUri,
|
||||
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
|
||||
@@ -44,7 +43,6 @@ function CommentMenuList(props: Props) {
|
||||
commentIsMine,
|
||||
commentId,
|
||||
activeChannelClaim,
|
||||
contentChannelPermanentUrl,
|
||||
isTopLevel,
|
||||
isPinned,
|
||||
playingUri,
|
||||
@@ -62,6 +60,7 @@ function CommentMenuList(props: Props) {
|
||||
} = props;
|
||||
|
||||
const contentChannelClaim = getChannelFromClaim(claim);
|
||||
const contentChannelPermanentUrl = contentChannelClaim && contentChannelClaim.permanent_url;
|
||||
const activeModeratorInfo = activeChannelClaim && moderationDelegatorsById[activeChannelClaim.claim_id];
|
||||
const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl;
|
||||
const activeChannelIsAdmin = activeChannelClaim && activeModeratorInfo && activeModeratorInfo.global;
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
makeSelectClaimForUri,
|
||||
selectClaimIsMine,
|
||||
selectFetchingMyChannels,
|
||||
selectMyClaimIdsRaw,
|
||||
} from 'redux/selectors/claims';
|
||||
import {
|
||||
selectTopLevelCommentsForUri,
|
||||
@@ -22,12 +21,17 @@ import {
|
||||
} from 'redux/selectors/comments';
|
||||
import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
|
||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { getChannelIdFromClaim } from 'util/claim';
|
||||
import CommentsList from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
const claim = selectClaimForUri(state, props.uri);
|
||||
const { uri } = props;
|
||||
|
||||
const claim = selectClaimForUri(state, uri);
|
||||
const channelId = getChannelIdFromClaim(claim);
|
||||
|
||||
const activeChannelClaim = selectActiveChannelClaim(state);
|
||||
const topLevelComments = selectTopLevelCommentsForUri(state, props.uri);
|
||||
const topLevelComments = selectTopLevelCommentsForUri(state, uri);
|
||||
|
||||
const resolvedComments =
|
||||
topLevelComments && topLevelComments.length > 0
|
||||
@@ -37,12 +41,12 @@ const select = (state, props) => {
|
||||
return {
|
||||
topLevelComments,
|
||||
resolvedComments,
|
||||
myChannelIds: selectMyClaimIdsRaw(state),
|
||||
allCommentIds: selectCommentIdsForUri(state, props.uri),
|
||||
pinnedComments: selectPinnedCommentsForUri(state, props.uri),
|
||||
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
|
||||
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
|
||||
claim,
|
||||
allCommentIds: selectCommentIdsForUri(state, uri),
|
||||
pinnedComments: selectPinnedCommentsForUri(state, uri),
|
||||
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(uri)(state),
|
||||
totalComments: makeSelectTotalCommentsCountForUri(uri)(state),
|
||||
claimId: claim && claim.claim_id,
|
||||
channelId,
|
||||
claimIsMine: selectClaimIsMine(state, claim),
|
||||
isFetchingComments: selectIsFetchingComments(state),
|
||||
isFetchingCommentsById: selectIsFetchingCommentsById(state),
|
||||
@@ -55,12 +59,12 @@ const select = (state, props) => {
|
||||
};
|
||||
};
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
fetchTopLevelComments: (uri, page, pageSize, sortBy) => dispatch(doCommentList(uri, '', page, pageSize, sortBy)),
|
||||
fetchComment: (commentId) => dispatch(doCommentById(commentId)),
|
||||
fetchReacts: (commentIds) => dispatch(doCommentReactList(commentIds)),
|
||||
resetComments: (claimId) => dispatch(doCommentReset(claimId)),
|
||||
doResolveUris: (uris) => dispatch(doResolveUris(uris, true)),
|
||||
});
|
||||
const perform = {
|
||||
fetchTopLevelComments: doCommentList,
|
||||
fetchComment: doCommentById,
|
||||
fetchReacts: doCommentReactList,
|
||||
resetComments: doCommentReset,
|
||||
doResolveUris,
|
||||
};
|
||||
|
||||
export default connect(select, perform)(CommentsList);
|
||||
+153
-108
@@ -1,9 +1,8 @@
|
||||
// @flow
|
||||
import { COMMENT_HIGHLIGHTED } from 'constants/classnames';
|
||||
import { COMMENT_PAGE_SIZE_TOP_LEVEL, SORT_BY } from 'constants/comment';
|
||||
import { ENABLE_COMMENT_REACTIONS } from 'config';
|
||||
import { getChannelIdFromClaim } from 'util/claim';
|
||||
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
|
||||
import { getCommentsListTitle } from 'util/comments';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as REACTION_TYPES from 'constants/reactions';
|
||||
import Button from 'component/button';
|
||||
@@ -15,7 +14,6 @@ import debounce from 'util/debounce';
|
||||
import Empty from 'component/common/empty';
|
||||
import React, { useEffect } from 'react';
|
||||
import Spinner from 'component/spinner';
|
||||
import useFetched from 'effects/use-fetched';
|
||||
import usePersistedState from 'effects/use-persisted-state';
|
||||
|
||||
const DEBOUNCE_SCROLL_HANDLER_MS = 200;
|
||||
@@ -32,11 +30,12 @@ type Props = {
|
||||
allCommentIds: any,
|
||||
pinnedComments: Array<Comment>,
|
||||
topLevelComments: Array<Comment>,
|
||||
resolvedComments: Array<Comment>,
|
||||
topLevelTotalPages: number,
|
||||
uri: string,
|
||||
claim: ?Claim,
|
||||
claimId?: string,
|
||||
channelId?: string,
|
||||
claimIsMine: boolean,
|
||||
myChannels: ?Array<ChannelClaim>,
|
||||
isFetchingComments: boolean,
|
||||
isFetchingCommentsById: boolean,
|
||||
isFetchingReacts: boolean,
|
||||
@@ -47,25 +46,26 @@ type Props = {
|
||||
othersReactsById: ?{ [string]: { [REACTION_TYPES.LIKE | REACTION_TYPES.DISLIKE]: number } },
|
||||
activeChannelId: ?string,
|
||||
settingsByChannelId: { [channelId: string]: PerChannelSettings },
|
||||
fetchReacts: (Array<string>) => Promise<any>,
|
||||
commentsAreExpanded?: boolean,
|
||||
fetchTopLevelComments: (string, number, number, number) => void,
|
||||
fetchComment: (string) => void,
|
||||
resetComments: (string) => void,
|
||||
fetchTopLevelComments: (uri: string, parentId: string, page: number, pageSize: number, sortBy: number) => void,
|
||||
fetchComment: (commentId: string) => void,
|
||||
fetchReacts: (commentIds: Array<string>) => Promise<any>,
|
||||
resetComments: (claimId: string) => void,
|
||||
doResolveUris: (uris: Array<string>, returnCachedClaims: boolean) => void,
|
||||
};
|
||||
|
||||
function CommentList(props: Props) {
|
||||
export default function CommentList(props: Props) {
|
||||
const {
|
||||
allCommentIds,
|
||||
uri,
|
||||
pinnedComments,
|
||||
topLevelComments,
|
||||
resolvedComments,
|
||||
topLevelTotalPages,
|
||||
claim,
|
||||
claimId,
|
||||
channelId,
|
||||
claimIsMine,
|
||||
myChannels,
|
||||
isFetchingComments,
|
||||
isFetchingCommentsById,
|
||||
isFetchingReacts,
|
||||
linkedCommentId,
|
||||
totalComments,
|
||||
@@ -74,28 +74,33 @@ function CommentList(props: Props) {
|
||||
othersReactsById,
|
||||
activeChannelId,
|
||||
settingsByChannelId,
|
||||
fetchReacts,
|
||||
commentsAreExpanded,
|
||||
fetchTopLevelComments,
|
||||
fetchComment,
|
||||
fetchReacts,
|
||||
resetComments,
|
||||
doResolveUris,
|
||||
} = props;
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
const isMediumScreen = useIsMediumScreen();
|
||||
|
||||
const spinnerRef = React.useRef();
|
||||
const DEFAULT_SORT = ENABLE_COMMENT_REACTIONS ? SORT_BY.POPULARITY : SORT_BY.NEWEST;
|
||||
const [sort, setSort] = usePersistedState('comment-sort-by', DEFAULT_SORT);
|
||||
const [page, setPage] = React.useState(0);
|
||||
const fetchedCommentsOnce = useFetched(isFetchingComments);
|
||||
const fetchedReactsOnce = useFetched(isFetchingReacts);
|
||||
const fetchedLinkedComment = useFetched(isFetchingCommentsById);
|
||||
const hasDefaultExpansion = commentsAreExpanded || (!isMobile && !isMediumScreen);
|
||||
const [commentsToDisplay, setCommentsToDisplay] = React.useState(topLevelComments);
|
||||
const [didInitialPageFetch, setInitialPageFetch] = React.useState(false);
|
||||
const hasDefaultExpansion = commentsAreExpanded || !isMediumScreen || isMobile;
|
||||
const [expandedComments, setExpandedComments] = React.useState(hasDefaultExpansion);
|
||||
|
||||
const totalFetchedComments = allCommentIds ? allCommentIds.length : 0;
|
||||
const channelId = getChannelIdFromClaim(claim);
|
||||
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
|
||||
const moreBelow = page < topLevelTotalPages;
|
||||
const isResolvingComments = topLevelComments && resolvedComments.length !== topLevelComments.length;
|
||||
const alreadyResolved = !isResolvingComments && resolvedComments.length !== 0;
|
||||
const canDisplayComments = commentsToDisplay && commentsToDisplay.length === topLevelComments.length;
|
||||
const title = getCommentsListTitle(totalComments);
|
||||
|
||||
// Display comments immediately if not fetching reactions
|
||||
// If not, wait to show comments until reactions are fetched
|
||||
@@ -113,8 +118,8 @@ function CommentList(props: Props) {
|
||||
// Reset comments
|
||||
useEffect(() => {
|
||||
if (page === 0) {
|
||||
if (claim) {
|
||||
resetComments(claim.claim_id);
|
||||
if (claimId) {
|
||||
resetComments(claimId);
|
||||
}
|
||||
setPage(1);
|
||||
}
|
||||
@@ -128,7 +133,7 @@ function CommentList(props: Props) {
|
||||
fetchComment(linkedCommentId);
|
||||
}
|
||||
|
||||
fetchTopLevelComments(uri, page, COMMENT_PAGE_SIZE_TOP_LEVEL, sort);
|
||||
fetchTopLevelComments(uri, '', page, COMMENT_PAGE_SIZE_TOP_LEVEL, sort);
|
||||
}
|
||||
}, [fetchComment, fetchTopLevelComments, linkedCommentId, page, sort, uri]);
|
||||
|
||||
@@ -167,23 +172,17 @@ function CommentList(props: Props) {
|
||||
|
||||
// Scroll to linked-comment
|
||||
useEffect(() => {
|
||||
if (fetchedLinkedComment && fetchedCommentsOnce && fetchedReactsOnce) {
|
||||
const elems = document.getElementsByClassName(COMMENT_HIGHLIGHTED);
|
||||
if (elems.length > 0) {
|
||||
const ROUGH_HEADER_HEIGHT = 125; // @see: --header-height
|
||||
const linkedComment = elems[0];
|
||||
window.scrollTo({
|
||||
top: linkedComment.getBoundingClientRect().top + window.scrollY - ROUGH_HEADER_HEIGHT,
|
||||
left: 0,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}
|
||||
if (linkedCommentId) {
|
||||
window.pendingLinkedCommentScroll = true;
|
||||
} else {
|
||||
delete window.pendingLinkedCommentScroll;
|
||||
}
|
||||
}, [fetchedLinkedComment, fetchedCommentsOnce, fetchedReactsOnce]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// Infinite scroll
|
||||
useEffect(() => {
|
||||
function shouldFetchNextPage(page, topLevelTotalPages, window, document, yPrefetchPx = 1000) {
|
||||
function shouldFetchNextPage(page, topLevelTotalPages, yPrefetchPx = 1000) {
|
||||
if (!spinnerRef || !spinnerRef.current) return false;
|
||||
|
||||
const rect = spinnerRef.current.getBoundingClientRect(); // $FlowFixMe
|
||||
@@ -206,86 +205,67 @@ function CommentList(props: Props) {
|
||||
}
|
||||
|
||||
const handleCommentScroll = debounce(() => {
|
||||
if (hasDefaultExpansion && shouldFetchNextPage(page, topLevelTotalPages, window, document)) {
|
||||
if (shouldFetchNextPage(page, topLevelTotalPages)) {
|
||||
setPage(page + 1);
|
||||
setInitialPageFetch(true);
|
||||
}
|
||||
}, DEBOUNCE_SCROLL_HANDLER_MS);
|
||||
|
||||
if (!isFetchingComments && readyToDisplayComments && moreBelow && spinnerRef && spinnerRef.current) {
|
||||
if (shouldFetchNextPage(page, topLevelTotalPages, window, document, 0)) {
|
||||
setPage(page + 1);
|
||||
} else {
|
||||
window.addEventListener('scroll', handleCommentScroll);
|
||||
return () => window.removeEventListener('scroll', handleCommentScroll);
|
||||
if (!didInitialPageFetch) {
|
||||
handleCommentScroll();
|
||||
setInitialPageFetch(true);
|
||||
}
|
||||
|
||||
if (hasDefaultExpansion && !isFetchingComments && canDisplayComments && readyToDisplayComments && moreBelow) {
|
||||
const commentsInDrawer = Boolean(document.querySelector('.MuiDrawer-root .card--enable-overflow'));
|
||||
const scrollingElement = commentsInDrawer ? document.querySelector('.card--enable-overflow') : window;
|
||||
|
||||
if (scrollingElement) {
|
||||
scrollingElement.addEventListener('scroll', handleCommentScroll);
|
||||
|
||||
return () => scrollingElement.removeEventListener('scroll', handleCommentScroll);
|
||||
}
|
||||
}
|
||||
}, [hasDefaultExpansion, isFetchingComments, moreBelow, page, readyToDisplayComments, topLevelTotalPages]);
|
||||
}, [
|
||||
canDisplayComments,
|
||||
hasDefaultExpansion,
|
||||
didInitialPageFetch,
|
||||
isFetchingComments,
|
||||
isMobile,
|
||||
moreBelow,
|
||||
page,
|
||||
readyToDisplayComments,
|
||||
topLevelTotalPages,
|
||||
]);
|
||||
|
||||
const getCommentElems = (comments) => {
|
||||
return comments.map((comment) => (
|
||||
<CommentView
|
||||
isTopLevel
|
||||
threadDepth={3}
|
||||
key={comment.comment_id}
|
||||
uri={uri}
|
||||
authorUri={comment.channel_url}
|
||||
author={comment.channel_name}
|
||||
claimId={comment.claim_id}
|
||||
commentId={comment.comment_id}
|
||||
message={comment.comment}
|
||||
timePosted={comment.timestamp * 1000}
|
||||
claimIsMine={claimIsMine}
|
||||
commentIsMine={
|
||||
comment.channel_id && myChannels && myChannels.some(({ claim_id }) => claim_id === comment.channel_id)
|
||||
}
|
||||
linkedCommentId={linkedCommentId}
|
||||
isPinned={comment.is_pinned}
|
||||
supportAmount={comment.support_amount}
|
||||
numDirectReplies={comment.replies}
|
||||
isModerator={comment.is_moderator}
|
||||
isGlobalMod={comment.is_global_mod}
|
||||
isFiat={comment.is_fiat}
|
||||
/>
|
||||
));
|
||||
};
|
||||
// Wait to only display topLevelComments after resolved or else
|
||||
// other components will try to resolve again, like channelThumbnail
|
||||
useEffect(() => {
|
||||
if (!isResolvingComments) setCommentsToDisplay(topLevelComments);
|
||||
}, [isResolvingComments, topLevelComments]);
|
||||
|
||||
const sortButton = (label, icon, sortOption) => {
|
||||
return (
|
||||
<Button
|
||||
button="alt"
|
||||
label={label}
|
||||
icon={icon}
|
||||
iconSize={18}
|
||||
onClick={() => changeSort(sortOption)}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': sort === sortOption,
|
||||
})}
|
||||
/>
|
||||
);
|
||||
};
|
||||
// Batch resolve comment channel urls
|
||||
useEffect(() => {
|
||||
if (!topLevelComments || alreadyResolved) return;
|
||||
|
||||
const urisToResolve = [];
|
||||
topLevelComments.map(({ channel_url }) => channel_url !== undefined && urisToResolve.push(channel_url));
|
||||
|
||||
if (urisToResolve.length > 0) doResolveUris(urisToResolve, true);
|
||||
}, [alreadyResolved, doResolveUris, topLevelComments]);
|
||||
|
||||
const commentProps = { isTopLevel: true, threadDepth: 3, uri, claimIsMine, linkedCommentId };
|
||||
const actionButtonsProps = { totalComments, sort, changeSort, setPage };
|
||||
|
||||
return (
|
||||
<Card
|
||||
className="card--enable-overflow"
|
||||
title={
|
||||
(totalComments === 0 && __('Leave a comment')) ||
|
||||
(totalComments === 1 && __('1 comment')) ||
|
||||
__('%totalComments% comments', { totalComments })
|
||||
}
|
||||
titleActions={
|
||||
<>
|
||||
{totalComments > 1 && ENABLE_COMMENT_REACTIONS && (
|
||||
<span className="comment__sort">
|
||||
{sortButton(__('Best'), ICONS.BEST, SORT_BY.POPULARITY)}
|
||||
{sortButton(__('Controversial'), ICONS.CONTROVERSIAL, SORT_BY.CONTROVERSY)}
|
||||
{sortButton(__('New'), ICONS.NEW, SORT_BY.NEWEST)}
|
||||
</span>
|
||||
)}
|
||||
<Button button="alt" icon={ICONS.REFRESH} title={__('Refresh')} onClick={() => setPage(0)} />
|
||||
</>
|
||||
}
|
||||
title={!isMobile && title}
|
||||
titleActions={<CommentActionButtons {...actionButtonsProps} />}
|
||||
actions={
|
||||
<>
|
||||
{isMobile && <CommentActionButtons {...actionButtonsProps} />}
|
||||
|
||||
<CommentCreate uri={uri} />
|
||||
|
||||
{channelSettings && channelSettings.comments_enabled && !isFetchingComments && !totalComments && (
|
||||
@@ -294,15 +274,20 @@ function CommentList(props: Props) {
|
||||
|
||||
<ul
|
||||
className={classnames({
|
||||
comments: expandedComments,
|
||||
'comments--contracted': !expandedComments,
|
||||
comments: !isMediumScreen || expandedComments,
|
||||
'comments--contracted': isMediumScreen && !expandedComments,
|
||||
})}
|
||||
>
|
||||
{readyToDisplayComments && pinnedComments && getCommentElems(pinnedComments)}
|
||||
{readyToDisplayComments && topLevelComments && getCommentElems(topLevelComments)}
|
||||
{readyToDisplayComments && (
|
||||
<>
|
||||
{pinnedComments && <CommentElements comments={pinnedComments} {...commentProps} />}
|
||||
|
||||
{commentsToDisplay && <CommentElements comments={commentsToDisplay} {...commentProps} />}
|
||||
</>
|
||||
)}
|
||||
</ul>
|
||||
|
||||
{!hasDefaultExpansion && topLevelComments && Boolean(topLevelComments.length) && (
|
||||
{!hasDefaultExpansion && (
|
||||
<div className="card__bottom-actions--comments">
|
||||
{(!expandedComments || moreBelow) && (
|
||||
<Button
|
||||
@@ -323,7 +308,7 @@ function CommentList(props: Props) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(isFetchingComments || (hasDefaultExpansion && moreBelow)) && (
|
||||
{(isFetchingComments || (hasDefaultExpansion && moreBelow) || !canDisplayComments) && (
|
||||
<div className="main--empty" ref={spinnerRef}>
|
||||
<Spinner type="small" />
|
||||
</div>
|
||||
@@ -334,4 +319,64 @@ function CommentList(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
export default CommentList;
|
||||
type CommentProps = {
|
||||
comments: Array<Comment>,
|
||||
};
|
||||
|
||||
const CommentElements = (commentProps: CommentProps) => {
|
||||
const { comments, ...commentsProps } = commentProps;
|
||||
|
||||
return comments.map((comment) => <CommentView key={comment.comment_id} comment={comment} {...commentsProps} />);
|
||||
};
|
||||
|
||||
type ActionButtonsProps = {
|
||||
totalComments: number,
|
||||
sort: string,
|
||||
changeSort: (string) => void,
|
||||
setPage: (number) => void,
|
||||
};
|
||||
|
||||
const CommentActionButtons = (actionButtonsProps: ActionButtonsProps) => {
|
||||
const { totalComments, sort, changeSort, setPage } = actionButtonsProps;
|
||||
|
||||
const sortButtonProps = { activeSort: sort, changeSort };
|
||||
|
||||
return (
|
||||
<>
|
||||
{totalComments > 1 && ENABLE_COMMENT_REACTIONS && (
|
||||
<span className="comment__sort">
|
||||
<SortButton {...sortButtonProps} label={__('Best')} icon={ICONS.BEST} sortOption={SORT_BY.POPULARITY} />
|
||||
<SortButton
|
||||
{...sortButtonProps}
|
||||
label={__('Controversial')}
|
||||
icon={ICONS.CONTROVERSIAL}
|
||||
sortOption={SORT_BY.CONTROVERSY}
|
||||
/>
|
||||
<SortButton {...sortButtonProps} label={__('New')} icon={ICONS.NEW} sortOption={SORT_BY.NEWEST} />
|
||||
</span>
|
||||
)}
|
||||
|
||||
<Button button="alt" icon={ICONS.REFRESH} title={__('Refresh')} onClick={() => setPage(0)} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
type SortButtonProps = {
|
||||
activeSort: string,
|
||||
sortOption: string,
|
||||
changeSort: (string) => void,
|
||||
};
|
||||
|
||||
const SortButton = (sortButtonProps: SortButtonProps) => {
|
||||
const { activeSort, sortOption, changeSort, ...buttonProps } = sortButtonProps;
|
||||
|
||||
return (
|
||||
<Button
|
||||
{...buttonProps}
|
||||
className={classnames(`button-toggle`, { 'button-toggle--active': activeSort === sortOption })}
|
||||
button="alt"
|
||||
iconSize={18}
|
||||
onClick={() => changeSort(sortOption)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doResolveUris } from 'redux/actions/claims';
|
||||
import { makeSelectClaimIsMine, selectMyChannelClaims, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectClaimIsMineForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectIsFetchingCommentsByParentId, selectRepliesForParentId } from 'redux/selectors/comments';
|
||||
import CommentsReplies from './view';
|
||||
|
||||
@@ -14,9 +14,8 @@ const select = (state, props) => {
|
||||
return {
|
||||
fetchedReplies,
|
||||
resolvedReplies,
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
userCanComment: true,
|
||||
myChannels: selectMyChannelClaims(state),
|
||||
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
// @flow
|
||||
import * as ICONS from 'constants/icons';
|
||||
import React from 'react';
|
||||
import Comment from 'component/comment';
|
||||
import Button from 'component/button';
|
||||
import Comment from 'component/comment';
|
||||
import React from 'react';
|
||||
import Spinner from 'component/spinner';
|
||||
|
||||
type Props = {
|
||||
fetchedReplies: Array<any>,
|
||||
fetchedReplies: Array<Comment>,
|
||||
resolvedReplies: Array<Comment>,
|
||||
uri: string,
|
||||
parentId: string,
|
||||
claimIsMine: boolean,
|
||||
myChannels: ?Array<ChannelClaim>,
|
||||
linkedCommentId?: string,
|
||||
commentingEnabled: boolean,
|
||||
userCanComment: boolean,
|
||||
threadDepth: number,
|
||||
numDirectReplies: number, // Total replies for parentId as reported by 'comment[replies]'. Includes blocked items.
|
||||
isFetchingByParentId: { [string]: boolean },
|
||||
onShowMore?: () => void,
|
||||
hasMore: boolean,
|
||||
supportDisabled: boolean,
|
||||
doResolveUris: (Array<string>) => void,
|
||||
onShowMore?: () => void,
|
||||
};
|
||||
|
||||
function CommentsReplies(props: Props) {
|
||||
@@ -26,102 +27,93 @@ function CommentsReplies(props: Props) {
|
||||
uri,
|
||||
parentId,
|
||||
fetchedReplies,
|
||||
resolvedReplies,
|
||||
claimIsMine,
|
||||
myChannels,
|
||||
linkedCommentId,
|
||||
commentingEnabled,
|
||||
userCanComment,
|
||||
threadDepth,
|
||||
numDirectReplies,
|
||||
isFetchingByParentId,
|
||||
onShowMore,
|
||||
hasMore,
|
||||
supportDisabled,
|
||||
doResolveUris,
|
||||
onShowMore,
|
||||
} = props;
|
||||
|
||||
const [isExpanded, setExpanded] = React.useState(true);
|
||||
const [commentsToDisplay, setCommentsToDisplay] = React.useState(fetchedReplies);
|
||||
const isResolvingReplies = fetchedReplies && resolvedReplies.length !== fetchedReplies.length;
|
||||
const alreadyResolved = !isResolvingReplies && resolvedReplies.length !== 0;
|
||||
const canDisplayComments = commentsToDisplay && commentsToDisplay.length === fetchedReplies.length;
|
||||
|
||||
function showMore() {
|
||||
if (onShowMore) {
|
||||
onShowMore();
|
||||
}
|
||||
}
|
||||
// Batch resolve comment channel urls
|
||||
React.useEffect(() => {
|
||||
if (!fetchedReplies || alreadyResolved) return;
|
||||
|
||||
// todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine
|
||||
function isMyComment(channelId: string) {
|
||||
if (myChannels != null && channelId != null) {
|
||||
for (let i = 0; i < myChannels.length; i++) {
|
||||
if (myChannels[i].claim_id === channelId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const urisToResolve = [];
|
||||
fetchedReplies.map(({ channel_url }) => channel_url !== undefined && urisToResolve.push(channel_url));
|
||||
|
||||
const displayedComments = fetchedReplies;
|
||||
if (urisToResolve.length > 0) doResolveUris(urisToResolve);
|
||||
}, [alreadyResolved, doResolveUris, fetchedReplies]);
|
||||
|
||||
return (
|
||||
Boolean(numDirectReplies) && (
|
||||
<div className="comment__replies-container">
|
||||
{Boolean(numDirectReplies) && !isExpanded && (
|
||||
// Wait to only display topLevelComments after resolved or else
|
||||
// other components will try to resolve again, like channelThumbnail
|
||||
React.useEffect(() => {
|
||||
if (!isResolvingReplies) setCommentsToDisplay(fetchedReplies);
|
||||
}, [isResolvingReplies, fetchedReplies]);
|
||||
|
||||
return !numDirectReplies ? null : (
|
||||
<div className="comment__replies-container">
|
||||
{!isExpanded ? (
|
||||
<div className="comment__actions--nested">
|
||||
<Button
|
||||
className="comment__action"
|
||||
label={__('Show Replies')}
|
||||
onClick={() => setExpanded(!isExpanded)}
|
||||
icon={isExpanded ? ICONS.UP : ICONS.DOWN}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="comment__replies">
|
||||
<Button className="comment__threadline" aria-label="Hide Replies" onClick={() => setExpanded(false)} />
|
||||
|
||||
<ul className="comments--replies">
|
||||
{!isResolvingReplies &&
|
||||
commentsToDisplay &&
|
||||
commentsToDisplay.length > 0 &&
|
||||
commentsToDisplay.map((comment) => (
|
||||
<Comment
|
||||
key={comment.comment_id}
|
||||
threadDepth={threadDepth}
|
||||
uri={uri}
|
||||
comment={comment}
|
||||
claimIsMine={claimIsMine}
|
||||
linkedCommentId={linkedCommentId}
|
||||
commentingEnabled={userCanComment}
|
||||
supportDisabled={supportDisabled}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
{isExpanded && fetchedReplies && hasMore && (
|
||||
<div className="comment__actions--nested">
|
||||
<Button
|
||||
button="link"
|
||||
label={__('Show more')}
|
||||
onClick={() => onShowMore && onShowMore()}
|
||||
className="button--uri-indicator"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{(isFetchingByParentId[parentId] || isResolvingReplies || !canDisplayComments) && (
|
||||
<div className="comment__replies-container">
|
||||
<div className="comment__actions--nested">
|
||||
<Button
|
||||
className="comment__action"
|
||||
label={__('Show Replies')}
|
||||
onClick={() => setExpanded(!isExpanded)}
|
||||
icon={isExpanded ? ICONS.UP : ICONS.DOWN}
|
||||
/>
|
||||
<Spinner type="small" />
|
||||
</div>
|
||||
)}
|
||||
{isExpanded && (
|
||||
<div>
|
||||
<div className="comment__replies">
|
||||
<Button className="comment__threadline" aria-label="Hide Replies" onClick={() => setExpanded(false)} />
|
||||
|
||||
<ul className="comments--replies">
|
||||
{displayedComments &&
|
||||
displayedComments.map((comment) => {
|
||||
return (
|
||||
<Comment
|
||||
threadDepth={threadDepth}
|
||||
uri={uri}
|
||||
authorUri={comment.channel_url}
|
||||
author={comment.channel_name}
|
||||
claimId={comment.claim_id}
|
||||
commentId={comment.comment_id}
|
||||
key={comment.comment_id}
|
||||
message={comment.comment}
|
||||
timePosted={comment.timestamp * 1000}
|
||||
claimIsMine={claimIsMine}
|
||||
commentIsMine={comment.channel_id && isMyComment(comment.channel_id)}
|
||||
linkedCommentId={linkedCommentId}
|
||||
commentingEnabled={commentingEnabled}
|
||||
supportAmount={comment.support_amount}
|
||||
numDirectReplies={comment.replies}
|
||||
isModerator={comment.is_moderator}
|
||||
isGlobalMod={comment.is_global_mod}
|
||||
supportDisabled={supportDisabled}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{isExpanded && fetchedReplies && hasMore && (
|
||||
<div className="comment__actions--nested">
|
||||
<Button button="link" label={__('Show more')} onClick={showMore} className="button--uri-indicator" />
|
||||
</div>
|
||||
)}
|
||||
{isFetchingByParentId[parentId] && (
|
||||
<div className="comment__replies-container">
|
||||
<div className="comment__actions--nested">
|
||||
<Spinner type="small" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// @flow
|
||||
import 'scss/component/_comment-badge.scss';
|
||||
|
||||
import classnames from 'classnames';
|
||||
import Icon from 'component/common/icon';
|
||||
import React from 'react';
|
||||
import Tooltip from 'component/common/tooltip';
|
||||
|
||||
const LABEL_TYPES = {
|
||||
ADMIN: 'Admin',
|
||||
MOD: 'Moderator',
|
||||
};
|
||||
|
||||
type Props = {
|
||||
icon: string,
|
||||
label: string,
|
||||
size?: number,
|
||||
};
|
||||
|
||||
export default function CommentBadge(props: Props) {
|
||||
const { icon, label, size = 20 } = props;
|
||||
|
||||
return (
|
||||
<Tooltip title={label} placement="top">
|
||||
<span
|
||||
className={classnames('comment__badge', {
|
||||
'comment__badge--globalMod': label === LABEL_TYPES.ADMIN,
|
||||
'comment__badge--mod': label === LABEL_TYPES.MOD,
|
||||
})}
|
||||
>
|
||||
<Icon icon={icon} size={size} />
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { MenuLink } from '@reach/menu-button';
|
||||
import Icon from 'component/common/icon';
|
||||
|
||||
type Props = {
|
||||
icon: string,
|
||||
name: string,
|
||||
page: string,
|
||||
};
|
||||
|
||||
export default function HeaderMenuLink(props: Props) {
|
||||
const { icon, name, page } = props;
|
||||
|
||||
return (
|
||||
<MenuLink className="menu__link" as={Link} to={`/$/${page}`}>
|
||||
<Icon aria-hidden icon={icon} />
|
||||
{name}
|
||||
</MenuLink>
|
||||
);
|
||||
}
|
||||
@@ -382,21 +382,10 @@ export const icons = {
|
||||
[ICONS.NO]: buildIcon(
|
||||
<path d="M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17" />
|
||||
),
|
||||
[ICONS.UP]: buildIcon(
|
||||
<g>
|
||||
<polyline transform="matrix(1,0,0,-1,0,24.707107)" points="6 9 12 15 18 9" />
|
||||
</g>
|
||||
),
|
||||
[ICONS.UP_TOP]: buildIcon(
|
||||
<g>
|
||||
<path d="m6 16 6-6 6 6M6 8h12" />
|
||||
</g>
|
||||
),
|
||||
[ICONS.DOWN_BOTTOM]: buildIcon(
|
||||
<g>
|
||||
<path d="m6 8 6 6 6-6M6 16h12" />
|
||||
</g>
|
||||
),
|
||||
[ICONS.UP]: buildIcon(<polyline transform="matrix(1,0,0,-1,0,24.707107)" points="6 9 12 15 18 9" />),
|
||||
[ICONS.UP_TOP]: buildIcon(<path d="m6 16 6-6 6 6M6 8h12" />),
|
||||
[ICONS.DOWN_BOTTOM]: buildIcon(<path d="m6 8 6 6 6-6M6 16h12" />),
|
||||
[ICONS.DRAG]: buildIcon(<path d="m8 18 4 4 4-4M4 14h16M4 10h16M8 6l4-4 4 4" />),
|
||||
[ICONS.DOWN]: buildIcon(<polyline points="6 9 12 15 18 9" />),
|
||||
[ICONS.FULLSCREEN]: buildIcon(
|
||||
<path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" />
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
// @flow
|
||||
import * as React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import remark from 'remark';
|
||||
import remarkAttr from 'remark-attr';
|
||||
import remarkStrip from 'strip-markdown';
|
||||
import remarkEmoji from 'remark-emoji';
|
||||
import remarkBreaks from 'remark-breaks';
|
||||
import remarkFrontMatter from 'remark-frontmatter';
|
||||
import reactRenderer from 'remark-react';
|
||||
import MarkdownLink from 'component/markdownLink';
|
||||
import defaultSchema from 'hast-util-sanitize/lib/github.json';
|
||||
import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS } from 'config';
|
||||
import { formattedLinks, inlineLinks } from 'util/remark-lbry';
|
||||
import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp';
|
||||
import { formattedEmote, inlineEmote } from 'util/remark-emote';
|
||||
import ZoomableImage from 'component/zoomableImage';
|
||||
import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS } from 'config';
|
||||
import Button from 'component/button';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import { parse } from 'node-html-parser';
|
||||
import * as React from 'react';
|
||||
import Button from 'component/button';
|
||||
import classnames from 'classnames';
|
||||
import defaultSchema from 'hast-util-sanitize/lib/github.json';
|
||||
import MarkdownLink from 'component/markdownLink';
|
||||
import OptimizedImage from 'component/optimizedImage';
|
||||
import reactRenderer from 'remark-react';
|
||||
import remark from 'remark';
|
||||
import remarkAttr from 'remark-attr';
|
||||
import remarkBreaks from 'remark-breaks';
|
||||
import remarkEmoji from 'remark-emoji';
|
||||
import remarkFrontMatter from 'remark-frontmatter';
|
||||
import remarkStrip from 'strip-markdown';
|
||||
import ZoomableImage from 'component/zoomableImage';
|
||||
import { parse } from 'node-html-parser';
|
||||
|
||||
const RE_EMOTE = /:\+1:|:-1:|:[\w-]+:/;
|
||||
|
||||
@@ -146,7 +146,7 @@ function isStakeEnoughForPreview(stakedLevel) {
|
||||
// ****************************************************************************
|
||||
// ****************************************************************************
|
||||
|
||||
const MarkdownPreview = (props: MarkdownProps) => {
|
||||
export default React.memo<MarkdownProps>(function MarkdownPreview(props: MarkdownProps) {
|
||||
const {
|
||||
content,
|
||||
strip,
|
||||
@@ -173,15 +173,10 @@ const MarkdownPreview = (props: MarkdownProps) => {
|
||||
if (lbrySrc && lbrySrc.startsWith('lbry://')) {
|
||||
return lbrySrc;
|
||||
}
|
||||
|
||||
return iframeHtml;
|
||||
})
|
||||
: '';
|
||||
|
||||
const initialQuote = strippedContent.split(' ').find((word) => word.length > 0 || word.charAt(0) === '>');
|
||||
let stripQuote;
|
||||
if (initialQuote && initialQuote.charAt(0) === '>') stripQuote = true;
|
||||
|
||||
const remarkOptions: Object = {
|
||||
sanitize: schema,
|
||||
fragment: React.Fragment,
|
||||
@@ -201,7 +196,7 @@ const MarkdownPreview = (props: MarkdownProps) => {
|
||||
div: React.Fragment,
|
||||
img: (imgProps) =>
|
||||
isStakeEnoughForPreview(stakedLevel) && !isEmote(imgProps.title, imgProps.src) ? (
|
||||
ZoomableImage
|
||||
<ZoomableImage {...imgProps} />
|
||||
) : (
|
||||
<SimpleImageLink src={imgProps.src} alt={imgProps.alt} title={imgProps.title} />
|
||||
),
|
||||
@@ -216,22 +211,10 @@ const MarkdownPreview = (props: MarkdownProps) => {
|
||||
};
|
||||
|
||||
// Strip all content and just render text
|
||||
if (strip || stripQuote) {
|
||||
if (strip) {
|
||||
// Remove new lines and extra space
|
||||
remarkOptions.remarkReactComponents.p = SimpleText;
|
||||
return stripQuote ? (
|
||||
<span dir="auto" className="markdown-preview">
|
||||
<blockquote>
|
||||
{
|
||||
remark()
|
||||
.use(remarkStrip)
|
||||
.use(remarkFrontMatter, ['yaml'])
|
||||
.use(reactRenderer, remarkOptions)
|
||||
.processSync(content).contents
|
||||
}
|
||||
</blockquote>
|
||||
</span>
|
||||
) : (
|
||||
return (
|
||||
<span dir="auto" className="markdown-preview">
|
||||
{
|
||||
remark()
|
||||
@@ -267,6 +250,4 @@ const MarkdownPreview = (props: MarkdownProps) => {
|
||||
}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MarkdownPreview;
|
||||
});
|
||||
@@ -1,18 +1,30 @@
|
||||
// @flow
|
||||
import type { Node } from 'react';
|
||||
import React from 'react';
|
||||
import ReachTooltip from '@reach/tooltip';
|
||||
// import '@reach/tooltip/styles.css'; --> 'scss/third-party.scss'
|
||||
import MUITooltip from '@mui/material/Tooltip';
|
||||
import type { Node } from 'react';
|
||||
|
||||
type Props = {
|
||||
label: string | Node,
|
||||
arrow?: boolean,
|
||||
children: Node,
|
||||
disableInteractive?: boolean,
|
||||
enterDelay?: number,
|
||||
title?: string | Node,
|
||||
};
|
||||
|
||||
function Tooltip(props: Props) {
|
||||
const { children, label } = props;
|
||||
const { arrow = true, children, disableInteractive = true, enterDelay = 300, title } = props;
|
||||
|
||||
return <ReachTooltip label={label}>{children}</ReachTooltip>;
|
||||
return (
|
||||
<MUITooltip
|
||||
arrow={arrow}
|
||||
disableInteractive={disableInteractive}
|
||||
enterDelay={enterDelay}
|
||||
enterNextDelay={enterDelay}
|
||||
title={title}
|
||||
>
|
||||
{children}
|
||||
</MUITooltip>
|
||||
);
|
||||
}
|
||||
|
||||
export default Tooltip;
|
||||
@@ -24,6 +24,7 @@ import PdfViewer from 'component/viewers/pdfViewer';
|
||||
type Props = {
|
||||
uri: string,
|
||||
streamingUrl: string,
|
||||
embedded?: boolean,
|
||||
contentType: string,
|
||||
claim: StreamClaim,
|
||||
currentTheme: string,
|
||||
@@ -44,8 +45,9 @@ class FileRender extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { embedded } = this.props;
|
||||
window.addEventListener('keydown', this.escapeListener, true);
|
||||
analytics.playerLoadedEvent();
|
||||
analytics.playerLoadedEvent(embedded);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -144,12 +146,13 @@ class FileRender extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { renderMode, className } = this.props;
|
||||
const { embedded, renderMode, className } = this.props;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classnames('file-render', className, {
|
||||
'file-render--document': RENDER_MODES.TEXT_MODES.includes(renderMode),
|
||||
'file-render--embed': embedded,
|
||||
'file-render--video': renderMode === RENDER_MODES.VIDEO || renderMode === RENDER_MODES.AUDIO,
|
||||
})}
|
||||
>
|
||||
|
||||
@@ -17,6 +17,10 @@ import { useHistory } from 'react-router';
|
||||
import { isURIEqual } from 'util/lbryURI';
|
||||
import AutoplayCountdown from 'component/autoplayCountdown';
|
||||
|
||||
// scss/init/vars.scss
|
||||
// --header-height
|
||||
const HEADER_HEIGHT = 64;
|
||||
|
||||
const IS_DESKTOP_MAC = typeof process === 'object' ? process.platform === 'darwin' : false;
|
||||
const DEBOUNCE_WINDOW_RESIZE_HANDLER_MS = 100;
|
||||
export const INLINE_PLAYER_WRAPPER_CLASS = 'inline-player__wrapper';
|
||||
@@ -351,8 +355,7 @@ export default function FileRenderFloating(props: Props) {
|
||||
width: fileViewerRect.width,
|
||||
height: fileViewerRect.height,
|
||||
left: fileViewerRect.x,
|
||||
// 80px is header height in scss/init/vars.scss
|
||||
top: fileViewerRect.windowOffset + fileViewerRect.top - 80 - (IS_DESKTOP_MAC ? 24 : 0),
|
||||
top: fileViewerRect.windowOffset + fileViewerRect.top - HEADER_HEIGHT - (IS_DESKTOP_MAC ? 24 : 0),
|
||||
}
|
||||
: {}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doCollectionEdit } from 'redux/actions/collections';
|
||||
import { makeSelectCollectionForIdHasClaimUrl } from 'redux/selectors/collections';
|
||||
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import * as COLLECTIONS_CONSTS from 'constants/collections';
|
||||
import FileWatchLaterLink from './view';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
|
||||
const select = (state, props) => {
|
||||
const claim = makeSelectClaimForUri(props.uri)(state);
|
||||
const permanentUri = claim && claim.permanent_url;
|
||||
const { uri } = props;
|
||||
|
||||
return {
|
||||
claim,
|
||||
hasClaimInWatchLater: makeSelectCollectionForIdHasClaimUrl(COLLECTIONS_CONSTS.WATCH_LATER_ID, permanentUri)(state),
|
||||
hasClaimInWatchLater: makeSelectCollectionForIdHasClaimUrl(COLLECTIONS_CONSTS.WATCH_LATER_ID, uri)(state),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as COLLECTIONS_CONSTS from 'constants/collections';
|
||||
|
||||
type Props = {
|
||||
uri: string,
|
||||
claim: StreamClaim,
|
||||
focusable: boolean,
|
||||
hasClaimInWatchLater: boolean,
|
||||
doToast: ({ message: string }) => void,
|
||||
@@ -15,14 +14,10 @@ type Props = {
|
||||
};
|
||||
|
||||
function FileWatchLaterLink(props: Props) {
|
||||
const { claim, hasClaimInWatchLater, doToast, doCollectionEdit, focusable = true } = props;
|
||||
const { uri, hasClaimInWatchLater, doToast, doCollectionEdit, focusable = true } = props;
|
||||
const buttonRef = useRef();
|
||||
let isHovering = useHover(buttonRef);
|
||||
|
||||
if (!claim) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function handleWatchLater(e) {
|
||||
e.preventDefault();
|
||||
doToast({
|
||||
@@ -31,7 +26,7 @@ function FileWatchLaterLink(props: Props) {
|
||||
linkTarget: !hasClaimInWatchLater && '/list/watchlater',
|
||||
});
|
||||
doCollectionEdit(COLLECTIONS_CONSTS.WATCH_LATER_ID, {
|
||||
claims: [claim],
|
||||
uris: [uri],
|
||||
remove: hasClaimInWatchLater,
|
||||
type: 'playlist',
|
||||
});
|
||||
|
||||
@@ -1,42 +1,31 @@
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { connect } from 'react-redux';
|
||||
import { selectTotalBalance, selectBalance } from 'redux/selectors/wallet';
|
||||
import { formatCredits } from 'util/format-credits';
|
||||
import { selectGetSyncErrorMessage } from 'redux/selectors/sync';
|
||||
import { selectUserVerifiedEmail, selectUserEmail, selectEmailToVerify, selectUser } from 'redux/selectors/user';
|
||||
import { doClearEmailEntry, doClearPasswordEntry } from 'redux/actions/user';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { doSignOut, doOpenModal } from 'redux/actions/app';
|
||||
import { makeSelectClientSetting, selectLanguage } from 'redux/selectors/settings';
|
||||
import { selectHasNavigated, selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { doSignOut } from 'redux/actions/app';
|
||||
import { formatCredits } from 'util/format-credits';
|
||||
import { selectClientSetting } from 'redux/selectors/settings';
|
||||
import { selectGetSyncErrorMessage } from 'redux/selectors/sync';
|
||||
import { selectHasNavigated } from 'redux/selectors/app';
|
||||
import { selectTotalBalance, selectBalance } from 'redux/selectors/wallet';
|
||||
import { selectUserVerifiedEmail, selectEmailToVerify, selectUser } from 'redux/selectors/user';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import Header from './view';
|
||||
import { selectMyChannelClaims } from 'redux/selectors/claims';
|
||||
|
||||
const select = (state) => ({
|
||||
language: selectLanguage(state),
|
||||
balance: selectBalance(state),
|
||||
roundedSpendableBalance: formatCredits(selectBalance(state), 2, true),
|
||||
roundedBalance: formatCredits(selectTotalBalance(state), 2, true),
|
||||
currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state),
|
||||
automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state),
|
||||
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
|
||||
authenticated: selectUserVerifiedEmail(state),
|
||||
email: selectUserEmail(state),
|
||||
syncError: selectGetSyncErrorMessage(state),
|
||||
balance: selectBalance(state),
|
||||
emailToVerify: selectEmailToVerify(state),
|
||||
hasNavigated: selectHasNavigated(state),
|
||||
hideBalance: selectClientSetting(state, SETTINGS.HIDE_BALANCE),
|
||||
roundedBalance: formatCredits(selectTotalBalance(state), 2, true),
|
||||
roundedSpendableBalance: formatCredits(selectBalance(state), 2, true),
|
||||
syncError: selectGetSyncErrorMessage(state),
|
||||
user: selectUser(state),
|
||||
activeChannelClaim: selectActiveChannelClaim(state),
|
||||
myChannels: selectMyChannelClaims(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
setClientSetting: (key, value, push) => dispatch(doSetClientSetting(key, value, push)),
|
||||
signOut: () => dispatch(doSignOut()),
|
||||
openSignOutModal: () => dispatch(doOpenModal(MODALS.SIGN_OUT)),
|
||||
clearEmailEntry: () => dispatch(doClearEmailEntry()),
|
||||
clearPasswordEntry: () => dispatch(doClearPasswordEntry()),
|
||||
signOut: () => dispatch(doSignOut()),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(Header);
|
||||
+173
-351
@@ -1,47 +1,25 @@
|
||||
// @flow
|
||||
import { ENABLE_UI_NOTIFICATIONS } from 'config';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import React from 'react';
|
||||
import { withRouter } from 'react-router';
|
||||
import classnames from 'classnames';
|
||||
import Button from 'component/button';
|
||||
import WunderBar from 'component/wunderbar';
|
||||
import Icon from 'component/common/icon';
|
||||
import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button';
|
||||
import NavigationButton from 'component/navigationButton';
|
||||
// import 'scss/component/_header.scss'; // ody codesplits this. no.
|
||||
|
||||
import { useIsMobile } from 'effects/use-screensize';
|
||||
import NotificationBubble from 'component/notificationBubble';
|
||||
import NotificationHeaderButton from 'component/notificationHeaderButton';
|
||||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
import SkipNavigationButton from 'component/skipNavigationButton';
|
||||
import { withRouter } from 'react-router';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import Button from 'component/button';
|
||||
import classnames from 'classnames';
|
||||
import HeaderMenuButtons from 'component/headerMenuButtons';
|
||||
import HeaderProfileMenuButton from 'component/headerProfileMenuButton';
|
||||
import Logo from 'component/logo';
|
||||
import NotificationBubble from 'component/notificationBubble';
|
||||
import React from 'react';
|
||||
import SkipNavigationButton from 'component/skipNavigationButton';
|
||||
import Tooltip from 'component/common/tooltip';
|
||||
import WunderBar from 'component/wunderbar';
|
||||
import * as remote from '@electron/remote';
|
||||
import { IS_MAC } from 'component/app/view';
|
||||
import NavigationButton from 'component/navigationButton';
|
||||
|
||||
type Props = {
|
||||
user: ?User,
|
||||
balance: string,
|
||||
balance: number,
|
||||
roundedBalance: string,
|
||||
roundedSpendableBalance: string,
|
||||
history: {
|
||||
entities: {}[],
|
||||
goBack: () => void,
|
||||
goForward: () => void,
|
||||
index: number,
|
||||
length: number,
|
||||
location: { pathname: string },
|
||||
push: (string) => void,
|
||||
replace: (string) => void,
|
||||
},
|
||||
currentTheme: string,
|
||||
automaticDarkModeEnabled: boolean,
|
||||
setClientSetting: (string, boolean | string, ?boolean) => void,
|
||||
hideBalance: boolean,
|
||||
email: ?string,
|
||||
authenticated: boolean,
|
||||
authHeader: boolean,
|
||||
backout: {
|
||||
backLabel?: string,
|
||||
@@ -49,147 +27,135 @@ type Props = {
|
||||
title: string,
|
||||
simpleTitle: string, // Just use the same value as `title` if `title` is already short (~< 10 chars), unless you have a better idea for title overlfow on mobile
|
||||
},
|
||||
syncError: ?string,
|
||||
balance: number,
|
||||
emailToVerify?: string,
|
||||
signOut: () => void,
|
||||
openSignOutModal: () => void,
|
||||
hasNavigated: boolean,
|
||||
hideBalance: boolean,
|
||||
hideCancel: boolean,
|
||||
history: {
|
||||
goBack: () => void,
|
||||
location: { pathname: string },
|
||||
push: (string) => void,
|
||||
replace: (string) => void,
|
||||
},
|
||||
isAbsoluteSideNavHidden: boolean,
|
||||
roundedBalance: string,
|
||||
roundedSpendableBalance: string,
|
||||
sidebarOpen: boolean,
|
||||
syncError: ?string,
|
||||
clearEmailEntry: () => void,
|
||||
clearPasswordEntry: () => void,
|
||||
hasNavigated: boolean,
|
||||
sidebarOpen: boolean,
|
||||
setSidebarOpen: (boolean) => void,
|
||||
isAbsoluteSideNavHidden: boolean,
|
||||
hideCancel: boolean,
|
||||
activeChannelClaim: ?ChannelClaim,
|
||||
myChannels: ?Array<ChannelClaim>,
|
||||
signOut: () => void,
|
||||
};
|
||||
|
||||
const Header = (props: Props) => {
|
||||
const {
|
||||
authHeader,
|
||||
backout,
|
||||
balance,
|
||||
emailToVerify,
|
||||
hideBalance,
|
||||
hideCancel,
|
||||
history,
|
||||
isAbsoluteSideNavHidden,
|
||||
roundedBalance,
|
||||
roundedSpendableBalance,
|
||||
history,
|
||||
setClientSetting,
|
||||
currentTheme,
|
||||
automaticDarkModeEnabled,
|
||||
hideBalance,
|
||||
email,
|
||||
authenticated,
|
||||
authHeader,
|
||||
signOut,
|
||||
sidebarOpen,
|
||||
syncError,
|
||||
openSignOutModal,
|
||||
clearEmailEntry,
|
||||
clearPasswordEntry,
|
||||
emailToVerify,
|
||||
backout,
|
||||
sidebarOpen,
|
||||
setSidebarOpen,
|
||||
isAbsoluteSideNavHidden,
|
||||
hideCancel,
|
||||
user,
|
||||
activeChannelClaim,
|
||||
myChannels,
|
||||
signOut,
|
||||
} = props;
|
||||
|
||||
const {
|
||||
location: { pathname },
|
||||
goBack,
|
||||
push,
|
||||
} = history;
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
// on the verify page don't let anyone escape other than by closing the tab to keep session data consistent
|
||||
const isVerifyPage = history.location.pathname.includes(PAGES.AUTH_VERIFY);
|
||||
const isSignUpPage = history.location.pathname.includes(PAGES.AUTH);
|
||||
const isSignInPage = history.location.pathname.includes(PAGES.AUTH_SIGNIN);
|
||||
const isPwdResetPage = history.location.pathname.includes(PAGES.AUTH_PASSWORD_RESET);
|
||||
const hasBackout = Boolean(backout);
|
||||
const isVerifyPage = pathname.includes(PAGES.AUTH_VERIFY);
|
||||
const isSignUpPage = pathname.includes(PAGES.AUTH);
|
||||
const isSignInPage = pathname.includes(PAGES.AUTH_SIGNIN);
|
||||
const isPwdResetPage = pathname.includes(PAGES.AUTH_PASSWORD_RESET);
|
||||
|
||||
// For pages that allow for "backing out", shows a backout option instead of the Home logo
|
||||
const canBackout = Boolean(backout);
|
||||
const { backLabel, backNavDefault, title: backTitle, simpleTitle: simpleBackTitle } = backout || {};
|
||||
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
||||
const activeChannelUrl = activeChannelClaim && activeChannelClaim.permanent_url;
|
||||
const hasChannels = myChannels && myChannels.length > 0;
|
||||
|
||||
// Sign out if they click the "x" when they are on the password prompt
|
||||
const authHeaderAction = syncError ? { onClick: signOut } : { navigate: '/' };
|
||||
const homeButtonNavigationProps = isVerifyPage ? {} : authHeader ? authHeaderAction : { navigate: '/' };
|
||||
const closeButtonNavigationProps = {
|
||||
onClick: () => {
|
||||
clearEmailEntry();
|
||||
clearPasswordEntry();
|
||||
const authHeaderAction = syncError && { onClick: signOut };
|
||||
const homeButtonNavigationProps = (isVerifyPage && {}) || (authHeader && authHeaderAction) || { navigate: '/' };
|
||||
const sidebarLabel = sidebarOpen
|
||||
? __('Close sidebar - hide channels you are following.')
|
||||
: __('Expand sidebar - view channels you are following.');
|
||||
|
||||
if (syncError) {
|
||||
signOut();
|
||||
}
|
||||
const onBackout = React.useCallback(
|
||||
(e: any) => {
|
||||
const { hasNavigated } = props;
|
||||
const { replace } = history;
|
||||
|
||||
if (isSignInPage && !emailToVerify) {
|
||||
history.goBack();
|
||||
} else if (isSignUpPage) {
|
||||
history.goBack();
|
||||
} else if (isPwdResetPage) {
|
||||
history.goBack();
|
||||
} else {
|
||||
history.push('/');
|
||||
window.removeEventListener('popstate', onBackout);
|
||||
|
||||
if (e.type !== 'popstate') {
|
||||
// if not initiated by pop (back button)
|
||||
if (hasNavigated && !backNavDefault) {
|
||||
goBack();
|
||||
} else {
|
||||
replace(backNavDefault || `/`);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function onBackout(e) {
|
||||
const { history, hasNavigated } = props;
|
||||
const { goBack, replace } = history;
|
||||
|
||||
window.removeEventListener('popstate', onBackout);
|
||||
|
||||
if (e.type !== 'popstate') {
|
||||
// if not initiated by pop (back button)
|
||||
if (hasNavigated && !backNavDefault) {
|
||||
goBack();
|
||||
} else {
|
||||
replace(backNavDefault || `/`);
|
||||
}
|
||||
}
|
||||
}
|
||||
[backNavDefault, goBack, history, props]
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (hasBackout) {
|
||||
if (canBackout) {
|
||||
window.addEventListener('popstate', onBackout);
|
||||
return () => window.removeEventListener('popstate', onBackout);
|
||||
}
|
||||
}, [hasBackout]);
|
||||
}, [canBackout, onBackout]);
|
||||
|
||||
function handleThemeToggle() {
|
||||
if (automaticDarkModeEnabled) {
|
||||
setClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED, false);
|
||||
}
|
||||
const userButtons = (hideWallet?: boolean, hideProfile?: boolean) => (
|
||||
<div className="header__menu--right">
|
||||
<Tooltip
|
||||
title={
|
||||
balance > 0
|
||||
? __('Immediately spendable: %spendable_balance%', { spendable_balance: roundedSpendableBalance })
|
||||
: __('Your Wallet')
|
||||
}
|
||||
>
|
||||
<div>
|
||||
<Button
|
||||
// title={
|
||||
// balance > 0
|
||||
// ? __('Immediately spendable: %spendable_balance%', { spendable_balance: roundedSpendableBalance })
|
||||
// : __('Your Wallet')
|
||||
// }
|
||||
navigate={`/$/${PAGES.WALLET}`}
|
||||
className="button--file-action header__navigationItem--balance"
|
||||
label={hideBalance || Number(roundedBalance) === 0 ? __('Your Wallet') : roundedBalance}
|
||||
icon={ICONS.LBC}
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Tooltip>
|
||||
|
||||
if (currentTheme === 'dark') {
|
||||
setClientSetting(SETTINGS.THEME, 'light', true);
|
||||
} else {
|
||||
setClientSetting(SETTINGS.THEME, 'dark', true);
|
||||
}
|
||||
}
|
||||
|
||||
type BalanceButtonProps = { className: string };
|
||||
const BalanceButton = (balanceButtonProps: BalanceButtonProps) => (
|
||||
<Button
|
||||
title={
|
||||
balance > 0
|
||||
? __('Immediately spendable: %spendable_balance%', { spendable_balance: roundedSpendableBalance })
|
||||
: __('Your Wallet')
|
||||
}
|
||||
navigate={`/$/${PAGES.WALLET}`}
|
||||
className={classnames(balanceButtonProps.className, 'header__navigation-item--balance')}
|
||||
label={hideBalance || Number(roundedBalance) === 0 ? __('Your Wallet') : roundedBalance}
|
||||
icon={ICONS.LBC}
|
||||
// @if TARGET='app'
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
// @endif
|
||||
/>
|
||||
<HeaderProfileMenuButton />
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<header
|
||||
className={classnames('header', {
|
||||
'header--minimal': authHeader,
|
||||
// @if TARGET='app'
|
||||
'header--mac': IS_MAC,
|
||||
// @endif
|
||||
})}
|
||||
// @if TARGET='app'
|
||||
onDoubleClick={(e) => {
|
||||
@@ -197,159 +163,88 @@ const Header = (props: Props) => {
|
||||
}}
|
||||
// @endif
|
||||
>
|
||||
<div className="header__contents">
|
||||
{!authHeader && backout ? (
|
||||
<div className="card__actions--between">
|
||||
<Button
|
||||
onClick={onBackout}
|
||||
button="link"
|
||||
label={(backLabel && backLabel) || __('Cancel')}
|
||||
icon={ICONS.ARROW_LEFT}
|
||||
/>
|
||||
{backTitle && <h1 className="header__auth-title">{isMobile ? simpleBackTitle || backTitle : backTitle}</h1>}
|
||||
<BalanceButton className="header__navigation-item menu__title" />
|
||||
</div>
|
||||
<div className="card__actions--between header__contents">
|
||||
{!authHeader && canBackout ? (
|
||||
<>
|
||||
<div className="header__menu--left">
|
||||
<Button onClick={onBackout} button="link" label={backLabel || __('Cancel')} icon={ICONS.ARROW_LEFT} />
|
||||
</div>
|
||||
{backTitle && <h1 className="header__authTitle">{(isMobile && simpleBackTitle) || backTitle}</h1>}
|
||||
{userButtons(false, isMobile)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div className="header__navigation">
|
||||
<SkipNavigationButton />
|
||||
{!authHeader && (
|
||||
<span style={{ position: 'relative' }}>
|
||||
<Button
|
||||
aria-label={
|
||||
sidebarOpen
|
||||
? __('Close sidebar - hide channels you are following.')
|
||||
: __('Expand sidebar - view channels you are following.')
|
||||
}
|
||||
className="header__navigation-item menu__title header__navigation-item--icon"
|
||||
icon={ICONS.MENU}
|
||||
aria-expanded={sidebarOpen}
|
||||
onClick={() => setSidebarOpen(!sidebarOpen)}
|
||||
>
|
||||
{isAbsoluteSideNavHidden && isMobile && notificationsEnabled && <NotificationBubble />}
|
||||
</Button>
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
aria-label={__('Home')}
|
||||
className="header__navigation-item header__navigation-item--lbry"
|
||||
onClick={() => {
|
||||
// here use state.router.location.pathname
|
||||
if (history.location.pathname === '/') window.location.reload();
|
||||
}}
|
||||
// @if TARGET='app'
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
// @endif
|
||||
{...homeButtonNavigationProps}
|
||||
>
|
||||
<Logo />
|
||||
</Button>
|
||||
<div className="header__menu--left">
|
||||
<SkipNavigationButton />
|
||||
{!authHeader && (
|
||||
<span style={{ position: 'relative' }}>
|
||||
<Button
|
||||
aria-label={sidebarLabel}
|
||||
className="header__navigationItem--icon"
|
||||
icon={ICONS.MENU}
|
||||
aria-expanded={sidebarOpen}
|
||||
onClick={() => setSidebarOpen(!sidebarOpen)}
|
||||
>
|
||||
{isAbsoluteSideNavHidden && isMobile && <NotificationBubble />}
|
||||
</Button>
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
aria-label={__('Home')}
|
||||
className="header__navigationItem--logo"
|
||||
onClick={() => {
|
||||
// here use state.router.location.pathname
|
||||
if (history.location.pathname === '/') window.location.reload();
|
||||
}}
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
{...homeButtonNavigationProps}
|
||||
>
|
||||
<Logo />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{!authHeader && (
|
||||
<div className="header__center">
|
||||
{/* @if TARGET='app' */}
|
||||
{!authHeader && (
|
||||
<div className="header__buttons">
|
||||
<NavigationButton isBackward history={history} />
|
||||
<NavigationButton isBackward={false} history={history} />
|
||||
</div>
|
||||
)}
|
||||
{/* @endif */}
|
||||
|
||||
{!authHeader && <WunderBar />}
|
||||
|
||||
<HeaderMenuButtons
|
||||
authenticated={authenticated}
|
||||
notificationsEnabled={notificationsEnabled}
|
||||
history={history}
|
||||
handleThemeToggle={handleThemeToggle}
|
||||
currentTheme={currentTheme}
|
||||
/>
|
||||
<WunderBar />
|
||||
<HeaderMenuButtons />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!authHeader && !canBackout
|
||||
? userButtons(isMobile)
|
||||
: !isVerifyPage &&
|
||||
!hideCancel && (
|
||||
<div className="header__menu--right">
|
||||
<Button
|
||||
title={__('Go Back')}
|
||||
button="alt"
|
||||
// className="button--header-close"
|
||||
icon={ICONS.REMOVE}
|
||||
onClick={() => {
|
||||
clearEmailEntry();
|
||||
clearPasswordEntry();
|
||||
|
||||
if (syncError) signOut();
|
||||
|
||||
if ((isSignInPage && !emailToVerify) || isSignUpPage || isPwdResetPage) {
|
||||
goBack();
|
||||
} else {
|
||||
push('/');
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{!authHeader && !backout ? (
|
||||
<div className={classnames('header__menu', 'header__menu--with-balance')}>
|
||||
<BalanceButton className="header__navigation-item menu__title mobile-hidden" />
|
||||
<Menu>
|
||||
<MenuButton
|
||||
aria-label={__('Your account')}
|
||||
title={__('Your account')}
|
||||
className={classnames('header__navigation-item', {
|
||||
'menu__title header__navigation-item--icon': !activeChannelUrl,
|
||||
'header__navigation-item--profile-pic': activeChannelUrl,
|
||||
})}
|
||||
// @if TARGET='app'
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
// @endif
|
||||
>
|
||||
{activeChannelUrl ? (
|
||||
<ChannelThumbnail uri={activeChannelUrl} small noLazyLoad />
|
||||
) : (
|
||||
<Icon size={18} icon={ICONS.ACCOUNT} aria-hidden />
|
||||
)}
|
||||
</MenuButton>
|
||||
<MenuList className="menu__list--header">
|
||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.UPLOADS}`)}>
|
||||
<Icon aria-hidden icon={ICONS.PUBLISH} />
|
||||
{__('Uploads')}
|
||||
</MenuItem>
|
||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.CHANNELS}`)}>
|
||||
<Icon aria-hidden icon={ICONS.CHANNEL} />
|
||||
{__('Channels')}
|
||||
</MenuItem>
|
||||
{hasChannels && authenticated && (
|
||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.CREATOR_DASHBOARD}`)}>
|
||||
<Icon aria-hidden icon={ICONS.ANALYTICS} />
|
||||
{__('Creator Analytics')}
|
||||
</MenuItem>
|
||||
)}
|
||||
{authenticated ? (
|
||||
<MenuItem onSelect={openSignOutModal}>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.SIGN_OUT} />
|
||||
{__('Sign Out')}
|
||||
</div>
|
||||
<span className="menu__link-help">{email}</span>
|
||||
</MenuItem>
|
||||
) : (
|
||||
<>
|
||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.AUTH_SIGNIN}`)}>
|
||||
<Icon aria-hidden icon={ICONS.SIGN_IN} />
|
||||
{__('Cloud Connect')}
|
||||
</MenuItem>
|
||||
</>
|
||||
)}
|
||||
</MenuList>
|
||||
</Menu>
|
||||
</div>
|
||||
) : (
|
||||
!isVerifyPage &&
|
||||
!hideCancel && (
|
||||
<div className="header__menu">
|
||||
{/* Add an empty span here so we can use the same style as above */}
|
||||
{/* This pushes the close button to the right side */}
|
||||
<span />
|
||||
|
||||
<Button
|
||||
title={__('Go Back')}
|
||||
button="alt"
|
||||
// className="button--header-close"
|
||||
icon={ICONS.REMOVE}
|
||||
{...closeButtonNavigationProps}
|
||||
// @if TARGET='app'
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
// @endif
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
@@ -357,77 +252,4 @@ const Header = (props: Props) => {
|
||||
);
|
||||
};
|
||||
|
||||
type HeaderMenuButtonProps = {
|
||||
authenticated: boolean,
|
||||
notificationsEnabled: boolean,
|
||||
history: { push: (string) => void },
|
||||
handleThemeToggle: (string) => void,
|
||||
currentTheme: string,
|
||||
};
|
||||
|
||||
function HeaderMenuButtons(props: HeaderMenuButtonProps) {
|
||||
const { notificationsEnabled, history, handleThemeToggle, currentTheme } = props;
|
||||
|
||||
return (
|
||||
<div className="header__buttons">
|
||||
<Menu>
|
||||
<MenuButton
|
||||
aria-label={__('Publish a file, or create a channel')}
|
||||
title={__('Publish a file, or create a channel')}
|
||||
className="header__navigation-item menu__title header__navigation-item--icon mobile-hidden"
|
||||
// @if TARGET='app'
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
// @endif
|
||||
>
|
||||
<Icon size={18} icon={ICONS.PUBLISH} aria-hidden />
|
||||
</MenuButton>
|
||||
|
||||
<MenuList className="menu__list--header">
|
||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.UPLOAD}`)}>
|
||||
<Icon aria-hidden icon={ICONS.PUBLISH} />
|
||||
{__('Upload')}
|
||||
</MenuItem>
|
||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.CHANNEL_NEW}`)}>
|
||||
<Icon aria-hidden icon={ICONS.CHANNEL} />
|
||||
{__('New Channel')}
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
|
||||
{notificationsEnabled && <NotificationHeaderButton />}
|
||||
|
||||
<Menu>
|
||||
<MenuButton
|
||||
aria-label={__('Settings')}
|
||||
title={__('Settings')}
|
||||
className="header__navigation-item menu__title header__navigation-item--icon mobile-hidden"
|
||||
// @if TARGET='app'
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
// @endif
|
||||
>
|
||||
<Icon size={18} icon={ICONS.SETTINGS} aria-hidden />
|
||||
</MenuButton>
|
||||
<MenuList className="menu__list--header">
|
||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.SETTINGS}`)}>
|
||||
<Icon aria-hidden tooltip icon={ICONS.SETTINGS} />
|
||||
{__('Settings')}
|
||||
</MenuItem>
|
||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.HELP}`)}>
|
||||
<Icon aria-hidden icon={ICONS.HELP} />
|
||||
{__('Help')}
|
||||
</MenuItem>
|
||||
<MenuItem className="menu__link" onSelect={handleThemeToggle}>
|
||||
<Icon icon={currentTheme === 'light' ? ICONS.DARK : ICONS.LIGHT} />
|
||||
{currentTheme === 'light' ? __('Dark') : __('Light')}
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default withRouter(Header);
|
||||
@@ -0,0 +1,24 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { selectActiveChannelStakedLevel } from 'redux/selectors/app';
|
||||
import { selectClientSetting } from 'redux/selectors/settings';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import HeaderMenuButtons from './view';
|
||||
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
|
||||
|
||||
const select = (state) => ({
|
||||
activeChannelStakedLevel: selectActiveChannelStakedLevel(state),
|
||||
authenticated: selectUserVerifiedEmail(state),
|
||||
automaticDarkModeEnabled: selectClientSetting(state, SETTINGS.AUTOMATIC_DARK_MODE_ENABLED),
|
||||
currentTheme: selectClientSetting(state, SETTINGS.THEME),
|
||||
user: selectUser(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
handleThemeToggle: (automaticDarkModeEnabled, currentTheme) => {
|
||||
if (automaticDarkModeEnabled) dispatch(doSetClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED, false));
|
||||
dispatch(doSetClientSetting(SETTINGS.THEME, currentTheme === 'dark' ? 'light' : 'dark', true));
|
||||
},
|
||||
});
|
||||
|
||||
export default connect(select, perform)(HeaderMenuButtons);
|
||||
@@ -0,0 +1,63 @@
|
||||
// @flow
|
||||
// import 'scss/component/_header.scss'; // ody codesplits this; no.
|
||||
|
||||
import { ENABLE_UI_NOTIFICATIONS } from 'config';
|
||||
import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import HeaderMenuLink from 'component/common/header-menu-link';
|
||||
import Icon from 'component/common/icon';
|
||||
import NotificationHeaderButton from 'component/headerNotificationButton';
|
||||
import React from 'react';
|
||||
import Tooltip from 'component/common/tooltip';
|
||||
|
||||
type HeaderMenuButtonProps = {
|
||||
authenticated: boolean,
|
||||
automaticDarkModeEnabled: boolean,
|
||||
currentTheme: string,
|
||||
user: ?User,
|
||||
handleThemeToggle: (boolean, string) => void,
|
||||
};
|
||||
|
||||
export default function HeaderMenuButtons(props: HeaderMenuButtonProps) {
|
||||
const { automaticDarkModeEnabled, currentTheme, user, handleThemeToggle } = props;
|
||||
|
||||
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
||||
|
||||
return (
|
||||
<div className="header__buttons">
|
||||
<Menu>
|
||||
<Tooltip title={__('Publish a file, or create a channel')}>
|
||||
<MenuButton className="header__navigationItem--icon">
|
||||
<Icon size={18} icon={ICONS.PUBLISH} aria-hidden />
|
||||
</MenuButton>
|
||||
</Tooltip>
|
||||
|
||||
<MenuList className="menu__list--header">
|
||||
<HeaderMenuLink page={PAGES.UPLOAD} icon={ICONS.PUBLISH} name={__('Upload')} />
|
||||
<HeaderMenuLink page={PAGES.CHANNEL_NEW} icon={ICONS.CHANNEL} name={__('New Channel')} />
|
||||
</MenuList>
|
||||
</Menu>
|
||||
|
||||
{notificationsEnabled && <NotificationHeaderButton />}
|
||||
|
||||
<Menu>
|
||||
<Tooltip title={__('Settings')}>
|
||||
<MenuButton className="header__navigationItem--icon">
|
||||
<Icon size={18} icon={ICONS.SETTINGS} aria-hidden />
|
||||
</MenuButton>
|
||||
</Tooltip>
|
||||
|
||||
<MenuList className="menu__list--header">
|
||||
<HeaderMenuLink page={PAGES.SETTINGS} icon={ICONS.SETTINGS} name={__('Settings')} />
|
||||
<HeaderMenuLink page={PAGES.HELP} icon={ICONS.HELP} name={__('Help')} />
|
||||
|
||||
<MenuItem className="menu__link" onSelect={() => handleThemeToggle(automaticDarkModeEnabled, currentTheme)}>
|
||||
<Icon icon={currentTheme === 'light' ? ICONS.DARK : ICONS.LIGHT} />
|
||||
{currentTheme === 'light' ? __('Dark') : __('Light')}
|
||||
</MenuItem>
|
||||
</MenuList>
|
||||
</Menu>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+2
-8
@@ -1,16 +1,10 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
selectNotifications,
|
||||
selectIsFetchingNotifications,
|
||||
selectUnseenNotificationCount,
|
||||
} from 'redux/selectors/notifications';
|
||||
import { selectUnseenNotificationCount } from 'redux/selectors/notifications';
|
||||
import { doSeeAllNotifications } from 'redux/actions/notifications';
|
||||
import { selectUser } from 'redux/selectors/user';
|
||||
import NotificationHeaderButton from './view';
|
||||
|
||||
const select = state => ({
|
||||
notifications: selectNotifications(state),
|
||||
fetching: selectIsFetchingNotifications(state),
|
||||
const select = (state) => ({
|
||||
unseenCount: selectUnseenNotificationCount(state),
|
||||
user: selectUser(state),
|
||||
});
|
||||
+20
-30
@@ -1,51 +1,41 @@
|
||||
// @flow
|
||||
import * as PAGES from 'constants/pages';
|
||||
// import 'scss/component/_header.scss'; // ody codesplits this; no. REMOVE THESE
|
||||
|
||||
import { ENABLE_UI_NOTIFICATIONS } from 'config';
|
||||
import { useHistory } from 'react-router';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import React from 'react';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import Button from 'component/button';
|
||||
import Icon from 'component/common/icon';
|
||||
import NotificationBubble from 'component/notificationBubble';
|
||||
import Button from 'component/button';
|
||||
import { useHistory } from 'react-router';
|
||||
import { ENABLE_UI_NOTIFICATIONS } from 'config';
|
||||
import React from 'react';
|
||||
import Tooltip from 'component/common/tooltip';
|
||||
|
||||
type Props = {
|
||||
unseenCount: number,
|
||||
doSeeAllNotifications: () => void,
|
||||
user: ?User,
|
||||
doSeeAllNotifications: () => void,
|
||||
};
|
||||
|
||||
export default function NotificationHeaderButton(props: Props) {
|
||||
const {
|
||||
unseenCount,
|
||||
// notifications,
|
||||
// fetching,
|
||||
doSeeAllNotifications,
|
||||
user,
|
||||
} = props;
|
||||
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
||||
const { unseenCount, user, doSeeAllNotifications } = props;
|
||||
|
||||
const { push } = useHistory();
|
||||
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
||||
|
||||
function handleMenuClick() {
|
||||
if (unseenCount > 0) {
|
||||
doSeeAllNotifications();
|
||||
}
|
||||
|
||||
if (unseenCount > 0) doSeeAllNotifications();
|
||||
push(`/$/${PAGES.NOTIFICATIONS}`);
|
||||
}
|
||||
|
||||
if (!notificationsEnabled) {
|
||||
return null;
|
||||
}
|
||||
if (!notificationsEnabled) return null;
|
||||
|
||||
return (
|
||||
<Button
|
||||
onClick={handleMenuClick}
|
||||
aria-label={__('Notifications')}
|
||||
title={__('Notifications')}
|
||||
className="header__navigation-item menu__title header__navigation-item--icon mobile-hidden"
|
||||
>
|
||||
<Icon size={18} icon={ICONS.NOTIFICATION} aria-hidden />
|
||||
<NotificationBubble />
|
||||
</Button>
|
||||
<Tooltip title={__('Notifications')}>
|
||||
<Button onClick={handleMenuClick} className="header__navigationItem--icon">
|
||||
<Icon size={18} icon={ICONS.NOTIFICATION} aria-hidden />
|
||||
<NotificationBubble />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { selectUserEmail, selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
import HeaderProfileMenuButton from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
activeChannelClaim: selectActiveChannelClaim(state),
|
||||
email: selectUserEmail(state),
|
||||
authenticated: selectUserVerifiedEmail(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
openSignOutModal: () => dispatch(doOpenModal(MODALS.SIGN_OUT)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(HeaderProfileMenuButton);
|
||||
@@ -0,0 +1,63 @@
|
||||
// @flow
|
||||
// import 'scss/component/_header.scss'; // REMOVE!
|
||||
|
||||
import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
import classnames from 'classnames';
|
||||
import HeaderMenuLink from 'component/common/header-menu-link';
|
||||
import Icon from 'component/common/icon';
|
||||
import React from 'react';
|
||||
|
||||
type HeaderMenuButtonProps = {
|
||||
activeChannelClaim: ?ChannelClaim,
|
||||
email: ?string,
|
||||
authenticated: boolean,
|
||||
openSignOutModal: () => void,
|
||||
};
|
||||
|
||||
export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) {
|
||||
const { activeChannelClaim, email, openSignOutModal, authenticated } = props;
|
||||
|
||||
const activeChannelUrl = activeChannelClaim && activeChannelClaim.permanent_url;
|
||||
|
||||
return (
|
||||
<div className="header__buttons">
|
||||
<Menu>
|
||||
<MenuButton
|
||||
aria-label={__('Your account')}
|
||||
title={__('Your account')}
|
||||
className={classnames('header__navigationItem', {
|
||||
'header__navigationItem--icon': !activeChannelUrl,
|
||||
'header__navigationItem--profilePic': activeChannelUrl,
|
||||
})}
|
||||
>
|
||||
{activeChannelUrl ? (
|
||||
<ChannelThumbnail uri={activeChannelUrl} small noLazyLoad />
|
||||
) : (
|
||||
<Icon size={18} icon={ICONS.ACCOUNT} aria-hidden />
|
||||
)}
|
||||
</MenuButton>
|
||||
|
||||
<MenuList className="menu__list--header">
|
||||
<HeaderMenuLink page={PAGES.UPLOADS} icon={ICONS.PUBLISH} name={__('Uploads')} />
|
||||
<HeaderMenuLink page={PAGES.CHANNELS} icon={ICONS.CHANNEL} name={__('Channels')} />
|
||||
<HeaderMenuLink page={PAGES.CREATOR_DASHBOARD} icon={ICONS.ANALYTICS} name={__('Creator Analytics')} />
|
||||
|
||||
{authenticated ? (
|
||||
<MenuItem onSelect={openSignOutModal}>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.SIGN_OUT} />
|
||||
{__('Sign Out')}
|
||||
</div>
|
||||
<span className="menu__link-help">{email}</span>
|
||||
</MenuItem>
|
||||
) : (
|
||||
<HeaderMenuLink page={PAGES.AUTH_SIGNIN} icon={ICONS.SIGN_IN} name={__('Cloud Connect')} />
|
||||
)}
|
||||
</MenuList>
|
||||
</Menu>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { LINKED_COMMENT_QUERY_PARAM } from 'constants/comment';
|
||||
import { parseURI, isURIValid } from 'util/lbryURI';
|
||||
import { WELCOME_VERSION } from 'config';
|
||||
import { GetLinksData } from 'util/buildHomepage';
|
||||
import { useIsLargeScreen } from 'effects/use-screensize';
|
||||
|
||||
import HomePage from 'page/home';
|
||||
import BackupPage from 'page/backup';
|
||||
@@ -125,8 +126,8 @@ function AppRouter(props: Props) {
|
||||
const urlParams = new URLSearchParams(search);
|
||||
const resetScroll = urlParams.get('reset_scroll');
|
||||
const hasLinkedCommentInUrl = urlParams.get(LINKED_COMMENT_QUERY_PARAM);
|
||||
|
||||
const dynamicRoutes = GetLinksData(homepageData).filter(
|
||||
const isLargeScreen = useIsLargeScreen();
|
||||
const dynamicRoutes = GetLinksData(homepageData, isLargeScreen).filter(
|
||||
(potentialRoute: any) => potentialRoute && potentialRoute.route
|
||||
);
|
||||
|
||||
|
||||
@@ -7,11 +7,13 @@ import SettingCommentsServer from './view';
|
||||
const select = (state) => ({
|
||||
customServerEnabled: makeSelectClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_ENABLED)(state),
|
||||
customServerUrl: makeSelectClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_URL)(state),
|
||||
customCommentServers: makeSelectClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVERS)(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
setCustomServerEnabled: (val) => dispatch(doSetClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_ENABLED, val, true)),
|
||||
setCustomServerUrl: (url) => dispatch(doSetClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_URL, url, true)),
|
||||
setCustomServers: (servers) => dispatch(doSetClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVERS, servers, true)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(SettingCommentsServer);
|
||||
@@ -0,0 +1,94 @@
|
||||
// @flow
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import Button from 'component/button';
|
||||
import { Form, FormField } from 'component/common/form';
|
||||
import { VALID_IPADDRESS_REGEX, VALID_HOSTNAME_REGEX, VALID_ENDPOINT_REGEX } from 'constants/protocol_regex';
|
||||
|
||||
type Props = {
|
||||
update: (CommentServerDetails) => void,
|
||||
onCancel: (boolean) => void,
|
||||
};
|
||||
|
||||
const isValidServerString = (serverString) => {
|
||||
const si = serverString.indexOf('/');
|
||||
const pi = serverString.indexOf(':');
|
||||
const path = si === -1 ? '' : serverString.slice(si);
|
||||
const hostMaybePort = si === -1 ? serverString : serverString.slice(0, si);
|
||||
const host = pi === -1 ? hostMaybePort : hostMaybePort.slice(0, pi);
|
||||
const port = pi === -1 ? '' : hostMaybePort.slice(pi + 1);
|
||||
const portInt = parseInt(port);
|
||||
|
||||
return (
|
||||
(host === 'localhost' || VALID_IPADDRESS_REGEX.test(host) || VALID_HOSTNAME_REGEX.test(host)) &&
|
||||
(!path || VALID_ENDPOINT_REGEX.test(path)) &&
|
||||
// eslint-disable-next-line
|
||||
(pi === -1 || (port && typeof portInt === 'number' && portInt === portInt))
|
||||
); // NaN !== NaN
|
||||
};
|
||||
|
||||
function ServerInputRow(props: Props) {
|
||||
const { update, onCancel } = props;
|
||||
const [nameString, setNameString] = useState('');
|
||||
const [hostString, setHostString] = useState('');
|
||||
const [useHttps, setUseHttps] = useState(true);
|
||||
|
||||
const getHostString = () => {
|
||||
return `${useHttps ? 'https://' : 'http://'}${hostString}`;
|
||||
};
|
||||
|
||||
const [validServerString, setValidServerString] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setValidServerString(isValidServerString(hostString));
|
||||
}, [hostString, validServerString, setValidServerString]);
|
||||
|
||||
function onSubmit() {
|
||||
const updateValue = { url: getHostString(), name: nameString };
|
||||
update(updateValue);
|
||||
setHostString('');
|
||||
setNameString('');
|
||||
}
|
||||
|
||||
return (
|
||||
<Form onSubmit={onSubmit}>
|
||||
<div className="setting-item-input">
|
||||
<FormField
|
||||
type="text"
|
||||
label={__('Name')}
|
||||
placeholder={'My Server'}
|
||||
value={nameString}
|
||||
onChange={(e) => setNameString(e.target.value)}
|
||||
/>
|
||||
<div className="fieldset-group fieldset-group--smushed fieldset-group--disabled-prefix fieldset-group--row">
|
||||
<div className={'fieldset-section'}>
|
||||
<label htmlFor="serverUrl">{__('URL')}</label>
|
||||
<div className="form-field__prefix">{`${useHttps ? 'https://' : 'http://'}`}</div>
|
||||
</div>
|
||||
<FormField
|
||||
type="text"
|
||||
placeholder={'code.freezepeach.fun'}
|
||||
value={hostString}
|
||||
onChange={(e) => setHostString(e.target.value)}
|
||||
name={'serverUrl'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="setting-item-input">
|
||||
<FormField
|
||||
label={'Use https'}
|
||||
name="use_https"
|
||||
type="checkbox"
|
||||
checked={useHttps}
|
||||
onChange={() => setUseHttps(!useHttps)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="section__actions setting-item-input">
|
||||
<Button type="submit" button="primary" label={__('Add')} disabled={!validServerString || !nameString} />
|
||||
<Button type="button" button="inverse" onClick={() => onCancel(false)} label={__('Cancel')} />
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
||||
export default ServerInputRow;
|
||||
@@ -1,70 +1,100 @@
|
||||
// @flow
|
||||
import { COMMENT_SERVER_NAME } from 'config';
|
||||
import { COMMENT_SERVER_API, COMMENT_SERVER_NAME } from 'config';
|
||||
import React from 'react';
|
||||
import Comments from 'comments';
|
||||
import { FormField } from 'component/common/form';
|
||||
|
||||
const DEBOUNCE_TEXT_INPUT_MS = 500;
|
||||
import ItemInputRow from './internal/input-radio-panel-addCommentServer';
|
||||
import Button from 'component/button';
|
||||
import { FormField } from 'component/common/form-components/form-field';
|
||||
|
||||
type Props = {
|
||||
customServerEnabled: boolean,
|
||||
customServerUrl: string,
|
||||
setCustomServerEnabled: (boolean) => void,
|
||||
setCustomServerUrl: (string) => void,
|
||||
setCustomServers: (Array<CommentServerDetails>) => void,
|
||||
customCommentServers: Array<CommentServerDetails>,
|
||||
};
|
||||
|
||||
const defaultServer = { name: COMMENT_SERVER_NAME, url: COMMENT_SERVER_API };
|
||||
function SettingCommentsServer(props: Props) {
|
||||
const { customServerEnabled, customServerUrl, setCustomServerEnabled, setCustomServerUrl } = props;
|
||||
const [url, setUrl] = React.useState(customServerUrl);
|
||||
const {
|
||||
customServerEnabled,
|
||||
customServerUrl,
|
||||
setCustomServerEnabled,
|
||||
setCustomServerUrl,
|
||||
customCommentServers,
|
||||
setCustomServers,
|
||||
} = props;
|
||||
const [addServer, setAddServer] = React.useState(false);
|
||||
|
||||
const customServersString = JSON.stringify(customCommentServers);
|
||||
|
||||
// "migrate" to make sure any currently set custom server is in saved list
|
||||
React.useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
Comments.setServerUrl(customServerEnabled ? url : undefined);
|
||||
if (url !== customServerUrl) {
|
||||
setCustomServerUrl(url);
|
||||
}
|
||||
}, DEBOUNCE_TEXT_INPUT_MS);
|
||||
// const servers = JSON.parse(customServersString);
|
||||
// if customServerUrl is not in servers, make sure it is.
|
||||
}, [customServerUrl, customServersString, setCustomServers]);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [url, customServerUrl, customServerEnabled, setCustomServerUrl]);
|
||||
const handleSelectServer = (serverItem: CommentServerDetails) => {
|
||||
if (serverItem.url !== COMMENT_SERVER_API) {
|
||||
Comments.setServerUrl(serverItem.url);
|
||||
setCustomServerUrl(serverItem.url);
|
||||
setCustomServerEnabled(true);
|
||||
} else {
|
||||
Comments.setServerUrl(undefined);
|
||||
setCustomServerEnabled(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddServer = (serverItem: CommentServerDetails) => {
|
||||
const newCustomServers = customCommentServers.slice();
|
||||
newCustomServers.push(serverItem);
|
||||
setCustomServers(newCustomServers);
|
||||
handleSelectServer(serverItem);
|
||||
setAddServer(false);
|
||||
};
|
||||
|
||||
const handleRemoveServer = (serverItem: CommentServerDetails) => {
|
||||
handleSelectServer(defaultServer);
|
||||
const newCustomServers = customCommentServers.slice().filter((server) => {
|
||||
return server.url !== serverItem.url;
|
||||
});
|
||||
setCustomServers(newCustomServers);
|
||||
};
|
||||
|
||||
const commentServerLabel = (serverDetails, onRemove) => (
|
||||
<span className={'compound-label'}>
|
||||
<span>{serverDetails.name}</span>
|
||||
<span className="compound-label__details">{serverDetails.url}</span>
|
||||
{onRemove && <Button button={'inverse'} label={__('Remove')} onClick={() => onRemove(serverDetails)} />}
|
||||
</span>
|
||||
);
|
||||
const commentServerRadio = (customServerEnabled, customServerUrl, onClick, onRemove, serverDetails) => (
|
||||
<FormField
|
||||
type="radio"
|
||||
checked={(!customServerEnabled && !onRemove) || (customServerEnabled && customServerUrl === serverDetails.url)}
|
||||
onClick={() => onClick(serverDetails)}
|
||||
label={commentServerLabel(serverDetails, onRemove)}
|
||||
name={`${serverDetails.name}${serverDetails.url}`}
|
||||
key={`${serverDetails.name}${serverDetails.url}`}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<fieldset-section>
|
||||
<FormField
|
||||
type="radio"
|
||||
name="use_default_comments_server"
|
||||
label={__('Default comments server (%name%)', { name: COMMENT_SERVER_NAME })}
|
||||
checked={!customServerEnabled}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
setCustomServerEnabled(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<FormField
|
||||
type="radio"
|
||||
name="use_custom_comments_server"
|
||||
label={__('Custom comments server')}
|
||||
checked={customServerEnabled}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
setCustomServerEnabled(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
{customServerEnabled && (
|
||||
<div className="section__body">
|
||||
<FormField
|
||||
type="text"
|
||||
placeholder="https://comment.mysite.com"
|
||||
value={url}
|
||||
onChange={(e) => setUrl(e.target.value)}
|
||||
/>
|
||||
<div className={'fieldset-section'}>
|
||||
{commentServerRadio(customServerEnabled, customServerUrl, handleSelectServer, null, defaultServer)}
|
||||
{customCommentServers.map((server) =>
|
||||
commentServerRadio(customServerEnabled, customServerUrl, handleSelectServer, handleRemoveServer, server)
|
||||
)}
|
||||
</div>
|
||||
<div className={'fieldset-section'}>
|
||||
{!addServer && (
|
||||
<div className="section__actions">
|
||||
<Button type="button" button="inverse" onClick={() => setAddServer(true)} label={__('Add A Server')} />
|
||||
</div>
|
||||
)}
|
||||
</fieldset-section>
|
||||
{addServer && <ItemInputRow update={handleAddServer} onCancel={setAddServer} />}
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ export default function SettingContent(props: Props) {
|
||||
}
|
||||
setClientSetting(SETTINGS.HIDE_REPOSTS, !hideReposts);
|
||||
}}
|
||||
checked={hideReposts}
|
||||
/>
|
||||
</SettingsRow>
|
||||
<SettingsRow title={__('Show mature content')} subtitle={__(HELP.SHOW_MATURE)}>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doSetDaemonSetting, doGetDaemonStatus, doCleanBlobs } from 'redux/actions/settings';
|
||||
import { selectDaemonStatus, selectDaemonSettings } from 'redux/selectors/settings';
|
||||
import SettingWalletServer from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
daemonSettings: selectDaemonSettings(state),
|
||||
daemonStatus: selectDaemonStatus(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
getDaemonStatus: () => dispatch(doGetDaemonStatus()),
|
||||
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
|
||||
cleanBlobs: () => dispatch(doCleanBlobs()),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(SettingWalletServer);
|
||||
@@ -0,0 +1,195 @@
|
||||
// @flow
|
||||
|
||||
import React from 'react';
|
||||
import { FormField } from 'component/common/form';
|
||||
import Button from 'component/button';
|
||||
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
||||
import { formatBytes } from 'util/format-bytes';
|
||||
const BYTES_PER_MB = 1048576;
|
||||
const ENABLE_AUTOMATIC_HOSTING = false;
|
||||
|
||||
type Price = {
|
||||
currency: string,
|
||||
amount: number,
|
||||
};
|
||||
|
||||
type DaemonStatus = {
|
||||
disk_space: {
|
||||
content_blobs_storage_used_mb: string,
|
||||
published_blobs_storage_used_mb: string,
|
||||
running: true,
|
||||
seed_blobs_storage_used_mb: string,
|
||||
total_used_mb: string,
|
||||
},
|
||||
};
|
||||
|
||||
type SetDaemonSettingArg = boolean | string | number | Price;
|
||||
|
||||
type DaemonSettings = {
|
||||
download_dir: string,
|
||||
share_usage_data: boolean,
|
||||
max_key_fee?: Price,
|
||||
max_connections_per_download?: number,
|
||||
save_files: boolean,
|
||||
save_blobs: boolean,
|
||||
ffmpeg_path: string,
|
||||
};
|
||||
|
||||
type Props = {
|
||||
// --- select ---
|
||||
daemonSettings: DaemonSettings,
|
||||
daemonStatus: DaemonStatus,
|
||||
// --- perform ---
|
||||
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
|
||||
cleanBlobs: () => void,
|
||||
};
|
||||
|
||||
function SettingWalletServer(props: Props) {
|
||||
const { daemonSettings, daemonStatus, setDaemonSetting, cleanBlobs } = props;
|
||||
|
||||
const { disk_space } = daemonStatus;
|
||||
const contentSpaceUsed = Number(disk_space.content_blobs_storage_used_mb);
|
||||
const networkSpaceUsed = Number(disk_space.seed_blobs_storage_used_mb);
|
||||
const blobLimitSetting = daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB];
|
||||
const networkLimitSetting = daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB];
|
||||
const [contentBlobSpaceLimitGB, setContentBlobSpaceLimit] = React.useState(
|
||||
blobLimitSetting ? blobLimitSetting / 1024 : 0
|
||||
);
|
||||
const [networkBlobSpaceLimitGB, setNetworkBlobSpaceLimit] = React.useState(
|
||||
networkLimitSetting ? networkLimitSetting / 1024 : 0
|
||||
);
|
||||
const [limitSpace, setLimitSpace] = React.useState(Boolean(blobLimitSetting));
|
||||
|
||||
function updateContentBlobLimitField(gb) {
|
||||
if (gb === 0) {
|
||||
setContentBlobSpaceLimit(0);
|
||||
} else if (!gb || !isNaN(gb)) {
|
||||
setContentBlobSpaceLimit(gb);
|
||||
}
|
||||
}
|
||||
|
||||
function updateNetworkBlobLimitField(gb) {
|
||||
if (gb === 0) {
|
||||
setNetworkBlobSpaceLimit(0);
|
||||
} else if (!gb || !isNaN(gb)) {
|
||||
setNetworkBlobSpaceLimit(gb);
|
||||
}
|
||||
}
|
||||
|
||||
function handleLimitSpace(value) {
|
||||
setLimitSpace(value);
|
||||
if (!value) {
|
||||
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(0));
|
||||
} else {
|
||||
const spaceLimitMB = contentBlobSpaceLimitGB * 1024;
|
||||
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(spaceLimitMB));
|
||||
}
|
||||
}
|
||||
|
||||
function handleSetContentBlobSpaceLimit() {
|
||||
const spaceLimitMB = contentBlobSpaceLimitGB * 1024;
|
||||
if (!isNaN(spaceLimitMB) && blobLimitSetting !== spaceLimitMB * 1024) {
|
||||
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(spaceLimitMB));
|
||||
}
|
||||
}
|
||||
|
||||
function handleSetNetworkBlobSpaceLimit() {
|
||||
const spaceLimitMB = networkBlobSpaceLimitGB * 1024;
|
||||
if (!isNaN(spaceLimitMB) && blobLimitSetting !== spaceLimitMB * 1024) {
|
||||
setDaemonSetting(DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB, String(spaceLimitMB));
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<fieldset-section>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="save_blobs"
|
||||
onChange={() => setDaemonSetting('save_blobs', !daemonSettings.save_blobs)}
|
||||
checked={daemonSettings.save_blobs}
|
||||
label={__('Enable Data Hosting')}
|
||||
/>
|
||||
</fieldset-section>
|
||||
{daemonSettings.save_blobs && (
|
||||
<fieldset-section>
|
||||
<div className={'settings__row-section-title'}>{__('View History Hosting')}</div>
|
||||
<div className={'help'}>
|
||||
{`View History Hosting using ${formatBytes(contentSpaceUsed * BYTES_PER_MB)} of ${
|
||||
daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB]
|
||||
? formatBytes(daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB] * BYTES_PER_MB)
|
||||
: 'Unlimited'
|
||||
}`}
|
||||
</div>
|
||||
</fieldset-section>
|
||||
)}
|
||||
{daemonSettings.save_blobs && (
|
||||
<fieldset-section>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="limit_space_used"
|
||||
onChange={() => handleLimitSpace(!limitSpace)}
|
||||
checked={limitSpace}
|
||||
label={__('Limit Hosting of Content History')}
|
||||
/>
|
||||
</fieldset-section>
|
||||
)}
|
||||
|
||||
{daemonSettings.save_blobs && limitSpace && (
|
||||
<FormField
|
||||
name="content_blob_limit_gb"
|
||||
type="text"
|
||||
label={__(`Limit (GB)`)}
|
||||
disabled={!daemonSettings.save_blobs}
|
||||
onChange={(e) => updateContentBlobLimitField(e.target.value)}
|
||||
value={contentBlobSpaceLimitGB}
|
||||
inputButton={
|
||||
<Button
|
||||
disabled={isNaN(contentBlobSpaceLimitGB)}
|
||||
button="primary"
|
||||
label={__('Apply')}
|
||||
onClick={handleSetContentBlobSpaceLimit}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<fieldset-section>
|
||||
<Button type="button" button="inverse" onClick={cleanBlobs} label={__('Clean Now')} />
|
||||
</fieldset-section>
|
||||
{/* Automatic Hosting Section */}
|
||||
{daemonSettings.save_blobs && ENABLE_AUTOMATIC_HOSTING && (
|
||||
<fieldset-section>
|
||||
<div className={'settings__row-section-title'}>{__('Automatic Hosting - Experimental')}</div>
|
||||
<p className={'help'}>
|
||||
{`Automatic Hosting using ${formatBytes(networkSpaceUsed * BYTES_PER_MB)} of ${formatBytes(
|
||||
daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB] * BYTES_PER_MB
|
||||
)}`}
|
||||
</p>
|
||||
</fieldset-section>
|
||||
)}
|
||||
{daemonSettings.save_blobs && ENABLE_AUTOMATIC_HOSTING && (
|
||||
<>
|
||||
<FormField
|
||||
name="network_blob_limit_gb"
|
||||
type="text"
|
||||
label={__(`Allow (GB)`)}
|
||||
disabled={!daemonSettings.save_blobs}
|
||||
onChange={(e) => updateNetworkBlobLimitField(e.target.value)}
|
||||
value={networkBlobSpaceLimitGB}
|
||||
inputButton={
|
||||
<Button
|
||||
disabled={isNaN(networkBlobSpaceLimitGB)}
|
||||
button="primary"
|
||||
label={__('Apply')}
|
||||
onClick={handleSetNetworkBlobSpaceLimit}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<div className="form-field__help">{__('Download and serve arbitrary data on the network.')}</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default SettingWalletServer;
|
||||
@@ -12,7 +12,6 @@ import { doSetDaemonSetting, doClearDaemonSetting, doFindFFmpeg } from 'redux/ac
|
||||
import { selectAllowAnalytics } from 'redux/selectors/app';
|
||||
import {
|
||||
selectDaemonSettings,
|
||||
selectDaemonStatus,
|
||||
selectFfmpegStatus,
|
||||
selectFindingFFmpeg,
|
||||
selectLanguage,
|
||||
@@ -29,7 +28,6 @@ const select = (state) => ({
|
||||
isAuthenticated: selectUserVerifiedEmail(state),
|
||||
allowAnalytics: selectAllowAnalytics(state),
|
||||
language: selectLanguage(state),
|
||||
daemonStatus: selectDaemonStatus(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -10,17 +10,16 @@ import I18nMessage from 'component/i18nMessage';
|
||||
import SettingAutoLaunch from 'component/settingAutoLaunch';
|
||||
import SettingClosingBehavior from 'component/settingClosingBehavior';
|
||||
import SettingCommentsServer from 'component/settingCommentsServer';
|
||||
import SettingDataHosting from 'component/settingDataHosting';
|
||||
import SettingShareUrl from 'component/settingShareUrl';
|
||||
import SettingsRow from 'component/settingsRow';
|
||||
import SettingWalletServer from 'component/settingWalletServer';
|
||||
import Spinner from 'component/spinner';
|
||||
import { getPasswordFromCookie } from 'util/saved-passwords';
|
||||
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
||||
import { formatBytes } from 'util/format-bytes';
|
||||
import SettingEnablePrereleases from 'component/settingEnablePrereleases';
|
||||
|
||||
const IS_MAC = process.platform === 'darwin';
|
||||
const BYTES_PER_MB = 1048576;
|
||||
|
||||
type Price = {
|
||||
currency: string,
|
||||
@@ -39,16 +38,6 @@ type DaemonSettings = {
|
||||
ffmpeg_path: string,
|
||||
};
|
||||
|
||||
type DaemonStatus = {
|
||||
disk_space: {
|
||||
content_blobs_storage_used_mb: string,
|
||||
published_blobs_storage_used_mb: string,
|
||||
running: true,
|
||||
seed_blobs_storage_used_mb: string,
|
||||
total_used_mb: string,
|
||||
},
|
||||
};
|
||||
|
||||
type Props = {
|
||||
// --- select ---
|
||||
daemonSettings: DaemonSettings,
|
||||
@@ -67,7 +56,6 @@ type Props = {
|
||||
updateWalletStatus: () => void,
|
||||
confirmForgetPassword: ({}) => void,
|
||||
toggle3PAnalytics: (boolean) => void,
|
||||
daemonStatus: DaemonStatus,
|
||||
};
|
||||
|
||||
export default function SettingSystem(props: Props) {
|
||||
@@ -87,23 +75,10 @@ export default function SettingSystem(props: Props) {
|
||||
updateWalletStatus,
|
||||
confirmForgetPassword,
|
||||
toggle3PAnalytics,
|
||||
daemonStatus,
|
||||
} = props;
|
||||
|
||||
const [clearingCache, setClearingCache] = React.useState(false);
|
||||
const [storedPassword, setStoredPassword] = React.useState(false);
|
||||
const { disk_space } = daemonStatus;
|
||||
const contentSpaceUsed = Number(disk_space.content_blobs_storage_used_mb);
|
||||
const networkSpaceUsed = Number(disk_space.seed_blobs_storage_used_mb);
|
||||
const blobLimitSetting = daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB];
|
||||
const networkLimitSetting = daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB];
|
||||
const [contentBlobSpaceLimitGB, setContentBlobSpaceLimit] = React.useState(
|
||||
blobLimitSetting ? blobLimitSetting / 1024 : 0
|
||||
);
|
||||
const [networkBlobSpaceLimitGB, setNetworkBlobSpaceLimit] = React.useState(
|
||||
networkLimitSetting ? networkLimitSetting / 1024 : 0
|
||||
);
|
||||
const [limitSpace, setLimitSpace] = React.useState(Boolean(blobLimitSetting));
|
||||
const { available: ffmpegAvailable, which: ffmpegPath } = ffmpegStatus;
|
||||
|
||||
function onChangeEncryptWallet() {
|
||||
@@ -118,46 +93,6 @@ export default function SettingSystem(props: Props) {
|
||||
confirmForgetPassword({ callback: () => setStoredPassword(false) });
|
||||
}
|
||||
|
||||
function updateContentBlobLimitField(gb) {
|
||||
if (gb === 0) {
|
||||
setContentBlobSpaceLimit(0);
|
||||
} else if (!gb || !isNaN(gb)) {
|
||||
setContentBlobSpaceLimit(gb);
|
||||
}
|
||||
}
|
||||
|
||||
function updateNetworkBlobLimitField(gb) {
|
||||
if (gb === 0) {
|
||||
setNetworkBlobSpaceLimit(0);
|
||||
} else if (!gb || !isNaN(gb)) {
|
||||
setNetworkBlobSpaceLimit(gb);
|
||||
}
|
||||
}
|
||||
|
||||
function handleLimitSpace(value) {
|
||||
setLimitSpace(value);
|
||||
if (!value) {
|
||||
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(0));
|
||||
} else {
|
||||
const spaceLimitMB = contentBlobSpaceLimitGB * 1024;
|
||||
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(spaceLimitMB));
|
||||
}
|
||||
}
|
||||
|
||||
function handleSetContentBlobSpaceLimit() {
|
||||
const spaceLimitMB = contentBlobSpaceLimitGB * 1024;
|
||||
if (!isNaN(spaceLimitMB) && blobLimitSetting !== spaceLimitMB * 1024) {
|
||||
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(spaceLimitMB));
|
||||
}
|
||||
}
|
||||
|
||||
function handleSetNetworkBlobSpaceLimit() {
|
||||
const spaceLimitMB = networkBlobSpaceLimitGB * 1024;
|
||||
if (!isNaN(spaceLimitMB) && blobLimitSetting !== spaceLimitMB * 1024) {
|
||||
setDaemonSetting(DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB, String(spaceLimitMB));
|
||||
}
|
||||
}
|
||||
|
||||
// Update ffmpeg variables
|
||||
React.useEffect(() => {
|
||||
const { available } = ffmpegStatus;
|
||||
@@ -220,93 +155,18 @@ export default function SettingSystem(props: Props) {
|
||||
multirow
|
||||
subtitle={
|
||||
<React.Fragment>
|
||||
{__('Content Data Hosting helps to seed things that you watch and download.')}{' '}
|
||||
{__('Network Data Hosting allows the p2p network to store blobs unrelated to your browsing.')}{' '}
|
||||
{__("If disabled, LBRY will be very sad and you won't be helping improve the network.")}{' '}
|
||||
{__('If you set a limit, playing videos may exceed your limit until cleanup runs every 30 minutes.')}{' '}
|
||||
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />.
|
||||
{__('Help improve the P2P data network (and make LBRY happy) by hosting data.')}{' '}
|
||||
{__("View History Hosting lets you choose how much storage to use helping content you've consumed.")}{' '}
|
||||
{/* {__( */}
|
||||
{/* 'Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.' */}
|
||||
{/* )}{' '} */}
|
||||
{__('Playing videos may exceed your history hosting limit until cleanup runs every 30 minutes.')}
|
||||
<br />
|
||||
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />
|
||||
</React.Fragment>
|
||||
}
|
||||
>
|
||||
<fieldset-section>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="save_blobs"
|
||||
onChange={() => setDaemonSetting('save_blobs', !daemonSettings.save_blobs)}
|
||||
checked={daemonSettings.save_blobs}
|
||||
label={__('Enable Data Hosting')}
|
||||
/>
|
||||
</fieldset-section>
|
||||
{daemonSettings.save_blobs && (
|
||||
<fieldset-section>
|
||||
<div className={'settings__row-section-title'}>{__('Hosting for content you have downloaded')}</div>
|
||||
<p className={'help'}>
|
||||
{`Content Hosting using ${formatBytes(contentSpaceUsed * BYTES_PER_MB)} of ${
|
||||
daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB]
|
||||
? formatBytes(daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB] * BYTES_PER_MB)
|
||||
: 'Unlimited'
|
||||
}`}
|
||||
</p>
|
||||
</fieldset-section>
|
||||
)}
|
||||
{daemonSettings.save_blobs && (
|
||||
<fieldset-section>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="limit_space_used"
|
||||
onChange={() => handleLimitSpace(!limitSpace)}
|
||||
checked={limitSpace}
|
||||
label={__('Limit Hosting for Content you Use')}
|
||||
/>
|
||||
</fieldset-section>
|
||||
)}
|
||||
|
||||
{daemonSettings.save_blobs && limitSpace && (
|
||||
<FormField
|
||||
name="content_blob_limit_gb"
|
||||
type="text"
|
||||
label={__(`Content: Limit (GB)`)}
|
||||
disabled={!daemonSettings.save_blobs}
|
||||
onChange={(e) => updateContentBlobLimitField(e.target.value)}
|
||||
value={contentBlobSpaceLimitGB}
|
||||
inputButton={
|
||||
<Button
|
||||
disabled={isNaN(contentBlobSpaceLimitGB)}
|
||||
button="primary"
|
||||
label={__('Apply')}
|
||||
onClick={handleSetContentBlobSpaceLimit}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{daemonSettings.save_blobs && (
|
||||
<fieldset-section>
|
||||
<div className={'settings__row-section-title'}>{__('Hosting content selected by the network')}</div>
|
||||
<p className={'help'}>
|
||||
{`Network Hosting using ${formatBytes(networkSpaceUsed * BYTES_PER_MB)} of ${formatBytes(
|
||||
daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB] * BYTES_PER_MB
|
||||
)}`}
|
||||
</p>
|
||||
</fieldset-section>
|
||||
)}
|
||||
{daemonSettings.save_blobs && (
|
||||
<FormField
|
||||
name="network_blob_limit_gb"
|
||||
type="text"
|
||||
label={__(`Network: Allow (GB)`)}
|
||||
disabled={!daemonSettings.save_blobs}
|
||||
onChange={(e) => updateNetworkBlobLimitField(e.target.value)}
|
||||
value={networkBlobSpaceLimitGB}
|
||||
inputButton={
|
||||
<Button
|
||||
disabled={isNaN(networkBlobSpaceLimitGB)}
|
||||
button="primary"
|
||||
label={__('Apply')}
|
||||
onClick={handleSetNetworkBlobSpaceLimit}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<SettingDataHosting />
|
||||
</SettingsRow>
|
||||
<SettingsRow
|
||||
title={__('Share usage and diagnostic data')}
|
||||
@@ -501,7 +361,22 @@ export default function SettingSystem(props: Props) {
|
||||
</fieldset-section>
|
||||
</SettingsRow>
|
||||
|
||||
<SettingsRow title={__('Wallet server')} multirow>
|
||||
<SettingsRow
|
||||
title={__('Wallet server')}
|
||||
subtitle={
|
||||
<I18nMessage
|
||||
tokens={{
|
||||
learn_more: (
|
||||
<Button button="link" href="http://lbry.com/faq/wallet-servers" label={__('Learn More')} />
|
||||
),
|
||||
}}
|
||||
>
|
||||
Wallet servers are used to relay data to and from the LBRY blockchain. They also determine what
|
||||
content shows in trending or is blocked. %learn_more%
|
||||
</I18nMessage>
|
||||
}
|
||||
multirow
|
||||
>
|
||||
<SettingWalletServer />
|
||||
</SettingsRow>
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { FormField } from 'component/common/form';
|
||||
import Button from 'component/button';
|
||||
import I18nMessage from 'component/i18nMessage';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import ServerInputRow from './internal/inputRow';
|
||||
import { stringifyServerParam } from 'util/sync-settings';
|
||||
@@ -133,16 +132,6 @@ function SettingWalletServer(props: Props) {
|
||||
}}
|
||||
label={__('Use custom wallet servers')}
|
||||
/>
|
||||
<p className="help">
|
||||
<I18nMessage
|
||||
tokens={{
|
||||
learn_more: <Button button="link" href="http://lbry.com/faq/wallet-servers" label={__('Learn More')} />,
|
||||
}}
|
||||
>
|
||||
Wallet servers are used to relay data to and from the LBRY blockchain. They also determine what content
|
||||
shows in trending or is blocked. %learn_more%
|
||||
</I18nMessage>
|
||||
</p>
|
||||
|
||||
{advancedMode && (
|
||||
<div>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// ****************************************************************************
|
||||
// LbryVolumeBarClass
|
||||
// ****************************************************************************
|
||||
|
||||
import videojs from 'video.js';
|
||||
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
|
||||
const VIDEOJS_CONTROL_BAR_CLASS = 'ControlBar';
|
||||
const VIDEOJS_VOLUME_PANEL_CLASS = 'VolumePanel';
|
||||
const VIDEOJS_VOLUME_CONTROL_CLASS = 'VolumeControl';
|
||||
const VIDEOJS_VOLUME_BAR_CLASS = 'VolumeBar';
|
||||
|
||||
class LbryVolumeBarClass extends videojs.getComponent(VIDEOJS_VOLUME_BAR_CLASS) {
|
||||
constructor(player, options = {}) {
|
||||
super(player, options);
|
||||
}
|
||||
|
||||
static replaceExisting(player) {
|
||||
try {
|
||||
const volumeControl = player
|
||||
.getChild(VIDEOJS_CONTROL_BAR_CLASS)
|
||||
.getChild(VIDEOJS_VOLUME_PANEL_CLASS)
|
||||
.getChild(VIDEOJS_VOLUME_CONTROL_CLASS);
|
||||
const volumeBar = volumeControl.getChild(VIDEOJS_VOLUME_BAR_CLASS);
|
||||
volumeControl.removeChild(volumeBar);
|
||||
volumeControl.addChild(new LbryVolumeBarClass(player));
|
||||
} catch (error) {
|
||||
// In case it slips in 'Production', the original volume bar will be used and the site should still be working
|
||||
// (just not exactly the way we want).
|
||||
if (isDev) throw Error('\n\nvideojs.jsx: Volume Panel hierarchy changed?\n\n' + error);
|
||||
}
|
||||
}
|
||||
|
||||
handleMouseDown(event) {
|
||||
super.handleMouseDown(event);
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
handleMouseMove(event) {
|
||||
super.handleMouseMove(event);
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
export default LbryVolumeBarClass;
|
||||
@@ -0,0 +1,236 @@
|
||||
// @flow
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
|
||||
const TAP = {
|
||||
NONE: 'NONE',
|
||||
UNMUTE: 'UNMUTE',
|
||||
RETRY: 'RETRY',
|
||||
};
|
||||
|
||||
const setLabel = (controlBar, childName, label) => {
|
||||
const c = controlBar.getChild(childName);
|
||||
if (c) {
|
||||
c.controlText(label);
|
||||
}
|
||||
};
|
||||
|
||||
// $FlowFixMe
|
||||
const VideoJsEvents = ({
|
||||
tapToUnmuteRef,
|
||||
tapToRetryRef,
|
||||
setReload,
|
||||
videoTheaterMode,
|
||||
playerRef,
|
||||
autoplaySetting,
|
||||
replay,
|
||||
}: {
|
||||
tapToUnmuteRef: any, // DOM element
|
||||
tapToRetryRef: any, // DOM element
|
||||
setReload: any, // react hook
|
||||
videoTheaterMode: any, // dispatch function
|
||||
playerRef: any, // DOM element
|
||||
autoplaySetting: boolean,
|
||||
replay: boolean,
|
||||
}) => {
|
||||
// Override the player's control text. We override to:
|
||||
// 1. Add keyboard shortcut to the tool-tip.
|
||||
// 2. Override videojs' i18n and use our own (don't want to have 2 systems).
|
||||
//
|
||||
// Notes:
|
||||
// - For dynamic controls (e.g. play/pause), those unfortunately need to be
|
||||
// updated again at their event-listener level (that's just the way videojs
|
||||
// updates the text), hence the need to listen to 'play', 'pause' and 'volumechange'
|
||||
// on top of just 'loadstart'.
|
||||
// - videojs changes the MuteToggle text at 'loadstart', so this was chosen
|
||||
// as the listener to update static texts.
|
||||
|
||||
function resolveCtrlText(e) {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const ctrlBar = player.getChild('controlBar');
|
||||
switch (e.type) {
|
||||
case 'play':
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Pause (space)'));
|
||||
break;
|
||||
case 'pause':
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Play (space)'));
|
||||
break;
|
||||
case 'volumechange':
|
||||
ctrlBar
|
||||
.getChild('VolumePanel')
|
||||
.getChild('MuteToggle')
|
||||
.controlText(player.muted() || player.volume() === 0 ? __('Unmute (m)') : __('Mute (m)'));
|
||||
break;
|
||||
case 'fullscreenchange':
|
||||
setLabel(
|
||||
ctrlBar,
|
||||
'FullscreenToggle',
|
||||
player.isFullscreen() ? __('Exit Fullscreen (f)') : __('Fullscreen (f)')
|
||||
);
|
||||
break;
|
||||
case 'loadstart':
|
||||
// --- Do everything ---
|
||||
setLabel(ctrlBar, 'PlaybackRateMenuButton', __('Playback Rate (<, >)'));
|
||||
setLabel(ctrlBar, 'QualityButton', __('Quality'));
|
||||
setLabel(ctrlBar, 'PlayNextButton', __('Play Next (SHIFT+N)'));
|
||||
setLabel(ctrlBar, 'PlayPreviousButton', __('Play Previous (SHIFT+P)'));
|
||||
setLabel(ctrlBar, 'TheaterModeButton', videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||
setLabel(ctrlBar, 'AutoplayNextButton', autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off'));
|
||||
|
||||
resolveCtrlText({ type: 'play' });
|
||||
resolveCtrlText({ type: 'pause' });
|
||||
resolveCtrlText({ type: 'volumechange' });
|
||||
resolveCtrlText({ type: 'fullscreenchange' });
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw Error('Unexpected: ' + e.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onInitialPlay() {
|
||||
const player = playerRef.current;
|
||||
if (player && (player.muted() || player.volume() === 0)) {
|
||||
// The css starts as "hidden". We make it visible here without
|
||||
// re-rendering the whole thing.
|
||||
showTapButton(TAP.UNMUTE);
|
||||
} else {
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function onVolumeChange() {
|
||||
const player = playerRef.current;
|
||||
if (player && !player.muted()) {
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function onError() {
|
||||
const player = playerRef.current;
|
||||
showTapButton(TAP.RETRY);
|
||||
|
||||
// reattach initial play listener in case we recover from error successfully
|
||||
// $FlowFixMe
|
||||
player.one('play', onInitialPlay);
|
||||
|
||||
if (player && player.loadingSpinner) {
|
||||
player.loadingSpinner.hide();
|
||||
}
|
||||
}
|
||||
|
||||
// const onEnded = React.useCallback(() => {
|
||||
// if (!adUrl) {
|
||||
// showTapButton(TAP.NONE);
|
||||
// }
|
||||
// }, [adUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const controlBar = player.getChild('controlBar');
|
||||
controlBar
|
||||
.getChild('TheaterModeButton')
|
||||
.controlText(videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||
}
|
||||
}, [videoTheaterMode]);
|
||||
|
||||
// when user clicks 'Unmute' button, turn audio on and hide unmute button
|
||||
function unmuteAndHideHint() {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
player.muted(false);
|
||||
if (player.volume() === 0) {
|
||||
player.volume(1.0);
|
||||
}
|
||||
}
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
|
||||
function retryVideoAfterFailure() {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
setReload(Date.now());
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function showTapButton(tapButton) {
|
||||
const setButtonVisibility = (theRef, newState) => {
|
||||
// Use the DOM to control the state of the button to prevent re-renders.
|
||||
if (theRef.current) {
|
||||
const curState = theRef.current.style.visibility === 'visible';
|
||||
if (newState !== curState) {
|
||||
theRef.current.style.visibility = newState ? 'visible' : 'hidden';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
switch (tapButton) {
|
||||
case TAP.NONE:
|
||||
setButtonVisibility(tapToUnmuteRef, false);
|
||||
setButtonVisibility(tapToRetryRef, false);
|
||||
break;
|
||||
case TAP.UNMUTE:
|
||||
setButtonVisibility(tapToUnmuteRef, true);
|
||||
setButtonVisibility(tapToRetryRef, false);
|
||||
break;
|
||||
case TAP.RETRY:
|
||||
setButtonVisibility(tapToUnmuteRef, false);
|
||||
setButtonVisibility(tapToRetryRef, true);
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw new Error('showTapButton: unexpected ref');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const touchOverlay = player.getChild('TouchOverlay');
|
||||
const controlBar = player.getChild('controlBar') || touchOverlay.getChild('controlBar');
|
||||
const autoplayButton = controlBar.getChild('AutoplayNextButton');
|
||||
|
||||
if (autoplayButton) {
|
||||
const title = autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off');
|
||||
|
||||
autoplayButton.controlText(title);
|
||||
autoplayButton.setAttribute('aria-label', title);
|
||||
autoplayButton.setAttribute('aria-checked', autoplaySetting);
|
||||
}
|
||||
}
|
||||
}, [autoplaySetting]);
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (replay && player) {
|
||||
player.play();
|
||||
}
|
||||
}, [replay]);
|
||||
|
||||
function initializeEvents() {
|
||||
const player = playerRef.current;
|
||||
// Add various event listeners to player
|
||||
player.one('play', onInitialPlay);
|
||||
player.on('play', resolveCtrlText);
|
||||
player.on('pause', resolveCtrlText);
|
||||
player.on('loadstart', resolveCtrlText);
|
||||
player.on('fullscreenchange', resolveCtrlText);
|
||||
player.on('volumechange', resolveCtrlText);
|
||||
player.on('volumechange', onVolumeChange);
|
||||
player.on('error', onError);
|
||||
// player.on('ended', onEnded);
|
||||
}
|
||||
|
||||
return {
|
||||
retryVideoAfterFailure,
|
||||
unmuteAndHideHint,
|
||||
initializeEvents,
|
||||
};
|
||||
};
|
||||
|
||||
export default VideoJsEvents;
|
||||
@@ -0,0 +1,69 @@
|
||||
// @flow
|
||||
const VideoJsFunctions = ({
|
||||
source,
|
||||
sourceType,
|
||||
videoJsOptions,
|
||||
isAudio,
|
||||
}: {
|
||||
source: string,
|
||||
sourceType: string,
|
||||
videoJsOptions: Object,
|
||||
isAudio: boolean,
|
||||
}) => {
|
||||
function detectFileType() {
|
||||
// $FlowFixMe
|
||||
return new Promise(async (res, rej) => {
|
||||
try {
|
||||
const response = await fetch(source, { method: 'HEAD', cache: 'no-store' });
|
||||
|
||||
// Temp variables to hold results
|
||||
let finalType = sourceType;
|
||||
let finalSource = source;
|
||||
|
||||
// override type if we receive an .m3u8 (transcoded mp4)
|
||||
// do we need to check if explicitly redirected
|
||||
// or is checking extension only a safer method
|
||||
if (response && response.redirected && response.url && response.url.endsWith('m3u8')) {
|
||||
finalType = 'application/x-mpegURL';
|
||||
finalSource = response.url;
|
||||
}
|
||||
|
||||
// Modify video source in options
|
||||
videoJsOptions.sources = [
|
||||
{
|
||||
src: finalSource,
|
||||
type: finalType,
|
||||
},
|
||||
];
|
||||
|
||||
return res(videoJsOptions);
|
||||
} catch (error) {
|
||||
return rej(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: can remove this function as well
|
||||
// Create the video DOM element and wrapper
|
||||
function createVideoPlayerDOM(container: any) {
|
||||
if (!container) return;
|
||||
|
||||
// This seems like a poor way to generate the DOM for video.js
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.setAttribute('data-vjs-player', 'true');
|
||||
const el = document.createElement(isAudio ? 'audio' : 'video');
|
||||
el.className = 'video-js vjs-big-play-centered ';
|
||||
wrapper.appendChild(el);
|
||||
|
||||
container.appendChild(wrapper);
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
return {
|
||||
detectFileType,
|
||||
createVideoPlayerDOM,
|
||||
};
|
||||
};
|
||||
|
||||
export default VideoJsFunctions;
|
||||
@@ -0,0 +1,157 @@
|
||||
// @flow
|
||||
import * as OVERLAY from './overlays';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import isUserTyping from 'util/detect-typing';
|
||||
|
||||
const SEEK_STEP_5 = 5;
|
||||
const SEEK_STEP = 10; // time to seek in seconds
|
||||
|
||||
const videoPlaybackRates = [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 1.75, 2];
|
||||
|
||||
// check if active (clicked) element is part of video div, used for keyboard shortcuts (volume etc)
|
||||
function activeElementIsPartOfVideoElement() {
|
||||
const videoElementParent = document.getElementsByClassName('video-js-parent')[0];
|
||||
const activeElement = document.activeElement;
|
||||
return videoElementParent.contains(activeElement);
|
||||
}
|
||||
|
||||
function volumeUp(event, playerRef) {
|
||||
// dont run if video element is not active element (otherwise runs when scrolling using keypad)
|
||||
const videoElementIsActive = activeElementIsPartOfVideoElement();
|
||||
const player = playerRef.current;
|
||||
if (!player || !videoElementIsActive) return;
|
||||
event.preventDefault();
|
||||
player.volume(player.volume() + 0.05);
|
||||
OVERLAY.showVolumeverlay(player, Math.round(player.volume() * 100));
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function volumeDown(event, playerRef) {
|
||||
// dont run if video element is not active element (otherwise runs when scrolling using keypad)
|
||||
const videoElementIsActive = activeElementIsPartOfVideoElement();
|
||||
const player = playerRef.current;
|
||||
if (!player || !videoElementIsActive) return;
|
||||
event.preventDefault();
|
||||
player.volume(player.volume() - 0.05);
|
||||
OVERLAY.showVolumeverlay(player, Math.round(player.volume() * 100));
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function seekVideo(stepSize: number, playerRef, containerRef) {
|
||||
const player = playerRef.current;
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode || !player) return;
|
||||
const duration = videoNode.duration;
|
||||
const currentTime = videoNode.currentTime;
|
||||
const newDuration = currentTime + stepSize;
|
||||
if (newDuration < 0) {
|
||||
videoNode.currentTime = 0;
|
||||
} else if (newDuration > duration) {
|
||||
videoNode.currentTime = duration;
|
||||
} else {
|
||||
videoNode.currentTime = newDuration;
|
||||
}
|
||||
OVERLAY.showSeekedOverlay(player, Math.abs(stepSize), stepSize > 0);
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function toggleFullscreen(playerRef) {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
if (!player.isFullscreen()) {
|
||||
player.requestFullscreen();
|
||||
} else {
|
||||
player.exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMute(containerRef) {
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode) return;
|
||||
videoNode.muted = !videoNode.muted;
|
||||
}
|
||||
|
||||
function togglePlay(containerRef) {
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode) return;
|
||||
videoNode.paused ? videoNode.play() : videoNode.pause();
|
||||
}
|
||||
|
||||
function changePlaybackSpeed(shouldSpeedUp: boolean, playerRef) {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
const isSpeedUp = shouldSpeedUp;
|
||||
const rate = player.playbackRate();
|
||||
let rateIndex = videoPlaybackRates.findIndex((x) => x === rate);
|
||||
if (rateIndex >= 0) {
|
||||
rateIndex = isSpeedUp ? Math.min(rateIndex + 1, videoPlaybackRates.length - 1) : Math.max(rateIndex - 1, 0);
|
||||
const nextRate = videoPlaybackRates[rateIndex];
|
||||
|
||||
OVERLAY.showPlaybackRateOverlay(player, nextRate, isSpeedUp);
|
||||
player.userActive(true);
|
||||
player.playbackRate(nextRate);
|
||||
}
|
||||
}
|
||||
|
||||
const VideoJsKeyboardShorcuts = ({
|
||||
playNext,
|
||||
playPrevious,
|
||||
toggleVideoTheaterMode,
|
||||
}: {
|
||||
playNext: any, // function
|
||||
playPrevious: any, // function
|
||||
toggleVideoTheaterMode: any, // function
|
||||
}) => {
|
||||
function toggleTheaterMode(playerRef) {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
// TODO: have to fix this
|
||||
toggleVideoTheaterMode();
|
||||
if (player.isFullscreen()) {
|
||||
player.exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyDown(e: KeyboardEvent, playerRef, containerRef) {
|
||||
const player = playerRef.current;
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode || !player || isUserTyping()) return;
|
||||
handleSingleKeyActions(e, playerRef, containerRef);
|
||||
handleShiftKeyActions(e, playerRef);
|
||||
}
|
||||
|
||||
function handleShiftKeyActions(e: KeyboardEvent, playerRef) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || !e.shiftKey) return;
|
||||
if (e.keyCode === KEYCODES.PERIOD) changePlaybackSpeed(true, playerRef);
|
||||
if (e.keyCode === KEYCODES.COMMA) changePlaybackSpeed(false, playerRef);
|
||||
if (e.keyCode === KEYCODES.N) playNext();
|
||||
if (e.keyCode === KEYCODES.P) playPrevious();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line flowtype/no-types-missing-file-annotation
|
||||
function handleSingleKeyActions(e: KeyboardEvent, playerRef, containerRef) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
||||
if (e.keyCode === KEYCODES.SPACEBAR || e.keyCode === KEYCODES.K) togglePlay(containerRef);
|
||||
if (e.keyCode === KEYCODES.F) toggleFullscreen(playerRef);
|
||||
if (e.keyCode === KEYCODES.M) toggleMute(containerRef);
|
||||
if (e.keyCode === KEYCODES.UP) volumeUp(e, playerRef);
|
||||
if (e.keyCode === KEYCODES.DOWN) volumeDown(e, playerRef);
|
||||
if (e.keyCode === KEYCODES.T) toggleTheaterMode(playerRef);
|
||||
if (e.keyCode === KEYCODES.L) seekVideo(SEEK_STEP, playerRef, containerRef);
|
||||
if (e.keyCode === KEYCODES.J) seekVideo(-SEEK_STEP, playerRef, containerRef);
|
||||
if (e.keyCode === KEYCODES.RIGHT) seekVideo(SEEK_STEP_5, playerRef, containerRef);
|
||||
if (e.keyCode === KEYCODES.LEFT) seekVideo(-SEEK_STEP_5, playerRef, containerRef);
|
||||
}
|
||||
|
||||
var curried_function = function (playerRef: any, containerRef: any) {
|
||||
return function curried_func(e: any) {
|
||||
handleKeyDown(e, playerRef, containerRef);
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
curried_function,
|
||||
};
|
||||
};
|
||||
|
||||
export default VideoJsKeyboardShorcuts;
|
||||
@@ -2,7 +2,6 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import Button from 'component/button';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import classnames from 'classnames';
|
||||
import videojs from 'video.js';
|
||||
import 'video.js/dist/alt/video-js-cdn.min.css';
|
||||
@@ -12,9 +11,10 @@ import './plugins/videojs-mobile-ui/plugin';
|
||||
import hlsQualitySelector from './plugins/videojs-hls-quality-selector/plugin';
|
||||
import recsys from './plugins/videojs-recsys/plugin';
|
||||
import qualityLevels from 'videojs-contrib-quality-levels';
|
||||
import isUserTyping from 'util/detect-typing';
|
||||
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
import LbryVolumeBarClass from './lbry-volume-bar';
|
||||
import keyboardShorcuts from './videojs-keyboard-shortcuts';
|
||||
import events from './videojs-events';
|
||||
import functions from './videojs-functions';
|
||||
|
||||
export type Player = {
|
||||
on: (string, (any) => void) => void,
|
||||
@@ -61,15 +61,6 @@ type Props = {
|
||||
playPrevious: () => void,
|
||||
};
|
||||
|
||||
// type VideoJSOptions = {
|
||||
// controls: boolean,
|
||||
// preload: string,
|
||||
// playbackRates: Array<number>,
|
||||
// responsive: boolean,
|
||||
// poster?: string,
|
||||
// muted?: boolean,
|
||||
// };
|
||||
|
||||
const videoPlaybackRates = [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 1.75, 2];
|
||||
|
||||
const IS_IOS =
|
||||
@@ -89,9 +80,6 @@ const VIDEO_JS_OPTIONS = {
|
||||
},
|
||||
};
|
||||
|
||||
const SEEK_STEP_5 = 5;
|
||||
const SEEK_STEP = 10; // time to seek in seconds
|
||||
|
||||
if (!Object.keys(videojs.getPlugins()).includes('eventTracking')) {
|
||||
videojs.registerPlugin('eventTracking', eventTracking);
|
||||
}
|
||||
@@ -108,47 +96,6 @@ if (!Object.keys(videojs.getPlugins()).includes('recsys')) {
|
||||
videojs.registerPlugin('recsys', recsys);
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// LbryVolumeBarClass
|
||||
// ****************************************************************************
|
||||
|
||||
const VIDEOJS_CONTROL_BAR_CLASS = 'ControlBar';
|
||||
const VIDEOJS_VOLUME_PANEL_CLASS = 'VolumePanel';
|
||||
const VIDEOJS_VOLUME_CONTROL_CLASS = 'VolumeControl';
|
||||
const VIDEOJS_VOLUME_BAR_CLASS = 'VolumeBar';
|
||||
|
||||
class LbryVolumeBarClass extends videojs.getComponent(VIDEOJS_VOLUME_BAR_CLASS) {
|
||||
constructor(player, options = {}) {
|
||||
super(player, options);
|
||||
}
|
||||
|
||||
static replaceExisting(player) {
|
||||
try {
|
||||
const volumeControl = player
|
||||
.getChild(VIDEOJS_CONTROL_BAR_CLASS)
|
||||
.getChild(VIDEOJS_VOLUME_PANEL_CLASS)
|
||||
.getChild(VIDEOJS_VOLUME_CONTROL_CLASS);
|
||||
const volumeBar = volumeControl.getChild(VIDEOJS_VOLUME_BAR_CLASS);
|
||||
volumeControl.removeChild(volumeBar);
|
||||
volumeControl.addChild(new LbryVolumeBarClass(player));
|
||||
} catch (error) {
|
||||
// In case it slips in 'Production', the original volume bar will be used and the site should still be working
|
||||
// (just not exactly the way we want).
|
||||
if (isDev) throw Error('\n\nvideojs.jsx: Volume Panel hierarchy changed?\n\n' + error);
|
||||
}
|
||||
}
|
||||
|
||||
handleMouseDown(event) {
|
||||
super.handleMouseDown(event);
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
handleMouseMove(event) {
|
||||
super.handleMouseMove(event);
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// VideoJs
|
||||
// ****************************************************************************
|
||||
@@ -175,9 +122,18 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
playPrevious,
|
||||
} = props;
|
||||
|
||||
const [reload, setReload] = useState('initial');
|
||||
// will later store the videojs player
|
||||
const playerRef = useRef();
|
||||
const containerRef = useRef();
|
||||
|
||||
const tapToUnmuteRef = useRef();
|
||||
const tapToRetryRef = useRef();
|
||||
|
||||
// initiate keyboard shortcuts
|
||||
const { curried_function } = keyboardShorcuts({ toggleVideoTheaterMode, playNext, playPrevious });
|
||||
|
||||
const [reload, setReload] = useState('initial');
|
||||
|
||||
const videoJsOptions = {
|
||||
...VIDEO_JS_OPTIONS,
|
||||
autoplay: autoplay,
|
||||
@@ -199,322 +155,17 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
},
|
||||
};
|
||||
|
||||
const tapToUnmuteRef = useRef();
|
||||
const tapToRetryRef = useRef();
|
||||
const { detectFileType, createVideoPlayerDOM } = functions({ source, sourceType, videoJsOptions, isAudio });
|
||||
|
||||
const TAP = {
|
||||
NONE: 'NONE',
|
||||
UNMUTE: 'UNMUTE',
|
||||
RETRY: 'RETRY',
|
||||
};
|
||||
|
||||
function showTapButton(tapButton) {
|
||||
const setButtonVisibility = (theRef, newState) => {
|
||||
// Use the DOM to control the state of the button to prevent re-renders.
|
||||
if (theRef.current) {
|
||||
const curState = theRef.current.style.visibility === 'visible';
|
||||
if (newState !== curState) {
|
||||
theRef.current.style.visibility = newState ? 'visible' : 'hidden';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
switch (tapButton) {
|
||||
case TAP.NONE:
|
||||
setButtonVisibility(tapToUnmuteRef, false);
|
||||
setButtonVisibility(tapToRetryRef, false);
|
||||
break;
|
||||
case TAP.UNMUTE:
|
||||
setButtonVisibility(tapToUnmuteRef, true);
|
||||
setButtonVisibility(tapToRetryRef, false);
|
||||
break;
|
||||
case TAP.RETRY:
|
||||
setButtonVisibility(tapToUnmuteRef, false);
|
||||
setButtonVisibility(tapToRetryRef, true);
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw new Error('showTapButton: unexpected ref');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function unmuteAndHideHint() {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
player.muted(false);
|
||||
if (player.volume() === 0) {
|
||||
player.volume(1.0);
|
||||
}
|
||||
}
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
|
||||
function retryVideoAfterFailure() {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
setReload(Date.now());
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function resolveCtrlText(e) {
|
||||
// Override the player's control text. We override to:
|
||||
// 1. Add keyboard shortcut to the tool-tip.
|
||||
// 2. Override videojs' i18n and use our own (don't want to have 2 systems).
|
||||
//
|
||||
// Notes:
|
||||
// - For dynamic controls (e.g. play/pause), those unfortunately need to be
|
||||
// updated again at their event-listener level (that's just the way videojs
|
||||
// updates the text), hence the need to listen to 'play', 'pause' and 'volumechange'
|
||||
// on top of just 'loadstart'.
|
||||
// - videojs changes the MuteToggle text at 'loadstart', so this was chosen
|
||||
// as the listener to update static texts.
|
||||
|
||||
const setLabel = (controlBar, childName, label) => {
|
||||
const c = controlBar.getChild(childName);
|
||||
if (c) {
|
||||
c.controlText(label);
|
||||
}
|
||||
};
|
||||
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const ctrlBar = player.getChild('controlBar');
|
||||
switch (e.type) {
|
||||
case 'play':
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Pause (space)'));
|
||||
break;
|
||||
case 'pause':
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Play (space)'));
|
||||
break;
|
||||
case 'volumechange':
|
||||
ctrlBar
|
||||
.getChild('VolumePanel')
|
||||
.getChild('MuteToggle')
|
||||
.controlText(player.muted() || player.volume() === 0 ? __('Unmute (m)') : __('Mute (m)'));
|
||||
break;
|
||||
case 'fullscreenchange':
|
||||
setLabel(
|
||||
ctrlBar,
|
||||
'FullscreenToggle',
|
||||
player.isFullscreen() ? __('Exit Fullscreen (f)') : __('Fullscreen (f)')
|
||||
);
|
||||
break;
|
||||
case 'loadstart':
|
||||
// --- Do everything ---
|
||||
setLabel(ctrlBar, 'PlaybackRateMenuButton', __('Playback Rate (<, >)'));
|
||||
setLabel(ctrlBar, 'QualityButton', __('Quality'));
|
||||
setLabel(ctrlBar, 'PlayNextButton', __('Play Next (SHIFT+N)'));
|
||||
setLabel(ctrlBar, 'PlayPreviousButton', __('Play Previous (SHIFT+P)'));
|
||||
setLabel(ctrlBar, 'TheaterModeButton', videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||
setLabel(ctrlBar, 'AutoplayNextButton', autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off'));
|
||||
|
||||
resolveCtrlText({ type: 'play' });
|
||||
resolveCtrlText({ type: 'pause' });
|
||||
resolveCtrlText({ type: 'volumechange' });
|
||||
resolveCtrlText({ type: 'fullscreenchange' });
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw Error('Unexpected: ' + e.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onInitialPlay() {
|
||||
const player = playerRef.current;
|
||||
if (player && (player.muted() || player.volume() === 0)) {
|
||||
// The css starts as "hidden". We make it visible here without
|
||||
// re-rendering the whole thing.
|
||||
showTapButton(TAP.UNMUTE);
|
||||
} else {
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function onVolumeChange() {
|
||||
const player = playerRef.current;
|
||||
if (player && !player.muted()) {
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function onError() {
|
||||
const player = playerRef.current;
|
||||
showTapButton(TAP.RETRY);
|
||||
|
||||
// reattach initial play listener in case we recover from error successfully
|
||||
// $FlowFixMe
|
||||
player.one('play', onInitialPlay);
|
||||
|
||||
if (player && player.loadingSpinner) {
|
||||
player.loadingSpinner.hide();
|
||||
}
|
||||
}
|
||||
|
||||
const onEnded = React.useCallback(() => {
|
||||
// not sure if this is necessary - used to be dependent on !adUrl
|
||||
showTapButton(TAP.NONE);
|
||||
}, []);
|
||||
|
||||
function handleKeyDown(e: KeyboardEvent) {
|
||||
const player = playerRef.current;
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode || !player || isUserTyping()) return;
|
||||
handleSingleKeyActions(e);
|
||||
handleShiftKeyActions(e);
|
||||
}
|
||||
|
||||
function handleShiftKeyActions(e: KeyboardEvent) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || !e.shiftKey) return;
|
||||
if (e.keyCode === KEYCODES.PERIOD) changePlaybackSpeed(true);
|
||||
if (e.keyCode === KEYCODES.COMMA) changePlaybackSpeed(false);
|
||||
if (e.keyCode === KEYCODES.N) playNext();
|
||||
if (e.keyCode === KEYCODES.P) playPrevious();
|
||||
}
|
||||
|
||||
function handleSingleKeyActions(e: KeyboardEvent) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
||||
if (e.keyCode === KEYCODES.SPACEBAR || e.keyCode === KEYCODES.K) togglePlay();
|
||||
if (e.keyCode === KEYCODES.F) toggleFullscreen();
|
||||
if (e.keyCode === KEYCODES.M) toggleMute();
|
||||
if (e.keyCode === KEYCODES.UP) volumeUp();
|
||||
if (e.keyCode === KEYCODES.DOWN) volumeDown();
|
||||
if (e.keyCode === KEYCODES.T) toggleTheaterMode();
|
||||
if (e.keyCode === KEYCODES.L) seekVideo(SEEK_STEP);
|
||||
if (e.keyCode === KEYCODES.J) seekVideo(-SEEK_STEP);
|
||||
if (e.keyCode === KEYCODES.RIGHT) seekVideo(SEEK_STEP_5);
|
||||
if (e.keyCode === KEYCODES.LEFT) seekVideo(-SEEK_STEP_5);
|
||||
}
|
||||
|
||||
function seekVideo(stepSize: number) {
|
||||
const player = playerRef.current;
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode || !player) return;
|
||||
const duration = videoNode.duration;
|
||||
const currentTime = videoNode.currentTime;
|
||||
const newDuration = currentTime + stepSize;
|
||||
if (newDuration < 0) {
|
||||
videoNode.currentTime = 0;
|
||||
} else if (newDuration > duration) {
|
||||
videoNode.currentTime = duration;
|
||||
} else {
|
||||
videoNode.currentTime = newDuration;
|
||||
}
|
||||
OVERLAY.showSeekedOverlay(player, Math.abs(stepSize), stepSize > 0);
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function changePlaybackSpeed(shouldSpeedUp: boolean) {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
const isSpeedUp = shouldSpeedUp;
|
||||
const rate = player.playbackRate();
|
||||
let rateIndex = videoPlaybackRates.findIndex((x) => x === rate);
|
||||
if (rateIndex >= 0) {
|
||||
rateIndex = isSpeedUp ? Math.min(rateIndex + 1, videoPlaybackRates.length - 1) : Math.max(rateIndex - 1, 0);
|
||||
const nextRate = videoPlaybackRates[rateIndex];
|
||||
|
||||
OVERLAY.showPlaybackRateOverlay(player, nextRate, isSpeedUp);
|
||||
player.userActive(true);
|
||||
player.playbackRate(nextRate);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleFullscreen() {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
if (!player.isFullscreen()) {
|
||||
player.requestFullscreen();
|
||||
} else {
|
||||
player.exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTheaterMode() {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
toggleVideoTheaterMode();
|
||||
if (player.isFullscreen()) {
|
||||
player.exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMute() {
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode) return;
|
||||
videoNode.muted = !videoNode.muted;
|
||||
}
|
||||
|
||||
function togglePlay() {
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode) return;
|
||||
videoNode.paused ? videoNode.play() : videoNode.pause();
|
||||
}
|
||||
|
||||
function volumeUp() {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
player.volume(player.volume() + 0.05);
|
||||
OVERLAY.showVolumeverlay(player, Math.round(player.volume() * 100));
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function volumeDown() {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
player.volume(player.volume() - 0.05);
|
||||
OVERLAY.showVolumeverlay(player, Math.round(player.volume() * 100));
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
// Create the video DOM element and wrapper
|
||||
function createVideoPlayerDOM(container) {
|
||||
if (!container) return;
|
||||
|
||||
// This seems like a poor way to generate the DOM for video.js
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.setAttribute('data-vjs-player', 'true');
|
||||
const el = document.createElement(isAudio ? 'audio' : 'video');
|
||||
el.className = 'video-js vjs-big-play-centered ';
|
||||
wrapper.appendChild(el);
|
||||
|
||||
container.appendChild(wrapper);
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
function detectFileType() {
|
||||
return new Promise(async (res, rej) => {
|
||||
try {
|
||||
const response = await fetch(source, { method: 'HEAD', cache: 'no-store' });
|
||||
|
||||
// Temp variables to hold results
|
||||
let finalType = sourceType;
|
||||
let finalSource = source;
|
||||
|
||||
// override type if we receive an .m3u8 (transcoded mp4)
|
||||
// do we need to check if explicitly redirected
|
||||
// or is checking extension only a safer method
|
||||
if (response && response.redirected && response.url && response.url.endsWith('m3u8')) {
|
||||
finalType = 'application/x-mpegURL';
|
||||
finalSource = response.url;
|
||||
}
|
||||
|
||||
// Modify video source in options
|
||||
videoJsOptions.sources = [
|
||||
{
|
||||
src: finalSource,
|
||||
type: finalType,
|
||||
},
|
||||
];
|
||||
|
||||
return res(videoJsOptions);
|
||||
} catch (error) {
|
||||
return rej(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
const { unmuteAndHideHint, retryVideoAfterFailure, initializeEvents } = events({
|
||||
tapToUnmuteRef,
|
||||
tapToRetryRef,
|
||||
setReload,
|
||||
videoTheaterMode,
|
||||
playerRef,
|
||||
autoplaySetting,
|
||||
replay,
|
||||
});
|
||||
|
||||
// Initialize video.js
|
||||
function initializeVideoPlayer(el) {
|
||||
@@ -526,16 +177,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
// this seems like a weird thing to have to check for here
|
||||
if (!player) return;
|
||||
|
||||
// Add various event listeners to player
|
||||
player.one('play', onInitialPlay);
|
||||
player.on('play', resolveCtrlText);
|
||||
player.on('pause', resolveCtrlText);
|
||||
player.on('loadstart', resolveCtrlText);
|
||||
player.on('fullscreenchange', resolveCtrlText);
|
||||
player.on('volumechange', resolveCtrlText);
|
||||
player.on('volumechange', onVolumeChange);
|
||||
player.on('error', onError);
|
||||
player.on('ended', onEnded);
|
||||
initializeEvents();
|
||||
|
||||
// Replace volume bar with custom LBRY volume bar
|
||||
LbryVolumeBarClass.replaceExisting(player);
|
||||
@@ -560,7 +202,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
}
|
||||
|
||||
// set playsinline for mobile
|
||||
// TODO: make this better
|
||||
player.children_[0].setAttribute('playsinline', '');
|
||||
|
||||
// I think this is a callback function
|
||||
@@ -568,45 +209,14 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
onPlayerReady(player, videoNode);
|
||||
});
|
||||
|
||||
// fixes #3498 (https://github.com/lbryio/lbry-desktop/issues/3498)
|
||||
// summary: on firefox the focus would stick to the fullscreen button which caused buggy behavior with spacebar
|
||||
vjs.on('fullscreenchange', () => document.activeElement && document.activeElement.blur());
|
||||
|
||||
return vjs;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (replay && player) {
|
||||
player.play();
|
||||
}
|
||||
}, [replay]);
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const controlBar = player.getChild('controlBar');
|
||||
controlBar
|
||||
.getChild('TheaterModeButton')
|
||||
.controlText(videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||
}
|
||||
}, [videoTheaterMode]);
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const touchOverlay = player.getChild('TouchOverlay');
|
||||
const controlBar = player.getChild('controlBar') || touchOverlay.getChild('controlBar');
|
||||
const autoplayButton = controlBar.getChild('AutoplayNextButton');
|
||||
|
||||
if (autoplayButton) {
|
||||
const title = autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off');
|
||||
|
||||
autoplayButton.controlText(title);
|
||||
autoplayButton.setAttribute('aria-label', title);
|
||||
autoplayButton.setAttribute('aria-checked', autoplaySetting);
|
||||
}
|
||||
}
|
||||
}, [autoplaySetting]);
|
||||
|
||||
/** instantiate videoJS and dispose of it when done with code **/
|
||||
// This lifecycle hook is only called once (on mount), or when `isAudio` or `source` changes.
|
||||
useEffect(() => {
|
||||
const vjsElement = createVideoPlayerDOM(containerRef.current);
|
||||
@@ -622,13 +232,12 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
// Set reference in component state
|
||||
playerRef.current = vjsPlayer;
|
||||
|
||||
// Add event listener for keyboard shortcuts
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
window.addEventListener('keydown', curried_function(playerRef, containerRef));
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
window.removeEventListener('keydown', curried_function);
|
||||
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// https://github.com/carmelopullara/react-feather
|
||||
// Note: Icons should be named for their purpose, rather than the actual icon.
|
||||
// The goal being to reduce multiple uses of the same icon for different purposes.
|
||||
//
|
||||
|
||||
export const REWARDS = 'Award';
|
||||
export const LOCAL = 'Folder';
|
||||
export const ALERT = 'AlertCircle';
|
||||
@@ -68,6 +68,7 @@ export const UP = 'ChevronUp';
|
||||
export const UP_TOP = 'ChevronUpTop';
|
||||
export const DOWN = 'ChevronDown';
|
||||
export const DOWN_BOTTOM = 'ChevronDownBottom';
|
||||
export const DRAG = 'DragAndDrop';
|
||||
export const SECURE = 'Lock';
|
||||
export const MENU = 'Menu';
|
||||
export const BACKUP = 'Database';
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
export const VALID_IPADDRESS_REGEX = new RegExp(
|
||||
'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\.)){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'
|
||||
);
|
||||
export const VALID_HOSTNAME_REGEX = new RegExp(
|
||||
'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(\\.))+([A-Za-z]|[A-Za-z][A-Za-z]*[A-Za-z])$'
|
||||
);
|
||||
|
||||
export const VALID_ENDPOINT_REGEX = new RegExp('^((\\/)([a-zA-Z0-9]+))+$');
|
||||
@@ -41,6 +41,7 @@ export const VIDEO_THEATER_MODE = 'video_theater_mode';
|
||||
export const VIDEO_PLAYBACK_RATE = 'video_playback_rate';
|
||||
export const CUSTOM_COMMENTS_SERVER_ENABLED = 'custom_comments_server_enabled';
|
||||
export const CUSTOM_COMMENTS_SERVER_URL = 'custom_comments_server_url';
|
||||
export const CUSTOM_COMMENTS_SERVERS = 'custom_comments_servers';
|
||||
export const CUSTOM_SHARE_URL_ENABLED = 'custom_share_url_enabled';
|
||||
export const CUSTOM_SHARE_URL = 'custom_share_url';
|
||||
export const ENABLE_PRERELEASE_UPDATES = 'enable_prerelease_updates';
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export const useActiveElement = () => {
|
||||
const [active, setActive] = useState(document.activeElement);
|
||||
|
||||
const handleFocus = (e) => {
|
||||
setActive(document.activeElement);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener('focusin', handleFocus);
|
||||
document.addEventListener('focusout', handleFocus);
|
||||
return () => {
|
||||
document.removeEventListener('focusin', handleFocus);
|
||||
document.removeEventListener('focusout', handleFocus);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return active;
|
||||
};
|
||||
@@ -1,55 +0,0 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { VASTClient } from 'vast-client';
|
||||
import analytics from 'analytics';
|
||||
|
||||
const PRE_ROLL_ADS_PROVIDER = 'https://tag.targeting.unrulymedia.com/rmp/216276/0/vast2?vastfw=vpaid&w=300&h=500&url=';
|
||||
|
||||
// Ignores any call made 1 minutes or less after the last successful ad
|
||||
const ADS_CAP_LEVEL = 1 * 60 * 1000;
|
||||
const vastClient = new VASTClient(0, ADS_CAP_LEVEL);
|
||||
|
||||
export function useGetAds(approvedVideo: boolean, adsEnabled: boolean): [?string, (?string) => void, boolean] {
|
||||
const [isFetching, setIsFetching] = React.useState(true);
|
||||
const [adUrl, setAdUrl] = React.useState();
|
||||
|
||||
// Fetch ads for all approved videos, even if we won't show ads to the user
|
||||
// Unruly needs more fetches before they will start returning ads ¯\_(ツ)_/¯
|
||||
React.useEffect(() => {
|
||||
if (!approvedVideo) {
|
||||
setIsFetching(false);
|
||||
return;
|
||||
}
|
||||
|
||||
analytics.adsFetchedEvent();
|
||||
const encodedHref = encodeURI(window.location.href);
|
||||
const url = `${PRE_ROLL_ADS_PROVIDER}${encodedHref}`;
|
||||
// Used for testing on local dev
|
||||
// const url = 'https://raw.githubusercontent.com/dailymotion/vast-client-js/master/test/vastfiles/sample.xml';
|
||||
|
||||
vastClient
|
||||
.get(url)
|
||||
.then((res) => {
|
||||
if (res.ads.length > 0) {
|
||||
// Let this line error if res.ads is empty
|
||||
// I took this from an example response from Dailymotion
|
||||
// It will be caught below and sent to matomo to figure out if there if this needs to be something changed to deal with unrulys data
|
||||
const adUrl = res.ads[0].creatives[0].mediaFiles[0].fileURL;
|
||||
|
||||
// Dummy video file
|
||||
// const adUrl = 'https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4';
|
||||
|
||||
if (adsEnabled && adUrl) {
|
||||
setAdUrl(adUrl);
|
||||
}
|
||||
}
|
||||
|
||||
setIsFetching(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setIsFetching(false);
|
||||
});
|
||||
}, [approvedVideo, adsEnabled]);
|
||||
|
||||
return [adUrl, setAdUrl, isFetching];
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { useActiveElement } from './use-active-element';
|
||||
export default function useHistoryNav(history) {
|
||||
const el = useActiveElement(); // disable if we're in a textarea.
|
||||
useEffect(() => {
|
||||
const handleKeyPress = e => {
|
||||
const handleKeyPress = (e) => {
|
||||
if ((e.metaKey || e.altKey) && !e.ctrlKey && !e.shiftKey) {
|
||||
switch (e.code) {
|
||||
case 'ArrowLeft':
|
||||
@@ -19,7 +20,9 @@ export default function useHistoryNav(history) {
|
||||
}
|
||||
}
|
||||
};
|
||||
window.addEventListener('keydown', handleKeyPress);
|
||||
if (!el.type || (el.type && !el.type.startsWith('text'))) {
|
||||
window.addEventListener('keydown', handleKeyPress);
|
||||
}
|
||||
return () => window.removeEventListener('keydown', handleKeyPress);
|
||||
}, []);
|
||||
}, [el]);
|
||||
}
|
||||
@@ -72,6 +72,100 @@ import ModalWalletUnlock from 'modal/modalWalletUnlock';
|
||||
|
||||
import ModalYoutubeWelcome from 'modal/modalYoutubeWelcome';
|
||||
|
||||
function getModal(id) {
|
||||
switch (id) {
|
||||
case MODALS.UPGRADE:
|
||||
return ModalUpgrade;
|
||||
case MODALS.DOWNLOADING:
|
||||
return ModalDownloading;
|
||||
case MODALS.AUTO_GENERATE_THUMBNAIL:
|
||||
return ModalAutoGenerateThumbnail;
|
||||
case MODALS.AUTO_UPDATE_DOWNLOADED:
|
||||
return ModalAutoUpdateDownloaded;
|
||||
case MODALS.ERROR:
|
||||
return ModalError;
|
||||
case MODALS.FILE_TIMEOUT:
|
||||
return ModalFileTimeout;
|
||||
case MODALS.FIRST_REWARD:
|
||||
return ModalFirstReward;
|
||||
case MODALS.TRANSACTION_FAILED:
|
||||
return ModalTransactionFailed;
|
||||
case MODALS.CONFIRM_FILE_REMOVE:
|
||||
return ModalRemoveFile;
|
||||
case MODALS.AFFIRM_PURCHASE:
|
||||
return ModalAffirmPurchase;
|
||||
case MODALS.CONFIRM_CLAIM_REVOKE:
|
||||
return ModalRevokeClaim;
|
||||
case MODALS.PHONE_COLLECTION:
|
||||
return ModalPhoneCollection;
|
||||
case MODALS.FIRST_SUBSCRIPTION:
|
||||
return ModalFirstSubscription;
|
||||
case MODALS.SEND_TIP:
|
||||
return ModalSendTip;
|
||||
case MODALS.REPOST:
|
||||
return ModalRepost;
|
||||
case MODALS.SOCIAL_SHARE:
|
||||
return ModalSocialShare;
|
||||
case MODALS.PUBLISH:
|
||||
return ModalPublish;
|
||||
case MODALS.PUBLISH_PREVIEW:
|
||||
return ModalPublishPreview;
|
||||
case MODALS.CONFIRM_EXTERNAL_RESOURCE:
|
||||
return ModalOpenExternalResource;
|
||||
case MODALS.CONFIRM_TRANSACTION:
|
||||
return ModalConfirmTransaction;
|
||||
case MODALS.CONFIRM_THUMBNAIL_UPLOAD:
|
||||
return ModalConfirmThumbnailUpload;
|
||||
case MODALS.WALLET_ENCRYPT:
|
||||
return ModalWalletEncrypt;
|
||||
case MODALS.WALLET_DECRYPT:
|
||||
return ModalWalletDecrypt;
|
||||
case MODALS.WALLET_UNLOCK:
|
||||
return ModalWalletUnlock;
|
||||
case MODALS.WALLET_PASSWORD_UNSAVE:
|
||||
return ModalPasswordUnsave;
|
||||
case MODALS.REWARD_GENERATED_CODE:
|
||||
return ModalRewardCode;
|
||||
case MODALS.COMMENT_ACKNOWEDGEMENT:
|
||||
return ModalCommentAcknowledgement;
|
||||
case MODALS.YOUTUBE_WELCOME:
|
||||
return ModalYoutubeWelcome;
|
||||
case MODALS.SET_REFERRER:
|
||||
return ModalSetReferrer;
|
||||
case MODALS.SIGN_OUT:
|
||||
return ModalSignOut;
|
||||
case MODALS.CONFIRM_AGE:
|
||||
return ModalConfirmAge;
|
||||
case MODALS.FILE_SELECTION:
|
||||
return ModalFileSelection;
|
||||
case MODALS.LIQUIDATE_SUPPORTS:
|
||||
return ModalSupportsLiquidate;
|
||||
case MODALS.IMAGE_UPLOAD:
|
||||
return ModalImageUpload;
|
||||
case MODALS.SYNC_ENABLE:
|
||||
return ModalSyncEnable;
|
||||
case MODALS.MOBILE_SEARCH:
|
||||
return ModalMobileSearch;
|
||||
case MODALS.VIEW_IMAGE:
|
||||
return ModalViewImage;
|
||||
case MODALS.MASS_TIP_UNLOCK:
|
||||
return ModalMassTipsUnlock;
|
||||
case MODALS.CONFIRM_REMOVE_BTC_SWAP_ADDRESS:
|
||||
return ModalRemoveBtcSwapAddress;
|
||||
case MODALS.BLOCK_CHANNEL:
|
||||
return ModalBlockChannel;
|
||||
case MODALS.COLLECTION_ADD:
|
||||
return ModalClaimCollectionAdd;
|
||||
case MODALS.COLLECTION_DELETE:
|
||||
return ModalDeleteCollection;
|
||||
case MODALS.CONFIRM_REMOVE_CARD:
|
||||
return ModalRemoveCard;
|
||||
case MODALS.CONFIRM_REMOVE_COMMENT:
|
||||
return ModalRemoveComment;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
type Props = {
|
||||
modal: { id: string, modalProps: {} },
|
||||
error: { message: string },
|
||||
@@ -94,102 +188,6 @@ function ModalRouter(props: Props) {
|
||||
if (!modal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function getModal(id) {
|
||||
switch (id) {
|
||||
case MODALS.UPGRADE:
|
||||
return ModalUpgrade;
|
||||
case MODALS.DOWNLOADING:
|
||||
return ModalDownloading;
|
||||
case MODALS.AUTO_GENERATE_THUMBNAIL:
|
||||
return ModalAutoGenerateThumbnail;
|
||||
case MODALS.AUTO_UPDATE_DOWNLOADED:
|
||||
return ModalAutoUpdateDownloaded;
|
||||
case MODALS.ERROR:
|
||||
return ModalError;
|
||||
case MODALS.FILE_TIMEOUT:
|
||||
return ModalFileTimeout;
|
||||
case MODALS.FIRST_REWARD:
|
||||
return ModalFirstReward;
|
||||
case MODALS.TRANSACTION_FAILED:
|
||||
return ModalTransactionFailed;
|
||||
case MODALS.CONFIRM_FILE_REMOVE:
|
||||
return ModalRemoveFile;
|
||||
case MODALS.AFFIRM_PURCHASE:
|
||||
return ModalAffirmPurchase;
|
||||
case MODALS.CONFIRM_CLAIM_REVOKE:
|
||||
return ModalRevokeClaim;
|
||||
case MODALS.PHONE_COLLECTION:
|
||||
return ModalPhoneCollection;
|
||||
case MODALS.FIRST_SUBSCRIPTION:
|
||||
return ModalFirstSubscription;
|
||||
case MODALS.SEND_TIP:
|
||||
return ModalSendTip;
|
||||
case MODALS.REPOST:
|
||||
return ModalRepost;
|
||||
case MODALS.SOCIAL_SHARE:
|
||||
return ModalSocialShare;
|
||||
case MODALS.PUBLISH:
|
||||
return ModalPublish;
|
||||
case MODALS.PUBLISH_PREVIEW:
|
||||
return ModalPublishPreview;
|
||||
case MODALS.CONFIRM_EXTERNAL_RESOURCE:
|
||||
return ModalOpenExternalResource;
|
||||
case MODALS.CONFIRM_TRANSACTION:
|
||||
return ModalConfirmTransaction;
|
||||
case MODALS.CONFIRM_THUMBNAIL_UPLOAD:
|
||||
return ModalConfirmThumbnailUpload;
|
||||
case MODALS.WALLET_ENCRYPT:
|
||||
return ModalWalletEncrypt;
|
||||
case MODALS.WALLET_DECRYPT:
|
||||
return ModalWalletDecrypt;
|
||||
case MODALS.WALLET_UNLOCK:
|
||||
return ModalWalletUnlock;
|
||||
case MODALS.WALLET_PASSWORD_UNSAVE:
|
||||
return ModalPasswordUnsave;
|
||||
case MODALS.REWARD_GENERATED_CODE:
|
||||
return ModalRewardCode;
|
||||
case MODALS.COMMENT_ACKNOWEDGEMENT:
|
||||
return ModalCommentAcknowledgement;
|
||||
case MODALS.YOUTUBE_WELCOME:
|
||||
return ModalYoutubeWelcome;
|
||||
case MODALS.SET_REFERRER:
|
||||
return ModalSetReferrer;
|
||||
case MODALS.SIGN_OUT:
|
||||
return ModalSignOut;
|
||||
case MODALS.CONFIRM_AGE:
|
||||
return ModalConfirmAge;
|
||||
case MODALS.FILE_SELECTION:
|
||||
return ModalFileSelection;
|
||||
case MODALS.LIQUIDATE_SUPPORTS:
|
||||
return ModalSupportsLiquidate;
|
||||
case MODALS.IMAGE_UPLOAD:
|
||||
return ModalImageUpload;
|
||||
case MODALS.SYNC_ENABLE:
|
||||
return ModalSyncEnable;
|
||||
case MODALS.MOBILE_SEARCH:
|
||||
return ModalMobileSearch;
|
||||
case MODALS.VIEW_IMAGE:
|
||||
return ModalViewImage;
|
||||
case MODALS.MASS_TIP_UNLOCK:
|
||||
return ModalMassTipsUnlock;
|
||||
case MODALS.CONFIRM_REMOVE_BTC_SWAP_ADDRESS:
|
||||
return ModalRemoveBtcSwapAddress;
|
||||
case MODALS.BLOCK_CHANNEL:
|
||||
return ModalBlockChannel;
|
||||
case MODALS.COLLECTION_ADD:
|
||||
return ModalClaimCollectionAdd;
|
||||
case MODALS.COLLECTION_DELETE:
|
||||
return ModalDeleteCollection;
|
||||
case MODALS.CONFIRM_REMOVE_CARD:
|
||||
return ModalRemoveCard;
|
||||
case MODALS.CONFIRM_REMOVE_COMMENT:
|
||||
return ModalRemoveComment;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const { id, modalProps } = modal;
|
||||
const SelectedModal = getModal(id);
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// @flow
|
||||
|
||||
// $FlowFixMe
|
||||
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
|
||||
|
||||
import React from 'react';
|
||||
import ClaimList from 'component/claimList';
|
||||
import Page from 'component/page';
|
||||
@@ -51,6 +55,7 @@ export default function CollectionPage(props: Props) {
|
||||
collectionHasEdits,
|
||||
claimIsPending,
|
||||
isResolvingCollection,
|
||||
editCollection,
|
||||
fetchCollectionItems,
|
||||
deleteCollection,
|
||||
} = props;
|
||||
@@ -63,9 +68,22 @@ export default function CollectionPage(props: Props) {
|
||||
const [didTryResolve, setDidTryResolve] = React.useState(false);
|
||||
const [showInfo, setShowInfo] = React.useState(false);
|
||||
const [showEdit, setShowEdit] = React.useState(false);
|
||||
const [unavailableUris, setUnavailable] = React.useState([]);
|
||||
|
||||
const { name, totalItems } = collection || {};
|
||||
const isBuiltin = COLLECTIONS_CONSTS.BUILTIN_LISTS.includes(collectionId);
|
||||
|
||||
function handleOnDragEnd(result) {
|
||||
const { source, destination } = result;
|
||||
|
||||
if (!destination) return;
|
||||
|
||||
const { index: from } = source;
|
||||
const { index: to } = destination;
|
||||
|
||||
editCollection(collectionId, { order: { from, to } });
|
||||
}
|
||||
|
||||
const urlParams = new URLSearchParams(search);
|
||||
const editing = urlParams.get(PAGE_VIEW_QUERY) === EDIT_PAGE;
|
||||
|
||||
@@ -94,6 +112,18 @@ export default function CollectionPage(props: Props) {
|
||||
/>
|
||||
);
|
||||
|
||||
const removeUnavailable = (
|
||||
<Button
|
||||
button="close"
|
||||
icon={ICONS.DELETE}
|
||||
label={__('Remove all unavailable claims')}
|
||||
onClick={() => {
|
||||
editCollection(collectionId, { uris: unavailableUris, remove: true });
|
||||
setUnavailable([]);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
let titleActions;
|
||||
if (collectionHasEdits) {
|
||||
titleActions = unpublished;
|
||||
@@ -124,7 +154,7 @@ export default function CollectionPage(props: Props) {
|
||||
{claim ? claim.value.title || claim.name : collection && collection.name}
|
||||
</span>
|
||||
}
|
||||
titleActions={titleActions}
|
||||
titleActions={unavailableUris.length > 0 ? removeUnavailable : titleActions}
|
||||
subtitle={subTitle}
|
||||
body={
|
||||
<CollectionActions
|
||||
@@ -191,7 +221,20 @@ export default function CollectionPage(props: Props) {
|
||||
<Page>
|
||||
<div className={classnames('section card-stack')}>
|
||||
{info}
|
||||
<ClaimList uris={collectionUrls} collectionId={collectionId} type={showEdit ? 'listview' : undefined} />
|
||||
|
||||
<DragDropContext onDragEnd={handleOnDragEnd}>
|
||||
<Droppable droppableId="list__ordering">
|
||||
{(DroppableProvided) => (
|
||||
<ClaimList
|
||||
uris={collectionUrls}
|
||||
collectionId={collectionId}
|
||||
showEdit={showEdit}
|
||||
droppableProvided={DroppableProvided}
|
||||
unavailableUris={unavailableUris}
|
||||
/>
|
||||
)}
|
||||
</Droppable>
|
||||
</DragDropContext>
|
||||
</div>
|
||||
</Page>
|
||||
);
|
||||
|
||||
+27
-12
@@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import { SITE_NAME, ENABLE_NO_SOURCE_CLAIMS } from 'config';
|
||||
import { SITE_NAME } from 'config';
|
||||
import React from 'react';
|
||||
import Page from 'component/page';
|
||||
import Button from 'component/button';
|
||||
@@ -9,6 +9,7 @@ import ClaimTilesDiscover from 'component/claimTilesDiscover';
|
||||
import ClaimPreviewTile from 'component/claimPreviewTile';
|
||||
import Icon from 'component/common/icon';
|
||||
import WaitUntilOnPage from 'component/common/wait-until-on-page';
|
||||
import { useIsLargeScreen } from 'effects/use-screensize'; // have this?
|
||||
import { GetLinksData } from 'util/buildHomepage';
|
||||
|
||||
type Props = {
|
||||
@@ -24,9 +25,11 @@ function HomePage(props: Props) {
|
||||
const showPersonalizedChannels = subscribedChannels && subscribedChannels.length > 0;
|
||||
const showPersonalizedTags = followedTags && followedTags.length > 0;
|
||||
const showIndividualTags = showPersonalizedTags && followedTags.length < 5;
|
||||
const isLargeScreen = useIsLargeScreen();
|
||||
|
||||
const rowData: Array<RowDataItem> = GetLinksData(
|
||||
homepageData,
|
||||
isLargeScreen,
|
||||
true,
|
||||
authenticated,
|
||||
showPersonalizedChannels,
|
||||
@@ -37,29 +40,40 @@ function HomePage(props: Props) {
|
||||
showNsfw
|
||||
);
|
||||
|
||||
type SectionHeaderProps = {
|
||||
title: string,
|
||||
navigate?: string,
|
||||
icon?: string,
|
||||
help?: string,
|
||||
};
|
||||
const SectionHeader = ({ title, navigate = '/', icon = '', help }: SectionHeaderProps) => {
|
||||
return (
|
||||
<h1 className="claim-grid__header">
|
||||
<Button navigate={navigate} button="link">
|
||||
<Icon className="claim-grid__header-icon" sectionIcon icon={icon} size={20} />
|
||||
<span className="claim-grid__title">{title}</span>
|
||||
{help}
|
||||
</Button>
|
||||
</h1>
|
||||
);
|
||||
};
|
||||
|
||||
function getRowElements(title, route, link, icon, help, options, index, pinUrls) {
|
||||
const tilePlaceholder = (
|
||||
<ul className="claim-grid">
|
||||
{new Array(options.pageSize || 8).fill(1).map((x, i) => (
|
||||
<ClaimPreviewTile showNoSourceClaims={ENABLE_NO_SOURCE_CLAIMS} key={i} placeholder />
|
||||
<ClaimPreviewTile key={i} placeholder />
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
|
||||
const claimTiles = (
|
||||
<ClaimTilesDiscover {...options} showNoSourceClaims={ENABLE_NO_SOURCE_CLAIMS} hasSource pinUrls={pinUrls} />
|
||||
);
|
||||
const claimTiles = <ClaimTilesDiscover {...options} hasSource pinUrls={pinUrls} />;
|
||||
|
||||
return (
|
||||
<div key={title} className="claim-grid__wrapper">
|
||||
{/* category header */}
|
||||
{index !== 0 && title && typeof title === 'string' && (
|
||||
<h1 className="claim-grid__header">
|
||||
<Button navigate={route || link} button="link">
|
||||
{icon && <Icon className="claim-grid__header-icon" sectionIcon icon={icon} size={20} />}
|
||||
<span className="claim-grid__title">{title}</span>
|
||||
{help}
|
||||
</Button>
|
||||
</h1>
|
||||
<SectionHeader title={__(title)} navigate={route || link} icon={icon} help={help} />
|
||||
)}
|
||||
|
||||
{index === 0 && <>{claimTiles}</>}
|
||||
@@ -69,6 +83,7 @@ function HomePage(props: Props) {
|
||||
</WaitUntilOnPage>
|
||||
)}
|
||||
|
||||
{/* view more button */}
|
||||
{(route || link) && (
|
||||
<Button
|
||||
className="claim-grid__title--secondary"
|
||||
|
||||
@@ -75,21 +75,15 @@ export default function OwnComments(props: Props) {
|
||||
)}
|
||||
{!contentClaim && <Empty text={__('Content or channel was deleted.')} />}
|
||||
</div>
|
||||
<Comment
|
||||
isTopLevel
|
||||
hideActions
|
||||
authorUri={comment.channel_url}
|
||||
author={comment.channel_name}
|
||||
commentId={comment.comment_id}
|
||||
message={comment.comment}
|
||||
timePosted={comment.timestamp * 1000}
|
||||
commentIsMine
|
||||
supportAmount={comment.support_amount}
|
||||
numDirectReplies={0} // Don't show replies here
|
||||
isModerator={comment.is_moderator}
|
||||
isGlobalMod={comment.is_global_mod}
|
||||
isFiat={comment.is_fiat}
|
||||
/>
|
||||
<React.Suspense fallback={null}>
|
||||
<Comment
|
||||
isTopLevel
|
||||
hideActions
|
||||
comment={comment}
|
||||
commentIsMine
|
||||
numDirectReplies={0} // Don't show replies here
|
||||
/>
|
||||
</React.Suspense>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
+25
-135
@@ -318,160 +318,49 @@ export const doCollectionEdit = (collectionId: string, params: CollectionEditPar
|
||||
) => {
|
||||
const state = getState();
|
||||
const collection: Collection = makeSelectCollectionForId(collectionId)(state);
|
||||
|
||||
if (!collection) return dispatch({ type: ACTIONS.COLLECTION_ERROR, data: { message: 'collection does not exist' } });
|
||||
|
||||
const editedCollection: Collection = makeSelectEditedCollectionForId(collectionId)(state);
|
||||
const unpublishedCollection: Collection = makeSelectUnpublishedCollectionForId(collectionId)(state);
|
||||
const publishedCollection: Collection = makeSelectPublishedCollectionForId(collectionId)(state); // needs to be published only
|
||||
|
||||
const generateCollectionItemsFromSearchResult = (results) => {
|
||||
return (
|
||||
Object.values(results)
|
||||
// $FlowFixMe
|
||||
.reduce(
|
||||
(
|
||||
acc,
|
||||
cur: {
|
||||
stream: ?StreamClaim,
|
||||
channel: ?ChannelClaim,
|
||||
claimsInChannel: ?number,
|
||||
collection: ?CollectionClaim,
|
||||
}
|
||||
) => {
|
||||
let url;
|
||||
if (cur.stream) {
|
||||
url = cur.stream.permanent_url;
|
||||
} else if (cur.channel) {
|
||||
url = cur.channel.permanent_url;
|
||||
} else if (cur.collection) {
|
||||
url = cur.collection.permanent_url;
|
||||
} else {
|
||||
return acc;
|
||||
}
|
||||
acc.push(url);
|
||||
return acc;
|
||||
},
|
||||
[]
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!collection) {
|
||||
return dispatch({
|
||||
type: ACTIONS.COLLECTION_ERROR,
|
||||
data: {
|
||||
message: 'collection does not exist',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let currentItems = collection.items ? collection.items.concat() : [];
|
||||
const { claims: passedClaims, order, claimIds, replace, remove, type } = params;
|
||||
const { uris, order, remove, type } = params;
|
||||
|
||||
const collectionType = type || collection.type;
|
||||
let newItems: Array<?string> = currentItems;
|
||||
const currentUrls = collection.items ? collection.items.concat() : [];
|
||||
let newItems = currentUrls;
|
||||
|
||||
if (passedClaims) {
|
||||
// Passed uris to add/remove:
|
||||
if (uris) {
|
||||
if (remove) {
|
||||
const passedUrls = passedClaims.map((claim) => claim.permanent_url);
|
||||
// $FlowFixMe // need this?
|
||||
newItems = currentItems.filter((item: string) => !passedUrls.includes(item));
|
||||
// Filters (removes) the passed uris from the current list items
|
||||
newItems = currentUrls.filter((url) => url && !uris.includes(url));
|
||||
} else {
|
||||
passedClaims.forEach((claim) => newItems.push(claim.permanent_url));
|
||||
}
|
||||
}
|
||||
|
||||
if (claimIds) {
|
||||
const batches = [];
|
||||
if (claimIds.length > 50) {
|
||||
for (let i = 0; i < Math.ceil(claimIds.length / 50); i++) {
|
||||
batches[i] = claimIds.slice(i * 50, (i + 1) * 50);
|
||||
}
|
||||
} else {
|
||||
batches[0] = claimIds;
|
||||
}
|
||||
const resultArray = await Promise.all(
|
||||
batches.map((batch) => {
|
||||
let options = { claim_ids: batch, page: 1, page_size: 50 };
|
||||
return dispatch(doClaimSearch(options));
|
||||
})
|
||||
);
|
||||
|
||||
const searchResults = Object.assign({}, ...resultArray);
|
||||
|
||||
if (replace) {
|
||||
newItems = generateCollectionItemsFromSearchResult(searchResults);
|
||||
} else {
|
||||
newItems = currentItems.concat(generateCollectionItemsFromSearchResult(searchResults));
|
||||
// Pushes (adds to the end) the passed uris to the current list items
|
||||
uris.forEach((url) => newItems.push(url));
|
||||
}
|
||||
}
|
||||
|
||||
// Passed an ordering to change: (doesn't need the uris here since
|
||||
// the items are already on the list)
|
||||
if (order) {
|
||||
const [movedItem] = currentItems.splice(order.from, 1);
|
||||
currentItems.splice(order.to, 0, movedItem);
|
||||
const [movedItem] = currentUrls.splice(order.from, 1);
|
||||
currentUrls.splice(order.to, 0, movedItem);
|
||||
}
|
||||
|
||||
// console.log('p&e', publishedCollection.items, newItems, publishedCollection.items.join(','), newItems.join(','))
|
||||
if (editedCollection) {
|
||||
// delete edited if newItems are the same as publishedItems
|
||||
if (publishedCollection.items.join(',') === newItems.join(',')) {
|
||||
dispatch({
|
||||
type: ACTIONS.COLLECTION_DELETE,
|
||||
data: {
|
||||
id: collectionId,
|
||||
collectionKey: 'edited',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
dispatch({
|
||||
type: ACTIONS.COLLECTION_EDIT,
|
||||
data: {
|
||||
id: collectionId,
|
||||
collectionKey: 'edited',
|
||||
collection: {
|
||||
items: newItems,
|
||||
id: collectionId,
|
||||
name: params.name || collection.name,
|
||||
updatedAt: getTimestamp(),
|
||||
type: collectionType,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if (publishedCollection) {
|
||||
// Delete 'edited' if newItems are the same as publishedItems
|
||||
if (editedCollection && newItems && publishedCollection.items.join(',') === newItems.join(',')) {
|
||||
dispatch({ type: ACTIONS.COLLECTION_DELETE, data: { id: collectionId, collectionKey: 'edited' } });
|
||||
} else {
|
||||
dispatch({
|
||||
type: ACTIONS.COLLECTION_EDIT,
|
||||
data: {
|
||||
id: collectionId,
|
||||
collectionKey: 'edited',
|
||||
collection: {
|
||||
items: newItems,
|
||||
id: collectionId,
|
||||
name: params.name || collection.name,
|
||||
updatedAt: getTimestamp(),
|
||||
type: collectionType,
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (COLS.BUILTIN_LISTS.includes(collectionId)) {
|
||||
dispatch({
|
||||
type: ACTIONS.COLLECTION_EDIT,
|
||||
data: {
|
||||
id: collectionId,
|
||||
collectionKey: 'builtin',
|
||||
collection: {
|
||||
items: newItems,
|
||||
id: collectionId,
|
||||
name: params.name || collection.name,
|
||||
updatedAt: getTimestamp(),
|
||||
type: collectionType,
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (unpublishedCollection) {
|
||||
dispatch({
|
||||
type: ACTIONS.COLLECTION_EDIT,
|
||||
data: {
|
||||
id: collectionId,
|
||||
collectionKey: 'unpublished',
|
||||
collectionKey:
|
||||
((editedCollection || publishedCollection) && 'edited') ||
|
||||
(COLS.BUILTIN_LISTS.includes(collectionId) && 'builtin') ||
|
||||
(unpublishedCollection && 'unpublished'),
|
||||
collection: {
|
||||
items: newItems,
|
||||
id: collectionId,
|
||||
@@ -482,5 +371,6 @@ export const doCollectionEdit = (collectionId: string, params: CollectionEditPar
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
@@ -110,6 +110,8 @@ export function doSetPrimaryUri(uri: ?string) {
|
||||
};
|
||||
}
|
||||
|
||||
export const doClearPlayingUri = () => (dispatch: Dispatch) => dispatch(doSetPlayingUri({ uri: null }));
|
||||
|
||||
export function doSetPlayingUri({
|
||||
uri,
|
||||
source,
|
||||
@@ -165,6 +167,7 @@ export function doPlayUri(
|
||||
const alreadyDownloading = fileInfo && !!downloadingByOutpoint[fileInfo.outpoint];
|
||||
|
||||
if (alreadyDownloading || alreadyDownloaded) {
|
||||
attemptPlay();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,15 +126,13 @@ export function doSetDaemonSetting(key, value, doNotDispatch = false) {
|
||||
// todo: add sdk reloadsettings() (or it happens automagically?)
|
||||
}
|
||||
});
|
||||
Lbry.settings_get().then((settings) => {
|
||||
analytics.toggleInternal(settings.share_usage_data);
|
||||
dispatch({
|
||||
type: ACTIONS.DAEMON_SETTINGS_RECEIVED,
|
||||
data: {
|
||||
settings,
|
||||
},
|
||||
});
|
||||
});
|
||||
dispatch(doFetchDaemonSettings());
|
||||
};
|
||||
}
|
||||
|
||||
export function doCleanBlobs() {
|
||||
return (dispatch) => {
|
||||
Lbry.blob_clean().then(dispatch(doFetchDaemonSettings()));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+18
-11
@@ -525,7 +525,7 @@ export function doSupportAbandonForClaim(claimId, claimType, keep, preview) {
|
||||
}
|
||||
|
||||
export function doWalletReconnect() {
|
||||
return (dispatch) => {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_RESTART,
|
||||
});
|
||||
@@ -533,16 +533,23 @@ export function doWalletReconnect() {
|
||||
// this basically returns null when it's done. :(
|
||||
// might be good to dispatch ACTIONS.WALLET_RESTARTED
|
||||
const walletTimeout = setTimeout(() => {
|
||||
failed = true;
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_RESTART_COMPLETED,
|
||||
});
|
||||
dispatch(
|
||||
doToast({
|
||||
message: __('Your servers were not available. Check your url and port, or switch back to defaults.'),
|
||||
isError: true,
|
||||
})
|
||||
);
|
||||
const state = getState();
|
||||
const { settings } = state;
|
||||
const { daemonStatus } = settings || {};
|
||||
const { wallet } = daemonStatus || {};
|
||||
const availableServers = wallet.available_servers;
|
||||
if (!availableServers) {
|
||||
failed = true;
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_RESTART_COMPLETED,
|
||||
});
|
||||
dispatch(
|
||||
doToast({
|
||||
message: __('Your servers were not available. Check your url and port, or switch back to defaults.'),
|
||||
isError: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
}, FIFTEEN_SECONDS);
|
||||
Lbry.wallet_reconnect().then(() => {
|
||||
clearTimeout(walletTimeout);
|
||||
|
||||
@@ -45,6 +45,7 @@ const defaultState = {
|
||||
[SETTINGS.DESKTOP_WINDOW_ZOOM]: 1,
|
||||
[SETTINGS.CUSTOM_COMMENTS_SERVER_ENABLED]: false,
|
||||
[SETTINGS.CUSTOM_COMMENTS_SERVER_URL]: '',
|
||||
[SETTINGS.CUSTOM_COMMENTS_SERVERS]: [],
|
||||
[SETTINGS.CUSTOM_SHARE_URL_ENABLED]: false,
|
||||
[SETTINGS.CUSTOM_SHARE_URL]: '',
|
||||
|
||||
|
||||
@@ -156,13 +156,13 @@ export const makeSelectClaimIdsForCollectionId = (id: string) =>
|
||||
return ids;
|
||||
});
|
||||
|
||||
export const makeSelectIndexForUrlInCollection = (url: string, id: string) =>
|
||||
export const makeSelectIndexForUrlInCollection = (url: string, id: string, ignoreShuffle?: boolean) =>
|
||||
createSelector(
|
||||
(state) => state.content.shuffleList,
|
||||
makeSelectUrlsForCollectionId(id),
|
||||
makeSelectClaimForUri(url),
|
||||
(shuffleState, urls, claim) => {
|
||||
const shuffleUrls = shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
const shuffleUrls = !ignoreShuffle && shuffleState && shuffleState.collectionId === id && shuffleState.newUrls;
|
||||
const listUrls = shuffleUrls || urls;
|
||||
|
||||
const index = listUrls && listUrls.findIndex((u) => u === url);
|
||||
|
||||
@@ -20,6 +20,11 @@ export const selectClientSettings = createSelector(selectState, (state) => state
|
||||
|
||||
export const selectLoadedLanguages = createSelector(selectState, (state) => state.loadedLanguages || {});
|
||||
|
||||
export const selectClientSetting = (state, setting) => {
|
||||
const clientSettings = selectClientSettings(state);
|
||||
return clientSettings ? clientSettings[setting] : undefined;
|
||||
};
|
||||
|
||||
export const makeSelectClientSetting = (setting) =>
|
||||
createSelector(selectClientSettings, (settings) => (settings ? settings[setting] : undefined));
|
||||
|
||||
|
||||
@@ -66,3 +66,7 @@
|
||||
@import 'component/empty';
|
||||
@import 'component/stripe-card';
|
||||
@import 'component/wallet-tip-send';
|
||||
@import 'component/swipe-list';
|
||||
@import 'component/utils';
|
||||
@import 'component/settings';
|
||||
@import 'component/embed-player';
|
||||
@@ -120,7 +120,7 @@
|
||||
order: 1;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' viewBox='0 -2 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-monitor'%3E%3Crect x='2' y='3' width='20' height='14' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='8' y1='21' x2='16' y2='21'%3E%3C/line%3E%3Cline x1='12' y1='17' x2='12' y2='21'%3E%3C/line%3E%3C/svg%3E");
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='19' height='19' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-monitor'%3E%3Crect x='2' y='3' width='20' height='14' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='8' y1='21' x2='16' y2='21'%3E%3C/line%3E%3Cline x1='12' y1='17' x2='12' y2='21'%3E%3C/line%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
&:focus:not(:focus-visible) {
|
||||
@@ -128,7 +128,7 @@
|
||||
// see: https://github.com/lbryio/lbry-desktop/pull/5549#discussion_r580406932
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' viewBox='0 -2 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-monitor'%3E%3Crect x='2' y='3' width='20' height='14' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='8' y1='21' x2='16' y2='21'%3E%3C/line%3E%3Cline x1='12' y1='17' x2='12' y2='21'%3E%3C/line%3E%3C/svg%3E");
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='19' height='19' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-monitor'%3E%3Crect x='2' y='3' width='20' height='14' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='8' y1='21' x2='16' y2='21'%3E%3C/line%3E%3Cline x1='12' y1='17' x2='12' y2='21'%3E%3C/line%3E%3C/svg%3E");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,26 +148,35 @@
|
||||
|
||||
.vjs-button--play-next.vjs-button {
|
||||
order: 0;
|
||||
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' class='feather feather-skip-forward'%3e%3cpolygon points='5 4 15 12 5 20 5 4'%3e%3c/polygon%3e%3cline x1='19' y1='5' x2='19' y2='19'%3e%3c/line%3e%3c/svg%3e");
|
||||
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='19' height='19' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-skip-forward'%3e%3cpolygon points='5 4 15 12 5 20 5 4'%3e%3c/polygon%3e%3cline x1='19' y1='5' x2='19' y2='19'%3e%3c/line%3e%3c/svg%3e");
|
||||
|
||||
&:focus:not(:focus-visible) {
|
||||
order: 0;
|
||||
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' class='feather feather-skip-forward'%3e%3cpolygon points='5 4 15 12 5 20 5 4'%3e%3c/polygon%3e%3cline x1='19' y1='5' x2='19' y2='19'%3e%3c/line%3e%3c/svg%3e");
|
||||
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='19' height='19' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-skip-forward'%3e%3cpolygon points='5 4 15 12 5 20 5 4'%3e%3c/polygon%3e%3cline x1='19' y1='5' x2='19' y2='19'%3e%3c/line%3e%3c/svg%3e");
|
||||
}
|
||||
}
|
||||
|
||||
.vjs-button--play-previous.vjs-button {
|
||||
order: 0;
|
||||
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' class='feather feather-skip-back'%3e%3cpolygon points='19 20 9 12 19 4 19 20'%3e%3c/polygon%3e%3cline x1='5' y1='19' x2='5' y2='5'%3e%3c/line%3e%3c/svg%3e");
|
||||
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='19' height='19' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-skip-back'%3e%3cpolygon points='19 20 9 12 19 4 19 20'%3e%3c/polygon%3e%3cline x1='5' y1='19' x2='5' y2='5'%3e%3c/line%3e%3c/svg%3e");
|
||||
|
||||
&:focus:not(:focus-visible) {
|
||||
order: 0;
|
||||
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='18' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' class='feather feather-skip-back'%3e%3cpolygon points='19 20 9 12 19 4 19 20'%3e%3c/polygon%3e%3cline x1='5' y1='19' x2='5' y2='5'%3e%3c/line%3e%3c/svg%3e");
|
||||
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='19' height='19' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-skip-back'%3e%3cpolygon points='19 20 9 12 19 4 19 20'%3e%3c/polygon%3e%3cline x1='5' y1='19' x2='5' y2='5'%3e%3c/line%3e%3c/svg%3e");
|
||||
}
|
||||
}
|
||||
|
||||
.vjs-button--autoplay-next.vjs-button {
|
||||
margin: auto;
|
||||
// TODO: the width and height of a vjs-button should probably retain
|
||||
// its default "100%" value, so that each control-bar button have the same
|
||||
// touch area size. Anything inside (like this on/off switch, or icons)
|
||||
// should be a child (e.g. vjs-icon-placeholder), so that inner margins will
|
||||
// also be consistent.
|
||||
//
|
||||
// TEMP: for now, just hardcode the left-right margin so that it looks
|
||||
// equally spaced compared to its siblings.
|
||||
margin: auto 0.5rem auto 0.7rem;
|
||||
|
||||
order: 1;
|
||||
width: 24px;
|
||||
height: 14px;
|
||||
@@ -281,8 +290,17 @@
|
||||
margin-right: var(--spacing-m);
|
||||
padding: 0 var(--spacing-xxs);
|
||||
|
||||
&.button--file-action-active {
|
||||
.icon {
|
||||
fill: var(--color-primary-alt);
|
||||
stroke: var(--color-primary) !important; //fixme
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
.icon {
|
||||
stroke: var(--color-text-subtitle);
|
||||
&:not(.color-override) {
|
||||
stroke: var(--color-text-subtitle);
|
||||
}
|
||||
}
|
||||
|
||||
.button__label {
|
||||
@@ -616,16 +634,17 @@ svg + .button__label {
|
||||
background-color: var(--color-button-alt-bg);
|
||||
color: var(--color-button-alt-text);
|
||||
text-align: center;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--color-button-alt-bg-hover);
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
font-size: var(--font-small);
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
padding: var(--spacing-s) var(--spacing-s);
|
||||
&:focus {
|
||||
background-color: var(--color-button-alt-bg);
|
||||
}
|
||||
}
|
||||
|
||||
&.top-right {
|
||||
@@ -648,6 +667,15 @@ svg + .button__label {
|
||||
&.button-collection-delete-cancel {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
&.button-collection-drag {
|
||||
cursor: grab;
|
||||
display: flex;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding-bottom: var(--spacing-xs);
|
||||
}
|
||||
}
|
||||
|
||||
.button-toggle--expandformobile {
|
||||
|
||||
@@ -363,17 +363,6 @@ $actions-z-index: 2;
|
||||
}
|
||||
}
|
||||
|
||||
.channel-staked__tooltip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 1rem;
|
||||
}
|
||||
|
||||
.channel-staked__tooltip-text {
|
||||
margin-left: var(--spacing-xs);
|
||||
font-size: var(--font-xsmall);
|
||||
}
|
||||
|
||||
.channel-staked__wrapper {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
|
||||
@@ -216,8 +216,12 @@
|
||||
}
|
||||
|
||||
.claim-preview--collection-mine {
|
||||
padding-left: 7rem;
|
||||
padding-left: 9rem;
|
||||
position: relative;
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
padding-left: 6.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.claim-preview--pending {
|
||||
@@ -240,7 +244,6 @@
|
||||
.claim-preview__actions {
|
||||
align-self: flex-end;
|
||||
margin-bottom: auto;
|
||||
justify-content: flex-end;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
@@ -250,10 +253,6 @@
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
|
||||
.claim-preview__actions {
|
||||
margin-left: var(--spacing-m);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-xsmall) {
|
||||
@@ -541,6 +540,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
.claim-preview--horizontal-tile {
|
||||
&:not(:first-child) {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.claim-tile__title {
|
||||
position: relative;
|
||||
padding: var(--spacing-s);
|
||||
@@ -551,7 +556,7 @@
|
||||
font-weight: 600;
|
||||
color: var(--color-text);
|
||||
font-size: var(--font-small);
|
||||
min-height: 2rem;
|
||||
min-height: 3.2rem;
|
||||
|
||||
@media (min-width: $breakpoint-small) {
|
||||
min-height: 2.5rem;
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
padding-top: var(--spacing-m);
|
||||
padding-bottom: var(--spacing-m);
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@@ -107,6 +107,10 @@
|
||||
justify-content: center;
|
||||
align-items: stretch;
|
||||
flex-grow: 4;
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
width: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.collection-edit__header {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
.comment__badge {
|
||||
padding-right: var(--spacing-xxs);
|
||||
|
||||
.icon {
|
||||
margin-bottom: -4px;
|
||||
height: 1rem;
|
||||
width: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.comment__badge--globalMod {
|
||||
.st0 {
|
||||
// @see: ICONS.BADGE_MOD
|
||||
fill: #fe7500;
|
||||
}
|
||||
}
|
||||
|
||||
.comment__badge--mod {
|
||||
.st0 {
|
||||
// @see: ICONS.BADGE_MOD
|
||||
fill: #ff3850;
|
||||
}
|
||||
}
|
||||
@@ -43,11 +43,13 @@ $thumbnailWidthSmall: 1rem;
|
||||
|
||||
.commentCreate__labelWrapper {
|
||||
display: flex;
|
||||
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
max-width: 50%;
|
||||
|
||||
.commentCreate__label {
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
.embed__wrapper {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background-color: var(--color-black);
|
||||
}
|
||||
|
||||
.embed__wrapper--light-background {
|
||||
@extend .embed__wrapper;
|
||||
|
||||
.vjs-poster,
|
||||
video {
|
||||
background-color: var(--color-white);
|
||||
}
|
||||
}
|
||||
|
||||
.embed__inline-button {
|
||||
@include thumbnail;
|
||||
position: relative;
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100%;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-top-left-radius: var(--border-radius);
|
||||
border-top-right-radius: var(--border-radius);
|
||||
background-color: var(--color-black);
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
height: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
.embed__inline-button-preview {
|
||||
@extend .embed__inline-button;
|
||||
background-color: var(--color-editor-inline-code-bg);
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.embed__loading {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.embed__loading-text {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--color-white);
|
||||
|
||||
h1 {
|
||||
font-size: var(--font-large);
|
||||
}
|
||||
}
|
||||
|
||||
.embed__overlay-logo {
|
||||
max-height: 2rem;
|
||||
max-width: 7rem;
|
||||
}
|
||||
@@ -111,6 +111,21 @@ label {
|
||||
.icon__lbc {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.compound-label {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: baseline;
|
||||
*:not(:first-child) {
|
||||
margin-left: var(--spacing-s);
|
||||
}
|
||||
.compount-label__strong {
|
||||
}
|
||||
.compound-label__details {
|
||||
color: var(--color-text-subtitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input-submit {
|
||||
@@ -293,7 +308,9 @@ input[type='number'] {
|
||||
|
||||
fieldset-group {
|
||||
+ fieldset-group {
|
||||
margin-top: var(--spacing-s);
|
||||
&:not(.fieldset-group--row) {
|
||||
margin-top: var(--spacing-s);
|
||||
}
|
||||
}
|
||||
|
||||
&.fieldset-group--smushed {
|
||||
@@ -339,6 +356,9 @@ fieldset-group {
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
&:not(.fieldset-group--row) {
|
||||
}
|
||||
}
|
||||
|
||||
// This is a special case where the prefix appears "inside" the input
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
@import '../init/vars';
|
||||
@import '../init/mixins';
|
||||
|
||||
.header {
|
||||
z-index: 3; // Main content uses z-index: 1, other content uses z-index: 2, this ensures it always scrolls under the header
|
||||
position: fixed;
|
||||
@@ -6,6 +9,7 @@
|
||||
background-color: var(--color-header-background);
|
||||
box-shadow: var(--card-box-shadow);
|
||||
font-size: var(--font-body);
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-webkit-app-region: drag;
|
||||
|
||||
@@ -23,20 +27,24 @@
|
||||
opacity: 1;
|
||||
position: relative;
|
||||
overflow: unset;
|
||||
width: inherit;
|
||||
height: inherit;
|
||||
width: unset;
|
||||
height: unset;
|
||||
}
|
||||
}
|
||||
|
||||
& > * {
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
|
||||
.header--minimal {
|
||||
box-shadow: none;
|
||||
background-color: var(--color-background);
|
||||
border-bottom: none;
|
||||
|
||||
.header__navigation {
|
||||
padding: var(--spacing-xs) 0;
|
||||
}
|
||||
|
||||
.header__navigationItem--logo {
|
||||
height: 3rem;
|
||||
}
|
||||
}
|
||||
|
||||
.header--mac {
|
||||
@@ -44,10 +52,11 @@
|
||||
}
|
||||
|
||||
.header__contents {
|
||||
height: calc(var(--header-height));
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 var(--spacing-m);
|
||||
flex: 1;
|
||||
height: var(--header-height);
|
||||
padding: var(--spacing-s) var(--spacing-m);
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
padding: var(--spacing-xs);
|
||||
@@ -55,16 +64,40 @@
|
||||
}
|
||||
|
||||
.header__navigation {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex: 1;
|
||||
height: var(--header-height);
|
||||
padding: var(--spacing-s) 0;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.card__actions--between {
|
||||
.header__menu--left {
|
||||
@media (max-width: $breakpoint-small) {
|
||||
max-width: 3rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.header__menu {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header__menu {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.header__menu--left {
|
||||
@extend .header__menu;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.header__menu--right {
|
||||
@extend .header__menu;
|
||||
justify-content: flex-end;
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
max-width: 4rem;
|
||||
}
|
||||
}
|
||||
|
||||
.header__buttons {
|
||||
@@ -78,7 +111,7 @@
|
||||
max-width: fit-content;
|
||||
}
|
||||
|
||||
.header__navigation-item {
|
||||
.header__navigationItem {
|
||||
height: var(--height-button);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
@@ -90,11 +123,16 @@
|
||||
svg {
|
||||
stroke: var(--color-text);
|
||||
}
|
||||
|
||||
&[aria-expanded='true'] {
|
||||
background-color: var(--color-header-button-active);
|
||||
}
|
||||
}
|
||||
|
||||
.header__navigation-item--back,
|
||||
.header__navigation-item--forward,
|
||||
.header__navigation-item--icon {
|
||||
.header__navigationItem--icon {
|
||||
@extend .header__navigationItem;
|
||||
width: var(--height-button);
|
||||
background-color: var(--color-header-button);
|
||||
border-radius: 1.5rem;
|
||||
@@ -110,6 +148,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
span {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
@@ -117,9 +159,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
.header__navigation-item--profile-pic {
|
||||
margin-left: var(--spacing-m);
|
||||
|
||||
.header__navigationItem--profilePic {
|
||||
.channel-thumbnail {
|
||||
height: var(--height-button);
|
||||
width: var(--height-button);
|
||||
@@ -131,8 +171,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
.header__navigation-item--balance {
|
||||
@extend .button--file-action;
|
||||
.header__navigationItem--balance {
|
||||
@extend .header__navigationItem;
|
||||
margin: 0 var(--spacing-s);
|
||||
color: var(--color-text);
|
||||
|
||||
@@ -141,17 +181,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
.header__navigation-item--forward {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.header__navigation-item--icon {
|
||||
@media (max-width: $breakpoint-small) {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.header__navigation-item--lbry {
|
||||
.header__navigationItem--logo {
|
||||
@extend .header__navigationItem;
|
||||
height: 4rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -173,61 +204,44 @@
|
||||
}
|
||||
}
|
||||
|
||||
.header--minimal {
|
||||
.header__navigation-item--lbry {
|
||||
height: 3rem;
|
||||
}
|
||||
}
|
||||
|
||||
.header__navigation-dropdown {
|
||||
@extend .menu__list--header;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
list-style-type: none;
|
||||
background-color: var(--color-header-background);
|
||||
}
|
||||
|
||||
.header__navigation-button {
|
||||
margin: 0;
|
||||
padding: var(--spacing-xxs) var(--spacing-m);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
background-color: var(--color-menu-background--active);
|
||||
}
|
||||
}
|
||||
|
||||
.header__navigation-button-help {
|
||||
@extend .help;
|
||||
margin-top: 0;
|
||||
margin-left: var(--spacing-s);
|
||||
}
|
||||
|
||||
.header__auth-buttons {
|
||||
.header__authButtons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-weight: var(--font-weight-bold);
|
||||
margin-left: var(--spacing-s);
|
||||
|
||||
& > *:not(:last-child) {
|
||||
margin: 0 var(--spacing-m);
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
.button--link {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.button--primary {
|
||||
padding: var(--spacing-xxs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.header__center {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
|
||||
@media (min-width: $breakpoint-small) {
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.header__auth-title {
|
||||
.header__authTitle {
|
||||
@extend .header__center;
|
||||
justify-content: center;
|
||||
|
||||
@media (min-width: $breakpoint-small) {
|
||||
font-size: var(--font-large);
|
||||
}
|
||||
}
|
||||
|
||||
.ReactModal__Overlay {
|
||||
.button--close {
|
||||
margin: 0;
|
||||
margin-top: var(--spacing-xxs);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
min-height: calc(100vh - var(--header-height));
|
||||
min-height: 100vh;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-top: var(--header-height);
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
padding: var(--spacing-xs);
|
||||
padding-top: var(--spacing-m);
|
||||
margin-top: var(--header-height-mobile);
|
||||
}
|
||||
|
||||
@media (min-width: $breakpoint-large) {
|
||||
@@ -42,20 +42,52 @@
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.main-wrapper__inner--auth {
|
||||
min-height: unset;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.sidebar--pusher {
|
||||
animation-timing-function: var(--resizing-animation-function);
|
||||
transition: transform var(--resizing-animation-timing);
|
||||
transform-origin: left;
|
||||
position: absolute;
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
transform: translateX(0);
|
||||
width: calc(100% - var(--spacing-m));
|
||||
}
|
||||
|
||||
@media (min-width: $breakpoint-small) {
|
||||
transform: translateX(var(--side-nav-width--micro));
|
||||
width: calc(100% - ((var(--side-nav-width--micro))));
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar--pusher--filepage {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sidebar--pusher--open {
|
||||
@media (min-width: $breakpoint-medium) {
|
||||
transform: translateX(var(--side-nav-width));
|
||||
width: calc(100% - var(--side-nav-width));
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
position: relative;
|
||||
width: calc(100% - var(--side-nav-width) - var(--spacing-l));
|
||||
width: calc(100% - 2 * var(--spacing-l));
|
||||
max-width: var(--page-max-width);
|
||||
z-index: 0;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
min-height: calc(100vh - var(--header-height));
|
||||
padding: 0 var(--spacing-m);
|
||||
|
||||
@media (max-width: $breakpoint-medium) and (min-width: $breakpoint-small) {
|
||||
margin: 0 var(--spacing-l);
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-medium) {
|
||||
@media (max-width: $breakpoint-small) {
|
||||
width: 100%;
|
||||
min-height: calc(100vh - var(--header-height-mobile));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,13 +159,7 @@
|
||||
margin-left: var(--spacing-m);
|
||||
|
||||
.card__header--between {
|
||||
padding: var(--spacing-s) var(--spacing-s) var(--spacing-s) var(--spacing-s);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.card__title-actions {
|
||||
padding: 0 0 0 0;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
@media (max-width: $breakpoint-medium) {
|
||||
width: 100%;
|
||||
@@ -148,7 +174,18 @@
|
||||
overflow-wrap: break-word;
|
||||
|
||||
.card__header--between {
|
||||
padding: var(--spacing-s) var(--spacing-s) var(--spacing-s) var(--spacing-s);
|
||||
align-items: flex-start !important;
|
||||
|
||||
.card__title-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
padding: var(--spacing-s);
|
||||
|
||||
button {
|
||||
margin-top: var(--spacing-xxs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.file-page__recommended-collection__row {
|
||||
@@ -162,6 +199,15 @@
|
||||
max-width: 50rem;
|
||||
}
|
||||
}
|
||||
|
||||
.collection-preview__edit-group {
|
||||
width: 1.5rem;
|
||||
}
|
||||
|
||||
.claim-preview--collection-mine {
|
||||
padding-left: 6.5rem;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: $breakpoint-medium) {
|
||||
@@ -221,12 +267,7 @@
|
||||
|
||||
.main--full-width {
|
||||
@extend .main;
|
||||
|
||||
@media (min-width: $breakpoint-large) {
|
||||
max-width: none;
|
||||
width: 100%;
|
||||
margin: 0 var(--spacing-l);
|
||||
}
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.main--auth-page {
|
||||
@@ -250,6 +291,10 @@
|
||||
margin-top: var(--spacing-m);
|
||||
padding: 0 var(--spacing-m);
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
padding: 0 0;
|
||||
}
|
||||
|
||||
.card__subtitle {
|
||||
margin: 0 0 var(--spacing-s) 0;
|
||||
font-size: var(--font-small);
|
||||
@@ -393,18 +438,25 @@
|
||||
.main__sign-up--graphic {
|
||||
max-width: 47rem;
|
||||
|
||||
.card__first-pane {
|
||||
width: 50%;
|
||||
@media (max-width: $breakpoint-small) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.card__second-pane {
|
||||
width: 50%;
|
||||
@media (max-width: $breakpoint-small) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
border: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--color-login-graphic-background);
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.signup-image {
|
||||
@media (max-width: $breakpoint-small) {
|
||||
width: 50%;
|
||||
@@ -413,7 +465,7 @@
|
||||
}
|
||||
|
||||
.card__title {
|
||||
font-size: var(--font-heading);
|
||||
font-size: var(--font-title);
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
.setting-item-input {
|
||||
min-height: var(--spacing-l);
|
||||
padding: 0 0 var(--spacing-s) 0;
|
||||
fieldset-section,
|
||||
.fieldset-group,
|
||||
fieldset-group {
|
||||
margin-top: 0;
|
||||
&:not(first-child) {
|
||||
margin-bottom: var(--spacing-m);
|
||||
}
|
||||
}
|
||||
&.checkbox,
|
||||
.checkbox:only-child {
|
||||
height: var(--spacing-l);
|
||||
float: left;
|
||||
}
|
||||
& {
|
||||
margin-left: 2.2rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
.swipe-list {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
overflow-x: auto;
|
||||
scroll-snap-type: x mandatory;
|
||||
}
|
||||
|
||||
.swipe-list__item {
|
||||
width: 80vw;
|
||||
margin-right: var(--spacing-s);
|
||||
flex-shrink: 0;
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
@@ -1,8 +1,24 @@
|
||||
[data-reach-tooltip] {
|
||||
border-radius: var(--border-radius);
|
||||
background-color: var(--color-tooltip-bg);
|
||||
color: var(--color-tooltip-text);
|
||||
border: none;
|
||||
padding: var(--spacing-s);
|
||||
overflow: hidden;
|
||||
.MuiTooltip-tooltip {
|
||||
border-radius: var(--border-radius) !important;
|
||||
background-color: var(--color-tooltip-bg) !important;
|
||||
color: var(--color-tooltip-text) !important;
|
||||
font-size: var(--font-small) !important;
|
||||
}
|
||||
|
||||
.MuiTooltip-arrow {
|
||||
color: var(--color-tooltip-bg) !important;
|
||||
font-size: var(--font-xxsmall) !important;
|
||||
}
|
||||
|
||||
.channel-staked__tooltip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 1rem;
|
||||
padding: var(--spacing-xs);
|
||||
|
||||
.channel-staked__tooltip-text {
|
||||
margin-left: var(--spacing-xs);
|
||||
font-size: var(--font-xsmall);
|
||||
font-size: var(--font-small);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
.justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
.justify-center {
|
||||
justify-content: center;
|
||||
}
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
.opacity-40 {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.h-12 {
|
||||
height: 3rem;
|
||||
}
|
||||
|
||||
.mt-0 {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
.mt-s {
|
||||
margin-top: var(--spacing-s);
|
||||
}
|
||||
|
||||
.mt-m {
|
||||
margin-top: var(--spacing-m);
|
||||
}
|
||||
|
||||
.mb-m {
|
||||
margin-bottom: var(--spacing-m);
|
||||
}
|
||||
|
||||
.mb-xl {
|
||||
margin-bottom: var(--spacing-xl);
|
||||
}
|
||||
|
||||
.ml-s {
|
||||
margin-left: var(--spacing-s);
|
||||
}
|
||||
|
||||
.ml-m {
|
||||
margin-left: var(--spacing-m);
|
||||
}
|
||||
|
||||
.mr-m {
|
||||
margin-right: var(--spacing-m);
|
||||
}
|
||||
|
||||
.mb-0 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.text-s {
|
||||
font-size: var(--font-small);
|
||||
}
|
||||
|
||||
@media (min-width: $breakpoint-small) {
|
||||
.md\:items-center {
|
||||
align-items: center;
|
||||
}
|
||||
.md\:flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
.md\:ml-m {
|
||||
margin-left: var(--spacing-m);
|
||||
}
|
||||
.md\:flex-row {
|
||||
flex-direction: row;
|
||||
}
|
||||
.md\:w-auto {
|
||||
width: auto;
|
||||
}
|
||||
.md\:mt-0 {
|
||||
margin-top: 0;
|
||||
}
|
||||
.md\:mb-xl {
|
||||
margin-bottom: var(--spacing-xl);
|
||||
}
|
||||
.md\:h-12 {
|
||||
height: 3rem;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user