Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06d120a920 |
No files matched your search
@@ -31,6 +31,7 @@ module.name_mapper='^modal\(.*\)$' -> '<PROJECT_ROOT>/ui/modal\1'
|
||||
module.name_mapper='^app\(.*\)$' -> '<PROJECT_ROOT>/ui/app\1'
|
||||
module.name_mapper='^native\(.*\)$' -> '<PROJECT_ROOT>/ui/native\1'
|
||||
module.name_mapper='^analytics\(.*\)$' -> '<PROJECT_ROOT>/ui/analytics\1'
|
||||
module.name_mapper='^recsys\(.*\)$' -> '<PROJECT_ROOT>/ui/recsys\1'
|
||||
module.name_mapper='^rewards\(.*\)$' -> '<PROJECT_ROOT>/ui/rewards\1'
|
||||
module.name_mapper='^i18n\(.*\)$' -> '<PROJECT_ROOT>/ui/i18n\1'
|
||||
module.name_mapper='^effects\(.*\)$' -> '<PROJECT_ROOT>/ui/effects\1'
|
||||
|
||||
+20
-10
@@ -3,6 +3,26 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## [Unreleased for Desktop]
|
||||
|
||||
### Added
|
||||
- Added direct replying to notifications _community pr!_ ([#6935](https://github.com/lbryio/lbry-desktop/pull/6935))
|
||||
- Added "Replay" option on autoplay countdown ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Added "Loop" option on Lists ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Added "Shuffle" option on Lists ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Added Play Next/Previous buttons (with shortcuts SHIFT+N/SHIFT+P) ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Added separate control for autoplay next on video player ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
|
||||
### Changed
|
||||
- Changing the supported language from Filipino to Tagalog _community pr!_ ([#6951](https://github.com/lbryio/lbry-desktop/pull/6951))
|
||||
- Don't show countdown to next item in list ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Changed "View List" popup option to link, so can be opened on a new tab ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
|
||||
### Fixed
|
||||
- Clicking on the title of a floating player will take you back to the list ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Fix floating player stopping on markdown or image files ([#7073](https://github.com/lbryio/lbry-desktop/pull/7073))
|
||||
- Fix list thumbnail upload ([#7074](https://github.com/lbryio/lbry-desktop/pull/7074))
|
||||
|
||||
## [0.51.2] - [2021-08-20]
|
||||
|
||||
### Added
|
||||
@@ -11,12 +31,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Add confirmation on comment removal _community pr!_ ([#6563](https://github.com/lbryio/lbry-desktop/pull/6563))
|
||||
- Show on content page if a file is part of a playlist already _community pr!_([#6393](https://github.com/lbryio/lbry-desktop/pull/6393))
|
||||
- Add filtering to playlists ([#6905](https://github.com/lbryio/lbry-desktop/pull/6905))
|
||||
- Added direct replying to notifications _community pr!_ ([#6935](https://github.com/lbryio/lbry-desktop/pull/6935))
|
||||
- Added "Replay" option on autoplay countdown ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Added "Loop" option on Lists ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Added "Shuffle" option on Lists ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Added Play Next/Previous buttons (with shortcuts SHIFT+N/SHIFT+P) ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Added separate control for autoplay next on video player ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
|
||||
### Changed
|
||||
- Use Canonical Url for copy link ([#6500](https://github.com/lbryio/lbry-desktop/pull/6500))
|
||||
@@ -27,9 +41,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Update sockety api _community pr!_ ([#6747](https://github.com/lbryio/lbry-desktop/pull/6747))
|
||||
- Use resolve for OG metadata instead of chainquery _community pr!_ ([#6787](https://github.com/lbryio/lbry-desktop/pull/6787))
|
||||
- Improved clickability of notification links _community pr!_ ([#6711](https://github.com/lbryio/lbry-desktop/pull/6711))
|
||||
- Changing the supported language from Filipino to Tagalog _community pr!_ ([#6951](https://github.com/lbryio/lbry-desktop/pull/6951))
|
||||
- Don't show countdown to next item in list ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
- Changed "View List" popup option to link, so can be opened on a new tab ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
|
||||
### Fixed
|
||||
- App now supports '#' and ':' for claimId separator ([#6496](https://github.com/lbryio/lbry-desktop/pull/6496))
|
||||
@@ -49,7 +60,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Fix OG: "Unparsable data structure - Truncated Unicode character" _community pr!_ ([#6839](https://github.com/lbryio/lbry-desktop/pull/6839))
|
||||
- Fix Paid embed warning overlay redirection button now links to odysee _community pr!_ ([#6819](https://github.com/lbryio/lbry-desktop/pull/6819))
|
||||
- Fix comment section redirection to create channel _community pr!_ ([#6557](https://github.com/lbryio/lbry-desktop/pull/6557))
|
||||
- Clicking on the title of a floating player will take you back to the list ([#6921](https://github.com/lbryio/lbry-desktop/pull/6921))
|
||||
|
||||
## [0.51.1] - [2021-06-26]
|
||||
|
||||
|
||||
Vendored
+40
-1
@@ -60,6 +60,9 @@ declare type CommentsState = {
|
||||
fetchingModerationDelegators: boolean,
|
||||
blockingByUri: {},
|
||||
unBlockingByUri: {},
|
||||
personalTimeoutMap: { [uri: string]: { blockedAt: string, bannedFor: number, banRemaining: number } },
|
||||
adminTimeoutMap: { [uri: string]: { blockedAt: string, bannedFor: number, banRemaining: number } },
|
||||
moderatorTimeoutMap: { [uri: string]: { blockedAt: string, bannedFor: number, banRemaining: number } },
|
||||
togglingForDelegatorMap: {[string]: Array<string>}, // {"blockedUri": ["delegatorUri1", ""delegatorUri2", ...]}
|
||||
settingsByChannelId: { [string]: PerChannelSettings }, // ChannelID -> settings
|
||||
fetchingSettings: boolean,
|
||||
@@ -189,7 +192,43 @@ declare type SuperListResponse = {
|
||||
has_hidden_comments: boolean,
|
||||
};
|
||||
|
||||
declare type ModerationBlockParams = {};
|
||||
declare type ModerationBlockParams = {
|
||||
// Publisher, Moderator, or Commentron Admin
|
||||
mod_channel_id: string,
|
||||
mod_channel_name: string,
|
||||
// Offender being blocked
|
||||
blocked_channel_id: string,
|
||||
blocked_channel_name: string,
|
||||
// Creator that Moderator is delegated from. Used for delegated moderation
|
||||
creator_channel_id?: string,
|
||||
creator_channel_name?: string,
|
||||
// Blocks identity from comment universally, requires Admin rights on commentron instance
|
||||
block_all?: boolean,
|
||||
time_out?: number,
|
||||
// If true will delete all comments of the offender, requires Admin rights on commentron for universal delete
|
||||
delete_all?: boolean,
|
||||
// The usual signature stuff
|
||||
signature: string,
|
||||
signing_ts: string,
|
||||
};
|
||||
|
||||
declare type ModerationBlockResponse = {
|
||||
deleted_comment_ids: Array<string>,
|
||||
banned_channel_id: string,
|
||||
all_blocked: boolean,
|
||||
banned_from: string,
|
||||
};
|
||||
|
||||
declare type BlockedListArgs = {
|
||||
// Publisher, Moderator or Commentron Admin
|
||||
mod_channel_id: string,
|
||||
mod_channel_name: string,
|
||||
// Creator that Moderator is delegated from. Used for delegated moderation
|
||||
creator_channel_id?: string,
|
||||
creator_channel_name?: string,
|
||||
signature: string,
|
||||
signing_ts: string,
|
||||
};
|
||||
|
||||
declare type ModerationAddDelegateParams = {
|
||||
mod_channel_id: string,
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
|
||||
declare type PlayingUri = {
|
||||
uri: string,
|
||||
primaryUri: string,
|
||||
pathname: string,
|
||||
commentId?: string,
|
||||
source?: string,
|
||||
|
||||
+5
-2
@@ -54,7 +54,10 @@
|
||||
"electron-notarize": "^1.0.0",
|
||||
"electron-updater": "^4.2.4",
|
||||
"express": "^4.17.1",
|
||||
"humanize-duration": "^3.27.0",
|
||||
"if-env": "^1.0.4",
|
||||
"match-sorter": "^6.3.0",
|
||||
"parse-duration": "^1.0.0",
|
||||
"react-datetime-picker": "^3.2.1",
|
||||
"react-plastic": "^1.1.1",
|
||||
"react-top-loading-bar": "^2.0.1",
|
||||
@@ -152,8 +155,8 @@
|
||||
"imagesloaded": "^4.1.4",
|
||||
"json-loader": "^0.5.4",
|
||||
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
||||
"lbry-redux": "lbryio/lbry-redux#12a2ffc708bed45ba8d5a46620dc3892aaf890f8",
|
||||
"lbryinc": "lbryio/lbryinc#8f9a58bfc8312a65614fd7327661cdcc502c4e59",
|
||||
"lbry-redux": "lbryio/lbry-redux#32b578707116d45f5b51b7ab523d200e75668676",
|
||||
"lbryinc": "lbryio/lbryinc#0b4e41ef90d6347819dd3453f2f9398a5c1b4f36",
|
||||
"lint-staged": "^7.0.2",
|
||||
"localforage": "^1.7.1",
|
||||
"lodash-es": "^4.17.14",
|
||||
|
||||
+30
-4
@@ -30,6 +30,9 @@
|
||||
"Send a tip": "Send a tip",
|
||||
"Share": "Share",
|
||||
"Play": "Play",
|
||||
"Shuffle Play": "Shuffle Play",
|
||||
"Shuffle": "Shuffle",
|
||||
"Loop": "Loop",
|
||||
"Subscribe": "Subscribe",
|
||||
"Report content": "Report content",
|
||||
"Report Content": "Report Content",
|
||||
@@ -155,7 +158,9 @@
|
||||
"Lost passwords cannot be recovered.": "Lost passwords cannot be recovered.",
|
||||
"Experimental settings": "Experimental settings",
|
||||
"Autoplay media files": "Autoplay media files",
|
||||
"Autoplay video and audio files when navigating to a file, as well as the next related item when a file finishes playing.": "Autoplay video and audio files when navigating to a file, as well as the next related item when a file finishes playing.",
|
||||
"Autoplay video and audio files when navigating to a file.": "Autoplay video and audio files when navigating to a file.",
|
||||
"Autoplay next recommended content": "Autoplay next recommended content",
|
||||
"Autoplay the next related item when a file (video or audio) finishes playing.": "Autoplay the next related item when a file (video or audio) finishes playing.",
|
||||
"Clear application cache": "Clear application cache",
|
||||
"Clear Cache": "Clear Cache",
|
||||
"This might fix issues that you are having. Your wallet will not be affected.": "This might fix issues that you are having. Your wallet will not be affected.",
|
||||
@@ -928,6 +933,7 @@
|
||||
"Community Choice?": "Community Choice?",
|
||||
"Download to your Library": "Download to your Library",
|
||||
"Leave a Comment": "Leave a Comment",
|
||||
"This comment has been deleted.": "This comment has been deleted.",
|
||||
"That was pretty deep. What do you think?": "That was pretty deep. What do you think?",
|
||||
"%repost_total% Reposts": "%repost_total% Reposts",
|
||||
"File Description": "File Description",
|
||||
@@ -1175,7 +1181,11 @@
|
||||
"Tap to unmute": "Tap to unmute",
|
||||
"Retry": "Retry",
|
||||
"Playing in %seconds_left% seconds...": "Playing in %seconds_left% seconds...",
|
||||
"Playing next free content in %seconds_left% seconds...": "Playing next free content in %seconds_left% seconds...",
|
||||
"Autoplay timer paused.": "Autoplay timer paused.",
|
||||
"Play Previous": "Play Previous",
|
||||
"Purchase?": "Purchase?",
|
||||
"Replay?": "Replay?",
|
||||
"0 Bytes": "0 Bytes",
|
||||
"Bytes": "Bytes",
|
||||
"KB": "KB",
|
||||
@@ -1716,6 +1726,10 @@
|
||||
"Level %current_level%": "Level %current_level%",
|
||||
"Creator tools": "Creator tools",
|
||||
"Prevent this channel from interacting with you.": "Prevent this channel from interacting with you.",
|
||||
"Choose a permanent or temporary ban.": "Choose a permanent or temporary ban.",
|
||||
"Personal | Moderator | Admin": "Personal | Moderator | Admin",
|
||||
"Personal | Moderator": "Personal | Moderator",
|
||||
"Personal | Admin": "Personal | Admin",
|
||||
"Hide this channel for you only.": "Hide this channel for you only.",
|
||||
"Interacting as %channelName%": "Interacting as %channelName%",
|
||||
"Page Not Found": "Page Not Found",
|
||||
@@ -1744,12 +1758,19 @@
|
||||
"Moderator Block": "Moderator Block",
|
||||
"Block this channel on behalf of %creator%": "Block this channel on behalf of %creator%",
|
||||
"creator": "creator",
|
||||
"Enter the timeout duration. Examples: %examples%": "Enter the timeout duration. Examples: %examples%",
|
||||
"Wow, banned for more than 100 years?": "Wow, banned for more than 100 years?",
|
||||
"Invalid duration.": "Invalid duration.",
|
||||
"Permanent": "Permanent",
|
||||
"Timeout --[time-based ban instead of permanent]--": "Timeout",
|
||||
"(Remaining: %duration%) --[timeout ban duration]--": "(Remaining: %duration%)",
|
||||
"Create a channel to change this setting.": "Create a channel to change this setting.",
|
||||
"Invalid channel URL \"%url%\"": "Invalid channel URL \"%url%\"",
|
||||
"Delegation": "Delegation",
|
||||
"Add moderator": "Add moderator",
|
||||
"Search channel": "Search channel",
|
||||
"Enter a @username or URL": "Enter a @username or URL",
|
||||
"Enter a name, @username or URL": "Enter a name, @username or URL",
|
||||
"Enter full channel name or URL": "Enter full channel name or URL",
|
||||
"Enter a channel name or URL to add as a moderator.\nExamples:\n - @channel\n - @channel#3\n - https://odysee.com/@Odysee:8\n - lbry://@Odysee#8": "Enter a channel name or URL to add as a moderator.\nExamples:\n - @channel\n - @channel#3\n - https://odysee.com/@Odysee:8\n - lbry://@Odysee#8",
|
||||
"Moderators": "Moderators",
|
||||
"Moderators can block channels on your behalf. Blocked channels will appear in your \"Blocked and Muted\" list.": "Moderators can block channels on your behalf. Blocked channels will appear in your \"Blocked and Muted\" list.",
|
||||
@@ -1762,8 +1783,11 @@
|
||||
"Play (space)": "Play (space)",
|
||||
"Unmute (m)": "Unmute (m)",
|
||||
"Exit Fullscreen (f)": "Exit Fullscreen (f)",
|
||||
"Toggle Theater mode (t)": "Toggle Theater mode (t)",
|
||||
"Theater Mode (t)": "Theater Mode (t)",
|
||||
"Default Mode (t)": "Default Mode (t)",
|
||||
"Quality": "Quality",
|
||||
"Autoplay Next On": "Autoplay Next On",
|
||||
"Autoplay Next Off": "Autoplay Next Off",
|
||||
"Announcements, updates, and rewards specific to users of LBRY Android.": "Announcements, updates, and rewards specific to users of LBRY Android.",
|
||||
"LBRY has special programs and opportunities for people in school.": "LBRY has special programs and opportunities for people in school.",
|
||||
"Creator specific news, automated reports, and other updates.": "Creator specific news, automated reports, and other updates.",
|
||||
@@ -1893,6 +1917,7 @@
|
||||
"e.g. John Doe": "e.g. John Doe",
|
||||
"e.g. john@example.com": "e.g. john@example.com",
|
||||
"e.g. satoshi@example.com": "e.g. satoshi@example.com",
|
||||
"e.g. odysee": "e.g. odysee",
|
||||
"Your channel": "Your channel",
|
||||
"Set to \"Anonymous\" if you do not want to associate your channel in this report.": "Set to \"Anonymous\" if you do not want to associate your channel in this report.",
|
||||
"Send report?": "Send report?",
|
||||
@@ -1969,7 +1994,6 @@
|
||||
"Learn more and sign petition": "Learn more and sign petition",
|
||||
"View claim details": "View claim details",
|
||||
"Publishing...": "Publishing...",
|
||||
"Enter a name, @username or URL": "Enter a name, @username or URL",
|
||||
"Recipient search": "Recipient search",
|
||||
"Fetch transaction data for export": "Fetch transaction data for export",
|
||||
"Fetching data": "Fetching data",
|
||||
@@ -1993,6 +2017,7 @@
|
||||
"This channel isn't staking enough LBRY Credits for inline image previews.": "This channel isn't staking enough LBRY Credits for inline image previews.",
|
||||
"Latest": "Latest",
|
||||
"Channel Not Found": "Channel Not Found",
|
||||
"Channel not found": "Channel not found",
|
||||
"Probably because you didn't make it.": "Probably because you didn't make it.",
|
||||
"Release date": "Release date",
|
||||
"Set custom release date": "Set custom release date",
|
||||
@@ -2143,5 +2168,6 @@
|
||||
"Channel Page": "Channel Page",
|
||||
"Content Page": "Content Page",
|
||||
"Card Last 4": "Card Last 4",
|
||||
"Search blocked channel name": "Search blocked channel name",
|
||||
"--end--": "--end--"
|
||||
}
|
||||
@@ -120,6 +120,10 @@ async function sendAndResetWatchmanData() {
|
||||
return 'Can only be used with a user id';
|
||||
}
|
||||
|
||||
if (!videoPlayer) {
|
||||
return 'Video player not initialized';
|
||||
}
|
||||
|
||||
let timeSinceLastIntervalSend = new Date() - lastSentTime;
|
||||
lastSentTime = new Date();
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ const Comments = {
|
||||
|
||||
moderation_block: (params: ModerationBlockParams) => fetchCommentsApi('moderation.Block', params),
|
||||
moderation_unblock: (params: ModerationBlockParams) => fetchCommentsApi('moderation.UnBlock', params),
|
||||
moderation_block_list: (params: ModerationBlockParams) => fetchCommentsApi('moderation.BlockedList', params),
|
||||
moderation_block_list: (params: BlockedListArgs) => fetchCommentsApi('moderation.BlockedList', params),
|
||||
moderation_add_delegate: (params: ModerationAddDelegateParams) => fetchCommentsApi('moderation.AddDelegate', params),
|
||||
moderation_remove_delegate: (params: ModerationRemoveDelegateParams) =>
|
||||
fetchCommentsApi('moderation.RemoveDelegate', params),
|
||||
|
||||
@@ -15,8 +15,11 @@ type Props = {
|
||||
nextRecommendedClaim: ?StreamClaim,
|
||||
nextRecommendedUri: string,
|
||||
modal: { id: string, modalProps: {} },
|
||||
skipPaid: boolean,
|
||||
doNavigate: () => void,
|
||||
doReplay: () => void,
|
||||
doPrevious: () => void,
|
||||
onCanceled: () => void,
|
||||
};
|
||||
|
||||
function AutoplayCountdown(props: Props) {
|
||||
@@ -25,8 +28,11 @@ function AutoplayCountdown(props: Props) {
|
||||
nextRecommendedClaim,
|
||||
history: { push },
|
||||
modal,
|
||||
skipPaid,
|
||||
doNavigate,
|
||||
doReplay,
|
||||
doPrevious,
|
||||
onCanceled,
|
||||
} = props;
|
||||
const nextTitle = nextRecommendedClaim && nextRecommendedClaim.value && nextRecommendedClaim.value.title;
|
||||
|
||||
@@ -44,6 +50,14 @@ function AutoplayCountdown(props: Props) {
|
||||
return elm && elm.getBoundingClientRect().top < 0;
|
||||
}
|
||||
|
||||
function getMsgPlayingNext() {
|
||||
if (skipPaid) {
|
||||
return __('Playing next free content in %seconds_left% seconds...', { seconds_left: timer });
|
||||
} else {
|
||||
return __('Playing in %seconds_left% seconds...', { seconds_left: timer });
|
||||
}
|
||||
}
|
||||
|
||||
// Update 'setTimerPaused'.
|
||||
React.useEffect(() => {
|
||||
// Ensure correct 'setTimerPaused' on initial render.
|
||||
@@ -68,6 +82,7 @@ function AutoplayCountdown(props: Props) {
|
||||
interval = setInterval(() => {
|
||||
const newTime = timer - 1;
|
||||
if (newTime === 0) {
|
||||
if (skipPaid) setTimer(countdownTime);
|
||||
doNavigate();
|
||||
} else {
|
||||
setTimer(timer - 1);
|
||||
@@ -78,7 +93,7 @@ function AutoplayCountdown(props: Props) {
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [timer, doNavigate, push, timerCanceled, isTimerPaused, nextRecommendedUri]);
|
||||
}, [timer, doNavigate, push, timerCanceled, isTimerPaused, nextRecommendedUri, skipPaid]);
|
||||
|
||||
if (timerCanceled || !nextRecommendedUri) {
|
||||
return null;
|
||||
@@ -105,19 +120,38 @@ function AutoplayCountdown(props: Props) {
|
||||
)}
|
||||
{!isTimerPaused && (
|
||||
<div className="file-viewer__overlay-secondary autoplay-countdown__counter">
|
||||
{__('Playing in %seconds_left% seconds...', { seconds_left: timer })}{' '}
|
||||
<Button label={__('Cancel')} button="link" onClick={() => setTimerCanceled(true)} />
|
||||
{getMsgPlayingNext()}{' '}
|
||||
<Button
|
||||
label={__('Cancel')}
|
||||
button="link"
|
||||
onClick={() => {
|
||||
setTimerCanceled(true);
|
||||
if (onCanceled) onCanceled();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<Button
|
||||
label={__('Replay?')}
|
||||
button="link"
|
||||
iconRight={ICONS.REPLAY}
|
||||
onClick={() => {
|
||||
setTimerCanceled(true);
|
||||
doReplay();
|
||||
}}
|
||||
/>
|
||||
{skipPaid && doPrevious && (
|
||||
<div>
|
||||
<Button
|
||||
label={__('Play Previous')}
|
||||
button="link"
|
||||
icon={ICONS.PLAY_PREVIOUS}
|
||||
onClick={() => doPrevious()}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<Button
|
||||
label={skipPaid ? __('Purchase?') : __('Replay?')}
|
||||
button="link"
|
||||
iconRight={skipPaid ? ICONS.WALLET : ICONS.REPLAY}
|
||||
onClick={() => {
|
||||
setTimerCanceled(true);
|
||||
doReplay();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
import BlockList from './view';
|
||||
export default BlockList;
|
||||
@@ -0,0 +1,205 @@
|
||||
// @flow
|
||||
import { Combobox, ComboboxInput, ComboboxPopover, ComboboxList, ComboboxOption } from '@reach/combobox';
|
||||
// import '@reach/combobox/styles.css'; --> 'scss/third-party.scss'
|
||||
import { matchSorter } from 'match-sorter';
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import Button from 'component/button';
|
||||
import ClaimList from 'component/claimList';
|
||||
import Icon from 'component/common/icon';
|
||||
import Paginate from 'component/common/paginate';
|
||||
import Yrbl from 'component/yrbl';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import useThrottle from 'effects/use-throttle';
|
||||
|
||||
const PAGE_SIZE = 10;
|
||||
|
||||
function reduceUriToChannelName(uri: string) {
|
||||
// 'parseURI' is too slow to handle a large list. Since our list should be
|
||||
// kosher in the first place, just do a quick substring call. Add a
|
||||
// try-catch just in case.
|
||||
try {
|
||||
return uri.substring(uri.indexOf('@') + 1, uri.indexOf('#'));
|
||||
} catch {
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// BlockList
|
||||
// ****************************************************************************
|
||||
|
||||
type Props = {
|
||||
uris: Array<string>,
|
||||
help: string,
|
||||
titleEmptyList: string,
|
||||
subtitleEmptyList: string,
|
||||
getActionButtons?: (url: string) => React$Node,
|
||||
className: ?string,
|
||||
};
|
||||
|
||||
export default function BlockList(props: Props) {
|
||||
const { uris: list, help, titleEmptyList, subtitleEmptyList, getActionButtons, className } = props;
|
||||
|
||||
// Keep a local list to allow for undoing actions in this component
|
||||
const [localList, setLocalList] = React.useState(undefined);
|
||||
const stringifiedList = JSON.stringify(list);
|
||||
const hasLocalList = localList && localList.length > 0;
|
||||
const justBlocked = list && localList && localList.length < list.length;
|
||||
|
||||
const [page, setPage] = React.useState(1);
|
||||
const [searchList, setSearchList] = React.useState(null); // null: not searching; []: no results;
|
||||
const isShowingSearchResults = searchList !== null;
|
||||
|
||||
let totalPages = 0;
|
||||
let paginatedLocalList;
|
||||
if (localList) {
|
||||
paginatedLocalList = localList.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
|
||||
totalPages = Math.ceil(localList.length / PAGE_SIZE);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
function getRenderActions() {
|
||||
if (getActionButtons) {
|
||||
return (claim) => <div className="section__actions">{getActionButtons(claim.permanent_url)}</div>;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function formatSearchSuggestion(suggestion: string) {
|
||||
return reduceUriToChannelName(suggestion);
|
||||
}
|
||||
|
||||
function filterSearchResults(results: ?Array<string>) {
|
||||
setSearchList(results);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
React.useEffect(() => {
|
||||
const list = stringifiedList && JSON.parse(stringifiedList);
|
||||
if (!hasLocalList) {
|
||||
setLocalList(list && list.length > 0 ? list : []);
|
||||
}
|
||||
}, [stringifiedList, hasLocalList]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (justBlocked && stringifiedList) {
|
||||
setLocalList(JSON.parse(stringifiedList));
|
||||
}
|
||||
}, [stringifiedList, justBlocked, setLocalList]);
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
if (paginatedLocalList === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!hasLocalList) {
|
||||
return (
|
||||
<div className="main--empty">
|
||||
<Yrbl
|
||||
title={titleEmptyList}
|
||||
subtitle={subtitleEmptyList}
|
||||
actions={
|
||||
<div className="section__actions">
|
||||
<Button button="primary" label={__('Go Home')} navigate="/" />
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="help--notice">{help}</div>
|
||||
<div className="section">
|
||||
<SearchList
|
||||
list={localList}
|
||||
placeholder={__('e.g. odysee')}
|
||||
formatter={formatSearchSuggestion}
|
||||
onResultsUpdated={filterSearchResults}
|
||||
/>
|
||||
</div>
|
||||
<div className={classnames('section block-list', className)}>
|
||||
<ClaimList
|
||||
uris={searchList || paginatedLocalList}
|
||||
showUnresolvedClaims
|
||||
showHiddenByUser
|
||||
hideMenu
|
||||
renderActions={getRenderActions()}
|
||||
/>
|
||||
</div>
|
||||
{!isShowingSearchResults && <Paginate totalPages={totalPages} disableHistory onPageChange={(p) => setPage(p)} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// SearchList
|
||||
// ****************************************************************************
|
||||
|
||||
type LsbProps = {
|
||||
list: ?Array<string>,
|
||||
placeholder?: string,
|
||||
formatter?: (suggestion: string) => string,
|
||||
onResultsUpdated?: (?Array<string>) => void,
|
||||
};
|
||||
|
||||
function SearchList(props: LsbProps) {
|
||||
const { list, placeholder, formatter, onResultsUpdated } = props;
|
||||
const [term, setTerm] = React.useState('');
|
||||
const results = useAuthorMatch(term, list);
|
||||
const handleChange = (event) => setTerm(event.target.value);
|
||||
const handleSelect = (e) => setTerm(e);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (onResultsUpdated) {
|
||||
onResultsUpdated(results);
|
||||
}
|
||||
}, [results]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
return (
|
||||
<div className="wunderbar__wrapper">
|
||||
<label>{__('Search blocked channel name')}</label>
|
||||
<Combobox className="wunderbar" onSelect={handleSelect}>
|
||||
<Icon icon={ICONS.SEARCH} />
|
||||
<ComboboxInput selectOnClick className="wunderbar__input" onChange={handleChange} placeholder={placeholder} />
|
||||
{results && (
|
||||
<ComboboxPopover className="wunderbar__suggestions" portal={false}>
|
||||
{results.length > 0 ? (
|
||||
<ComboboxList>
|
||||
{results.slice(0, 10).map((result, index) => (
|
||||
<ComboboxOption
|
||||
className="wunderbar__more-results"
|
||||
key={index}
|
||||
value={formatter ? formatter(result) : result}
|
||||
/>
|
||||
))}
|
||||
</ComboboxList>
|
||||
) : (
|
||||
<span style={{ display: 'block', margin: 8 }}>{__('No results')}</span>
|
||||
)}
|
||||
</ComboboxPopover>
|
||||
)}
|
||||
</Combobox>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function useAuthorMatch(term, list) {
|
||||
const throttledTerm = useThrottle(term, 200);
|
||||
return React.useMemo(() => {
|
||||
return !throttledTerm || throttledTerm.trim() === ''
|
||||
? null
|
||||
: matchSorter(list, throttledTerm, {
|
||||
keys: [(item) => reduceUriToChannelName(item)],
|
||||
threshold: matchSorter.rankings.CONTAINS,
|
||||
});
|
||||
}, [throttledTerm]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}
|
||||
@@ -154,6 +154,7 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
title={title}
|
||||
onClick={onClick}
|
||||
aria-label={ariaLabel}
|
||||
disabled={disabled} // is there a reason this wasn't here before?
|
||||
>
|
||||
{content}
|
||||
</a>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import React from 'react';
|
||||
import Button from 'component/button';
|
||||
import { BLOCK_LEVEL } from 'constants/comment';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
|
||||
type Props = {
|
||||
uri: string,
|
||||
@@ -12,7 +11,7 @@ type Props = {
|
||||
isBlockingOrUnBlocking: boolean,
|
||||
isToggling: boolean,
|
||||
doCommentModUnBlock: (string, boolean) => void,
|
||||
doCommentModBlock: (string, boolean) => void,
|
||||
doCommentModBlock: (string, ?Number, boolean) => void,
|
||||
doCommentModUnBlockAsAdmin: (string, string) => void,
|
||||
doCommentModBlockAsAdmin: (string, string) => void,
|
||||
doCommentModUnBlockAsModerator: (string, string, string) => void,
|
||||
@@ -42,17 +41,16 @@ function ChannelBlockButton(props: Props) {
|
||||
if (isBlocked) {
|
||||
doCommentModUnBlock(uri, false);
|
||||
} else {
|
||||
doCommentModBlock(uri, false);
|
||||
doCommentModBlock(uri, undefined, false);
|
||||
}
|
||||
break;
|
||||
|
||||
case BLOCK_LEVEL.MODERATOR:
|
||||
if (creatorUri) {
|
||||
const { channelClaimId } = parseURI(creatorUri);
|
||||
if (isBlocked) {
|
||||
doCommentModUnBlockAsModerator(uri, channelClaimId, '');
|
||||
doCommentModUnBlockAsModerator(uri, creatorUri, '');
|
||||
} else {
|
||||
doCommentModBlockAsModerator(uri, channelClaimId, '');
|
||||
doCommentModBlockAsModerator(uri, creatorUri, '');
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -146,6 +146,7 @@ function ChannelContent(props: Props) {
|
||||
defaultFreshness={CS.FRESH_ALL}
|
||||
showHiddenByUser={viewHiddenChannels}
|
||||
forceShowReposts
|
||||
fetchViewCount
|
||||
hideFilters={!showFilters}
|
||||
hideAdvancedFilter={!showFilters}
|
||||
tileLayout={tileLayout}
|
||||
|
||||
@@ -5,6 +5,7 @@ import Button from 'component/button';
|
||||
import Card from 'component/common/card';
|
||||
import { FormField } from 'component/common/form';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import CollectionSelectItem from 'component/collectionSelectItem';
|
||||
|
||||
type Props = {
|
||||
@@ -46,8 +47,7 @@ const ClaimCollectionAdd = (props: Props) => {
|
||||
}
|
||||
|
||||
function altEnterListener(e: SyntheticKeyboardEvent<*>) {
|
||||
const KEYCODE_ENTER = 13;
|
||||
if (e.keyCode === KEYCODE_ENTER) {
|
||||
if (e.keyCode === KEYCODES.ENTER) {
|
||||
e.preventDefault();
|
||||
buttonref.current.click();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ type Props = {
|
||||
onScrollBottom?: (any) => void,
|
||||
page?: number,
|
||||
pageSize?: number,
|
||||
id?: string,
|
||||
// If using the default header, this is a unique ID needed to persist the state of the filter setting
|
||||
persistedStorageKey?: string,
|
||||
showHiddenByUser: boolean,
|
||||
@@ -47,7 +46,7 @@ type Props = {
|
||||
searchOptions?: any,
|
||||
collectionId?: string,
|
||||
showNoSourceClaims?: boolean,
|
||||
onClick?: (e: any, index?: number) => void,
|
||||
onClick?: (e: any, claim?: ?Claim, index?: number) => void,
|
||||
};
|
||||
|
||||
export default function ClaimList(props: Props) {
|
||||
@@ -56,7 +55,6 @@ export default function ClaimList(props: Props) {
|
||||
uris,
|
||||
headerAltControls,
|
||||
loading,
|
||||
id,
|
||||
persistedStorageKey,
|
||||
empty,
|
||||
defaultSort,
|
||||
@@ -110,9 +108,9 @@ export default function ClaimList(props: Props) {
|
||||
setCurrentSort(currentSort === SORT_NEW ? SORT_OLD : SORT_NEW);
|
||||
}
|
||||
|
||||
function handleClaimClicked(e, index) {
|
||||
function handleClaimClicked(e, claim, index) {
|
||||
if (onClick) {
|
||||
onClick(e, index);
|
||||
onClick(e, claim, index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +198,6 @@ export default function ClaimList(props: Props) {
|
||||
{injectedItem && index === 4 && <li>{injectedItem}</li>}
|
||||
<ClaimPreview
|
||||
uri={uri}
|
||||
containerId={id}
|
||||
indexInContainer={index}
|
||||
type={type}
|
||||
active={activeUri && uri === activeUri}
|
||||
@@ -220,7 +217,7 @@ export default function ClaimList(props: Props) {
|
||||
return claim.name.length === 24 && !claim.name.includes(' ') && claim.value.author === 'Spee.ch';
|
||||
}}
|
||||
live={resolveLive(index)}
|
||||
onClick={handleClaimClicked}
|
||||
onClick={(e, claim, index) => handleClaimClicked(e, claim, index)}
|
||||
/>
|
||||
</React.Fragment>
|
||||
))}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doClaimSearch,
|
||||
selectClaimsByUri,
|
||||
selectClaimSearchByQuery,
|
||||
selectClaimSearchByQueryLastPageReached,
|
||||
selectFetchingClaimSearch,
|
||||
@@ -12,11 +13,13 @@ import { doToggleTagFollowDesktop } from 'redux/actions/tags';
|
||||
import { makeSelectClientSetting, selectShowMatureContent, selectLanguage } from 'redux/selectors/settings';
|
||||
import { selectModerationBlockList } from 'redux/selectors/comments';
|
||||
import ClaimListDiscover from './view';
|
||||
import { doFetchViewCount } from 'lbryinc';
|
||||
|
||||
const select = (state) => ({
|
||||
followedTags: selectFollowedTags(state),
|
||||
claimSearchByQuery: selectClaimSearchByQuery(state),
|
||||
claimSearchByQueryLastPageReached: selectClaimSearchByQueryLastPageReached(state),
|
||||
claimsByUri: selectClaimsByUri(state),
|
||||
loading: selectFetchingClaimSearch(state),
|
||||
showNsfw: selectShowMatureContent(state),
|
||||
hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state),
|
||||
@@ -29,6 +32,7 @@ const select = (state) => ({
|
||||
const perform = {
|
||||
doClaimSearch,
|
||||
doToggleTagFollowDesktop,
|
||||
doFetchViewCount,
|
||||
};
|
||||
|
||||
export default connect(select, perform)(ClaimListDiscover);
|
||||
@@ -18,66 +18,81 @@ import { getLivestreamOnlyOptions } from 'util/search';
|
||||
|
||||
type Props = {
|
||||
uris: Array<string>,
|
||||
showHeader: boolean,
|
||||
name?: string,
|
||||
type: string,
|
||||
subscribedChannels: Array<Subscription>,
|
||||
doClaimSearch: ({}) => void,
|
||||
loading: boolean,
|
||||
pageSize?: number,
|
||||
|
||||
fetchViewCount?: boolean,
|
||||
forceShowReposts?: boolean,
|
||||
hasNoSource?: boolean,
|
||||
hasSource?: boolean,
|
||||
hideAdvancedFilter?: boolean,
|
||||
hideFilters?: boolean,
|
||||
includeSupportAction?: boolean,
|
||||
infiniteScroll?: Boolean,
|
||||
isChannel?: boolean,
|
||||
liveLivestreamsFirst?: boolean,
|
||||
personalView: boolean,
|
||||
doToggleTagFollowDesktop: (string) => void,
|
||||
meta?: Node,
|
||||
showNsfw: boolean,
|
||||
hideReposts: boolean,
|
||||
history: { action: string, push: (string) => void, replace: (string) => void },
|
||||
location: { search: string, pathname: string },
|
||||
claimSearchByQuery: {
|
||||
[string]: Array<string>,
|
||||
},
|
||||
claimSearchByQueryLastPageReached: { [string]: boolean },
|
||||
mutedUris: Array<string>,
|
||||
blockedUris: Array<string>,
|
||||
hiddenNsfwMessage?: Node,
|
||||
channelIds?: Array<string>,
|
||||
claimIds?: Array<string>,
|
||||
tags: string, // these are just going to be string. pass a CSV if you want multi
|
||||
defaultTags: string,
|
||||
orderBy?: Array<string>,
|
||||
showHeader: boolean,
|
||||
showHiddenByUser?: boolean,
|
||||
showNoSourceClaims?: boolean,
|
||||
tileLayout: boolean,
|
||||
|
||||
orderBy?: Array<string>, // Trending, New, Top
|
||||
defaultOrderBy?: string,
|
||||
sortBy?: Array<string>, // Newest First, Oldest First
|
||||
freshness?: string,
|
||||
defaultFreshness?: string,
|
||||
header?: Node,
|
||||
headerLabel?: string | Node,
|
||||
name?: string,
|
||||
hideAdvancedFilter?: boolean,
|
||||
|
||||
tags: string, // these are just going to be string. pass a CSV if you want multi
|
||||
defaultTags: string,
|
||||
|
||||
claimType?: string | Array<string>,
|
||||
defaultClaimType?: Array<string>,
|
||||
|
||||
streamType?: string | Array<string>,
|
||||
defaultStreamType?: string | Array<string>,
|
||||
renderProperties?: (Claim) => Node,
|
||||
includeSupportAction?: boolean,
|
||||
repostedClaimId?: string,
|
||||
pageSize?: number,
|
||||
followedTags?: Array<Tag>,
|
||||
injectedItem: ?Node,
|
||||
infiniteScroll?: Boolean,
|
||||
feeAmount?: string,
|
||||
tileLayout: boolean,
|
||||
hideFilters?: boolean,
|
||||
maxPages?: number,
|
||||
forceShowReposts?: boolean,
|
||||
languageSetting: string,
|
||||
searchInLanguage: boolean,
|
||||
scrollAnchor?: string,
|
||||
showHiddenByUser?: boolean,
|
||||
liveLivestreamsFirst?: boolean,
|
||||
livestreamMap?: { [string]: any },
|
||||
hasSource?: boolean,
|
||||
hasNoSource?: boolean,
|
||||
limitClaimsPerChannel?: number,
|
||||
releaseTime?: string,
|
||||
showNoSourceClaims?: boolean,
|
||||
isChannel?: boolean,
|
||||
|
||||
empty?: string,
|
||||
feeAmount?: string,
|
||||
releaseTime?: string,
|
||||
repostedClaimId?: string,
|
||||
scrollAnchor?: string,
|
||||
maxPages?: number,
|
||||
limitClaimsPerChannel?: number,
|
||||
|
||||
channelIds?: Array<string>,
|
||||
claimIds?: Array<string>,
|
||||
subscribedChannels: Array<Subscription>,
|
||||
livestreamMap?: { [string]: any },
|
||||
|
||||
header?: Node,
|
||||
headerLabel?: string | Node,
|
||||
hiddenNsfwMessage?: Node,
|
||||
injectedItem: ?Node,
|
||||
meta?: Node,
|
||||
renderProperties?: (Claim) => Node,
|
||||
|
||||
history: { action: string, push: (string) => void, replace: (string) => void },
|
||||
location: { search: string, pathname: string },
|
||||
|
||||
// --- select ---
|
||||
followedTags?: Array<Tag>,
|
||||
claimSearchByQuery: { [string]: Array<string> },
|
||||
claimSearchByQueryLastPageReached: { [string]: boolean },
|
||||
claimsByUri: { [string]: any },
|
||||
loading: boolean,
|
||||
showNsfw: boolean,
|
||||
hideReposts: boolean,
|
||||
languageSetting: string,
|
||||
mutedUris: Array<string>,
|
||||
blockedUris: Array<string>,
|
||||
searchInLanguage: boolean,
|
||||
|
||||
// --- perform ---
|
||||
doClaimSearch: ({}) => void,
|
||||
doToggleTagFollowDesktop: (string) => void,
|
||||
doFetchViewCount: (claimIdCsv: string) => void,
|
||||
};
|
||||
|
||||
function ClaimListDiscover(props: Props) {
|
||||
@@ -94,12 +109,14 @@ function ClaimListDiscover(props: Props) {
|
||||
channelIds,
|
||||
showNsfw,
|
||||
hideReposts,
|
||||
fetchViewCount,
|
||||
history,
|
||||
location,
|
||||
mutedUris,
|
||||
blockedUris,
|
||||
hiddenNsfwMessage,
|
||||
defaultOrderBy,
|
||||
sortBy,
|
||||
orderBy,
|
||||
headerLabel,
|
||||
header,
|
||||
@@ -138,6 +155,8 @@ function ClaimListDiscover(props: Props) {
|
||||
isChannel = false,
|
||||
showNoSourceClaims,
|
||||
empty,
|
||||
claimsByUri,
|
||||
doFetchViewCount,
|
||||
} = props;
|
||||
const didNavigateForward = history.action === 'PUSH';
|
||||
const { search } = location;
|
||||
@@ -153,6 +172,7 @@ function ClaimListDiscover(props: Props) {
|
||||
(urlParams.get(CS.TAGS_KEY) !== null && urlParams.get(CS.TAGS_KEY)) ||
|
||||
(defaultTags && getParamFromTags(defaultTags));
|
||||
const freshnessParam = freshness || urlParams.get(CS.FRESH_KEY) || defaultFreshness;
|
||||
const sortByParam = sortBy || urlParams.get(CS.SORT_BY_KEY) || CS.SORT_BY.NEWEST.key;
|
||||
const mutedAndBlockedChannelIds = Array.from(
|
||||
new Set(mutedUris.concat(blockedUris).map((uri) => splitBySeparator(uri)[1]))
|
||||
);
|
||||
@@ -238,12 +258,7 @@ function ClaimListDiscover(props: Props) {
|
||||
no_totals: true,
|
||||
not_channel_ids: isChannel ? undefined : mutedAndBlockedChannelIds,
|
||||
not_tags: !showNsfw ? MATURE_TAGS : [],
|
||||
order_by:
|
||||
orderParam === CS.ORDER_BY_TRENDING
|
||||
? CS.ORDER_BY_TRENDING_VALUE
|
||||
: orderParam === CS.ORDER_BY_NEW
|
||||
? CS.ORDER_BY_NEW_VALUE
|
||||
: CS.ORDER_BY_TOP_VALUE, // Sort by top
|
||||
order_by: resolveOrderByOption(orderParam, sortByParam),
|
||||
};
|
||||
|
||||
if (ENABLE_NO_SOURCE_CLAIMS && hasNoSource) {
|
||||
@@ -518,6 +533,37 @@ function ClaimListDiscover(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
function fetchViewCountForUris(uris) {
|
||||
const claimIds = [];
|
||||
|
||||
if (uris) {
|
||||
uris.forEach((uri) => {
|
||||
if (claimsByUri[uri]) {
|
||||
claimIds.push(claimsByUri[uri].claim_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (claimIds.length > 0) {
|
||||
doFetchViewCount(claimIds.join(','));
|
||||
}
|
||||
}
|
||||
|
||||
function resolveOrderByOption(orderBy: string | Array<string>, sortBy: string | Array<string>) {
|
||||
const order_by =
|
||||
orderBy === CS.ORDER_BY_TRENDING
|
||||
? CS.ORDER_BY_TRENDING_VALUE
|
||||
: orderBy === CS.ORDER_BY_NEW
|
||||
? CS.ORDER_BY_NEW_VALUE
|
||||
: CS.ORDER_BY_TOP_VALUE;
|
||||
|
||||
if (orderBy === CS.ORDER_BY_NEW && sortBy === CS.SORT_BY.OLDEST.key) {
|
||||
return order_by.map((x) => `${CS.SORT_BY.OLDEST.opt}${x}`);
|
||||
}
|
||||
|
||||
return order_by;
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
@@ -547,6 +593,12 @@ function ClaimListDiscover(props: Props) {
|
||||
}
|
||||
}, [uris, claimSearchResult, finalUris, setFinalUris, liveLivestreamsFirst, livestreamSearchResult]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (fetchViewCount) {
|
||||
fetchViewCountForUris(finalUris);
|
||||
}
|
||||
}, [finalUris]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const headerToUse = header || (
|
||||
<ClaimListHeader
|
||||
channelIds={channelIds}
|
||||
@@ -583,7 +635,6 @@ function ClaimListDiscover(props: Props) {
|
||||
)}
|
||||
<ClaimList
|
||||
tileLayout
|
||||
id={mainSearchKey}
|
||||
loading={loading}
|
||||
uris={finalUris}
|
||||
onScrollBottom={handleScrollBottom}
|
||||
@@ -617,7 +668,6 @@ function ClaimListDiscover(props: Props) {
|
||||
</div>
|
||||
)}
|
||||
<ClaimList
|
||||
id={mainSearchKey}
|
||||
type={type}
|
||||
loading={loading}
|
||||
uris={finalUris}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// @flow
|
||||
import { SIMPLE_SITE } from 'config';
|
||||
import * as CS from 'constants/claim_search';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import type { Node } from 'react';
|
||||
@@ -21,6 +20,7 @@ type Props = {
|
||||
streamType?: string | Array<string>,
|
||||
defaultStreamType?: string | Array<string>,
|
||||
feeAmount: string,
|
||||
sortBy?: string,
|
||||
orderBy?: Array<string>,
|
||||
defaultOrderBy?: string,
|
||||
hideAdvancedFilter: boolean,
|
||||
@@ -45,6 +45,7 @@ function ClaimListHeader(props: Props) {
|
||||
streamType,
|
||||
defaultStreamType,
|
||||
feeAmount,
|
||||
sortBy,
|
||||
orderBy,
|
||||
defaultOrderBy,
|
||||
hideAdvancedFilter,
|
||||
@@ -71,6 +72,7 @@ function ClaimListHeader(props: Props) {
|
||||
streamType || (CS.FILE_TYPES.includes(contentTypeParam) && contentTypeParam) || defaultStreamType || null;
|
||||
const durationParam = urlParams.get(CS.DURATION_KEY) || null;
|
||||
const languageParam = urlParams.get(CS.LANGUAGE_KEY) || null;
|
||||
const sortByParam = sortBy || urlParams.get(CS.SORT_BY_KEY) || null;
|
||||
const channelIdsInUrl = urlParams.get(CS.CHANNEL_IDS_KEY);
|
||||
const channelIdsParam = channelIdsInUrl ? channelIdsInUrl.split(',') : channelIds;
|
||||
const feeAmountParam = urlParams.get('fee_amount') || feeAmount || CS.FEE_AMOUNT_ANY;
|
||||
@@ -153,6 +155,13 @@ function ClaimListHeader(props: Props) {
|
||||
case CS.ORDER_BY_KEY:
|
||||
newUrlParams.set(CS.ORDER_BY_KEY, delta.value);
|
||||
break;
|
||||
case CS.SORT_BY_KEY:
|
||||
if (delta.value === CS.SORT_BY.NEWEST.key) {
|
||||
newUrlParams.delete(CS.SORT_BY_KEY);
|
||||
} else {
|
||||
newUrlParams.set(CS.SORT_BY_KEY, delta.value);
|
||||
}
|
||||
break;
|
||||
case CS.FRESH_KEY:
|
||||
if (delta.value === defaultFreshness || delta.value === CS.FRESH_DEFAULT) {
|
||||
newUrlParams.delete(CS.FRESH_KEY);
|
||||
@@ -240,7 +249,7 @@ function ClaimListHeader(props: Props) {
|
||||
</div>
|
||||
)}
|
||||
<div className="claim-search__menu-group">
|
||||
{!hideAdvancedFilter && !SIMPLE_SITE && (
|
||||
{!hideAdvancedFilter && (
|
||||
<Button
|
||||
button="alt"
|
||||
aria-label={__('More')}
|
||||
@@ -266,7 +275,7 @@ function ClaimListHeader(props: Props) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{expanded && !SIMPLE_SITE && (
|
||||
{expanded && (
|
||||
<>
|
||||
<div className={classnames(`card claim-search__menus`)}>
|
||||
{/* FRESHNESS FIELD */}
|
||||
@@ -449,6 +458,32 @@ function ClaimListHeader(props: Props) {
|
||||
</FormField>
|
||||
</div>
|
||||
|
||||
{/* SORT FIELD */}
|
||||
{orderParam === CS.ORDER_BY_NEW && (
|
||||
<div className={'claim-search__input-container'}>
|
||||
<FormField
|
||||
className={classnames('claim-search__dropdown', {
|
||||
'claim-search__dropdown--selected': sortByParam,
|
||||
})}
|
||||
label={__('Sort By')}
|
||||
type="select"
|
||||
name="sort_by"
|
||||
value={sortByParam || CS.SORT_BY.NEWEST.key}
|
||||
onChange={(e) => handleChange({ key: CS.SORT_BY_KEY, value: e.target.value })}
|
||||
>
|
||||
{Object.entries(CS.SORT_BY).map(([key, value]) => {
|
||||
return (
|
||||
// $FlowFixMe https://github.com/facebook/flow/issues/2221
|
||||
<option key={value.key} value={value.key}>
|
||||
{/* $FlowFixMe */}
|
||||
{__(value.str)}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</FormField>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{channelIdsInUrl && (
|
||||
<div className={'claim-search__input-container'}>
|
||||
<label>{__('Advanced Filters from URL')}</label>
|
||||
|
||||
@@ -31,14 +31,13 @@ import { doChannelSubscribe, doChannelUnsubscribe } from 'redux/actions/subscrip
|
||||
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import { selectListShuffle } from 'redux/selectors/content';
|
||||
import { doSetPlayingUri, doToggleShuffleList } from 'redux/actions/content';
|
||||
import { doToggleLoopList, doToggleShuffleList } from 'redux/actions/content';
|
||||
import ClaimPreview from './view';
|
||||
import fs from 'fs';
|
||||
|
||||
const select = (state, props) => {
|
||||
const claim = makeSelectClaimForUri(props.uri, false)(state);
|
||||
const collectionId = props.collectionId;
|
||||
const resolvedList = makeSelectUrlsForCollectionId(collectionId)(state);
|
||||
const repostedClaim = claim && claim.reposted_claim;
|
||||
const contentClaim = repostedClaim || claim;
|
||||
const contentSigningChannel = contentClaim && contentClaim.signing_channel;
|
||||
@@ -73,7 +72,7 @@ const select = (state, props) => {
|
||||
isMyCollection: makeSelectCollectionIsMine(collectionId)(state),
|
||||
editedCollection: makeSelectEditedCollectionForId(collectionId)(state),
|
||||
isAuthenticated: Boolean(selectUserVerifiedEmail(state)),
|
||||
resolvedList,
|
||||
resolvedList: makeSelectUrlsForCollectionId(collectionId)(state),
|
||||
playNextUri,
|
||||
};
|
||||
};
|
||||
@@ -102,8 +101,10 @@ const perform = (dispatch) => ({
|
||||
doChannelUnsubscribe: (subscription) => dispatch(doChannelUnsubscribe(subscription)),
|
||||
doCollectionEdit: (collection, props) => dispatch(doCollectionEdit(collection, props)),
|
||||
fetchCollectionItems: (collectionId) => dispatch(doFetchItemsInCollection({ collectionId })),
|
||||
doSetPlayingUri: (uri) => dispatch(doSetPlayingUri({ uri })),
|
||||
doToggleShuffleList: (collectionId) => dispatch(doToggleShuffleList(undefined, collectionId, true, true)),
|
||||
doToggleShuffleList: (collectionId) => {
|
||||
dispatch(doToggleLoopList(collectionId, false, true));
|
||||
dispatch(doToggleShuffleList(undefined, collectionId, true, true));
|
||||
},
|
||||
});
|
||||
|
||||
export default connect(select, perform)(ClaimPreview);
|
||||
@@ -7,7 +7,13 @@ import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import { Menu, MenuButton, MenuList, MenuItem } from '@reach/menu-button';
|
||||
import Icon from 'component/common/icon';
|
||||
import { generateShareUrl, generateRssUrl, generateLbryContentUrl, formatLbryUrlForWeb } from 'util/url';
|
||||
import {
|
||||
generateShareUrl,
|
||||
generateRssUrl,
|
||||
generateLbryContentUrl,
|
||||
formatLbryUrlForWeb,
|
||||
generateListSearchUrlParams,
|
||||
} from 'util/url';
|
||||
import { useHistory } from 'react-router';
|
||||
import { buildURI, parseURI, COLLECTIONS_CONSTS } from 'lbry-redux';
|
||||
|
||||
@@ -59,7 +65,6 @@ type Props = {
|
||||
playNextUri: string,
|
||||
resolvedList: boolean,
|
||||
fetchCollectionItems: (string) => void,
|
||||
doSetPlayingUri: (string) => void,
|
||||
doToggleShuffleList: (string) => void,
|
||||
};
|
||||
|
||||
@@ -101,7 +106,6 @@ function ClaimMenuList(props: Props) {
|
||||
playNextUri,
|
||||
resolvedList,
|
||||
fetchCollectionItems,
|
||||
doSetPlayingUri,
|
||||
doToggleShuffleList,
|
||||
} = props;
|
||||
const [doShuffle, setDoShuffle] = React.useState(false);
|
||||
@@ -129,15 +133,15 @@ function ClaimMenuList(props: Props) {
|
||||
if (doShuffle && resolvedList) {
|
||||
doToggleShuffleList(collectionId);
|
||||
if (playNextUri) {
|
||||
const collectionParams = new URLSearchParams();
|
||||
collectionParams.set(COLLECTIONS_CONSTS.COLLECTION_ID, collectionId);
|
||||
const navigateUrl = formatLbryUrlForWeb(playNextUri) + `?` + collectionParams.toString();
|
||||
setDoShuffle(false);
|
||||
doSetPlayingUri(playNextUri);
|
||||
push(navigateUrl);
|
||||
const navigateUrl = formatLbryUrlForWeb(playNextUri);
|
||||
push({
|
||||
pathname: navigateUrl,
|
||||
search: generateListSearchUrlParams(collectionId),
|
||||
state: { collectionId, forceAutoplay: true },
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [collectionId, doSetPlayingUri, doShuffle, doToggleShuffleList, playNextUri, push, resolvedList]);
|
||||
}, [collectionId, doShuffle, doToggleShuffleList, playNextUri, push, resolvedList]);
|
||||
|
||||
if (!claim) {
|
||||
return null;
|
||||
@@ -259,6 +263,7 @@ function ClaimMenuList(props: Props) {
|
||||
push(`/$/${PAGES.REPORT_CONTENT}?claimId=${contentClaim && contentClaim.claim_id}`);
|
||||
}
|
||||
|
||||
const shouldShow = !IS_WEB || (IS_WEB && isAuthenticated);
|
||||
return (
|
||||
<Menu>
|
||||
<MenuButton
|
||||
@@ -271,94 +276,93 @@ function ClaimMenuList(props: Props) {
|
||||
<Icon size={20} icon={ICONS.MORE_VERTICAL} />
|
||||
</MenuButton>
|
||||
<MenuList className="menu__list">
|
||||
{(!IS_WEB || (IS_WEB && isAuthenticated)) && (
|
||||
<>
|
||||
<>
|
||||
{/* COLLECTION OPERATIONS */}
|
||||
{collectionId && isCollectionClaim ? (
|
||||
<>
|
||||
{/* COLLECTION OPERATIONS */}
|
||||
{collectionId && isCollectionClaim ? (
|
||||
<MenuItem className="comment__menu-option" onSelect={() => push(`/$/${PAGES.LIST}/${collectionId}`)}>
|
||||
<a className="menu__link" href={`/$/${PAGES.LIST}/${collectionId}`}>
|
||||
<Icon aria-hidden icon={ICONS.VIEW} />
|
||||
{__('View List')}
|
||||
</a>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => {
|
||||
if (!resolvedList) fetchItems();
|
||||
setDoShuffle(true);
|
||||
}}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.SHUFFLE} />
|
||||
{__('Shuffle Play')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
{isMyCollection && (
|
||||
<>
|
||||
<MenuItem className="comment__menu-option" onSelect={() => push(`/$/${PAGES.LIST}/${collectionId}`)}>
|
||||
<a className="menu__link" href={`/$/${PAGES.LIST}/${collectionId}`}>
|
||||
<Icon aria-hidden icon={ICONS.VIEW} />
|
||||
{__('View List')}
|
||||
</a>
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => push(`/$/${PAGES.LIST}/${collectionId}?view=edit`)}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden iconColor={'red'} icon={ICONS.PUBLISH} />
|
||||
{editedCollection ? __('Publish') : __('Edit List')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => {
|
||||
if (!resolvedList) fetchItems();
|
||||
setDoShuffle(true);
|
||||
}}
|
||||
onSelect={() => openModal(MODALS.COLLECTION_DELETE, { collectionId })}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.SHUFFLE} />
|
||||
{__('Shuffle Play')}
|
||||
<Icon aria-hidden icon={ICONS.DELETE} />
|
||||
{__('Delete List')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
{isMyCollection && (
|
||||
<>
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => push(`/$/${PAGES.LIST}/${collectionId}?view=edit`)}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden iconColor={'red'} icon={ICONS.PUBLISH} />
|
||||
{editedCollection ? __('Publish') : __('Edit List')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => openModal(MODALS.COLLECTION_DELETE, { collectionId })}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.DELETE} />
|
||||
{__('Delete List')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
isPlayable && (
|
||||
<>
|
||||
{/* WATCH LATER */}
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() =>
|
||||
handleAdd(hasClaimInWatchLater, __('Watch Later'), COLLECTIONS_CONSTS.WATCH_LATER_ID)
|
||||
}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={hasClaimInWatchLater ? ICONS.DELETE : ICONS.TIME} />
|
||||
{hasClaimInWatchLater ? __('In Watch Later') : __('Watch Later')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
{/* FAVORITES LIST */}
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => handleAdd(hasClaimInFavorites, __('Favorites'), COLLECTIONS_CONSTS.FAVORITES_ID)}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={hasClaimInFavorites ? ICONS.DELETE : ICONS.STAR} />
|
||||
{hasClaimInFavorites ? __('In Favorites') : __('Favorites')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
{/* CURRENTLY ONLY SUPPORT PLAYLISTS FOR PLAYABLE; LATER DIFFERENT TYPES */}
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => openModal(MODALS.COLLECTION_ADD, { uri, type: 'playlist' })}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.STACK} />
|
||||
{__('Add to Lists')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
<hr className="menu__separator" />
|
||||
</>
|
||||
)
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
shouldShow &&
|
||||
isPlayable && (
|
||||
<>
|
||||
{/* WATCH LATER */}
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => handleAdd(hasClaimInWatchLater, __('Watch Later'), COLLECTIONS_CONSTS.WATCH_LATER_ID)}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={hasClaimInWatchLater ? ICONS.DELETE : ICONS.TIME} />
|
||||
{hasClaimInWatchLater ? __('In Watch Later') : __('Watch Later')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
{/* FAVORITES LIST */}
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => handleAdd(hasClaimInFavorites, __('Favorites'), COLLECTIONS_CONSTS.FAVORITES_ID)}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={hasClaimInFavorites ? ICONS.DELETE : ICONS.STAR} />
|
||||
{hasClaimInFavorites ? __('In Favorites') : __('Favorites')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
{/* CURRENTLY ONLY SUPPORT PLAYLISTS FOR PLAYABLE; LATER DIFFERENT TYPES */}
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => openModal(MODALS.COLLECTION_ADD, { uri, type: 'playlist' })}
|
||||
>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.STACK} />
|
||||
{__('Add to Lists')}
|
||||
</div>
|
||||
</MenuItem>
|
||||
<hr className="menu__separator" />
|
||||
</>
|
||||
)
|
||||
)}
|
||||
</>
|
||||
|
||||
{shouldShow && (
|
||||
<>
|
||||
{!isChannelPage && (
|
||||
<>
|
||||
<MenuItem className="comment__menu-option" onSelect={handleSupport}>
|
||||
@@ -435,9 +439,9 @@ function ClaimMenuList(props: Props) {
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<hr className="menu__separator" />
|
||||
</>
|
||||
)}
|
||||
<hr className="menu__separator" />
|
||||
|
||||
<MenuItem className="comment__menu-option" onSelect={handleCopyLink}>
|
||||
<div className="menu__link">
|
||||
|
||||
@@ -29,7 +29,6 @@ import ClaimPreviewNoContent from './claim-preview-no-content';
|
||||
import { ENABLE_NO_SOURCE_CLAIMS } from 'config';
|
||||
import Button from 'component/button';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import { CONTAINER_ID } from 'constants/navigation';
|
||||
|
||||
const AbandonedChannelPreview = lazyImport(() =>
|
||||
import('component/abandonedChannelPreview' /* webpackChunkName: "abandonedChannelPreview" */)
|
||||
@@ -67,7 +66,7 @@ type Props = {
|
||||
actions: boolean | Node | string | number,
|
||||
properties: boolean | Node | string | number | ((Claim) => Node),
|
||||
empty?: Node,
|
||||
onClick?: (e: any, index?: number) => any,
|
||||
onClick?: (e: any, claim?: ?Claim, index?: number) => any,
|
||||
streamingUrl: ?string,
|
||||
getFile: (string) => void,
|
||||
customShouldHide?: (Claim) => boolean,
|
||||
@@ -90,7 +89,6 @@ type Props = {
|
||||
disableNavigation?: boolean,
|
||||
mediaDuration?: string,
|
||||
date?: any,
|
||||
containerId?: string, // ID or name of the container (e.g. ClaimList, HOC, etc.) that this is in.
|
||||
indexInContainer?: number, // The index order of this component within 'containerId'.
|
||||
channelSubCount?: number,
|
||||
};
|
||||
@@ -154,7 +152,6 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
isCollectionMine,
|
||||
collectionUris,
|
||||
disableNavigation,
|
||||
containerId,
|
||||
indexInContainer,
|
||||
channelSubCount,
|
||||
} = props;
|
||||
@@ -198,8 +195,12 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
claim.value.stream_type &&
|
||||
// $FlowFixMe
|
||||
(claim.value.stream_type === 'audio' || claim.value.stream_type === 'video');
|
||||
const isChannelUri = isValid ? parseURI(uri).isChannel : false;
|
||||
const isChannelUri = claim ? claim.value_type === 'channel' : false;
|
||||
const signingChannel = claim && claim.signing_channel;
|
||||
const repostedChannelUri =
|
||||
claim && claim.repost_channel_url && claim.value_type === 'channel'
|
||||
? claim.permanent_url || claim.canonical_url
|
||||
: undefined;
|
||||
|
||||
// Get channel title ( use name as fallback )
|
||||
let channelTitle = null;
|
||||
@@ -223,7 +224,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
|
||||
const handleNavLinkClick = (e) => {
|
||||
if (onClick) {
|
||||
onClick(e, indexInContainer);
|
||||
onClick(e, claim, indexInContainer); // not sure indexInContainer is used for anything.
|
||||
}
|
||||
e.stopPropagation();
|
||||
};
|
||||
@@ -232,10 +233,9 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
to: {
|
||||
pathname: navigateUrl,
|
||||
search: navigateSearch.toString() ? '?' + navigateSearch.toString() : '',
|
||||
state: containerId ? { [CONTAINER_ID]: containerId } : undefined,
|
||||
},
|
||||
onClick: (e) => handleNavLinkClick(e),
|
||||
onAuxClick: (e) => handleNavLinkClick(e),
|
||||
onClick: handleNavLinkClick,
|
||||
onAuxClick: handleNavLinkClick,
|
||||
};
|
||||
|
||||
// do not block abandoned and nsfw claims if showUserBlocked is passed
|
||||
@@ -281,14 +281,13 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
|
||||
function handleOnClick(e) {
|
||||
if (onClick) {
|
||||
onClick(e, indexInContainer);
|
||||
onClick(e, claim, indexInContainer);
|
||||
}
|
||||
|
||||
if (claim && !pending && !disableNavigation) {
|
||||
history.push({
|
||||
pathname: navigateUrl,
|
||||
search: navigateSearch.toString() ? '?' + navigateSearch.toString() : '',
|
||||
state: containerId ? { [CONTAINER_ID]: containerId } : undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -483,7 +482,9 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
)}
|
||||
|
||||
{isChannelUri && !channelIsBlocked && !claimIsMine && (
|
||||
<SubscribeButton uri={uri.startsWith('lbry://') ? uri : `lbry://${uri}`} />
|
||||
<SubscribeButton
|
||||
uri={repostedChannelUri || (uri.startsWith('lbry://') ? uri : `lbry://${uri}`)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{includeSupportAction && <ClaimSupportButton uri={uri} />}
|
||||
|
||||
@@ -4,6 +4,7 @@ import React from 'react';
|
||||
import UriIndicator from 'component/uriIndicator';
|
||||
import DateTime from 'component/dateTime';
|
||||
import Button from 'component/button';
|
||||
import FileViewCountInline from 'component/fileViewCountInline';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
|
||||
type Props = {
|
||||
@@ -37,7 +38,14 @@ function ClaimPreviewSubtitle(props: Props) {
|
||||
`${claimsInChannel} ${claimsInChannel === 1 ? __('upload') : __('uploads')}`}
|
||||
|
||||
{!isChannel &&
|
||||
(isLivestream && ENABLE_NO_SOURCE_CLAIMS ? __('Livestream') : <DateTime timeAgo uri={uri} />)}
|
||||
(isLivestream && ENABLE_NO_SOURCE_CLAIMS ? (
|
||||
__('Livestream')
|
||||
) : (
|
||||
<>
|
||||
<FileViewCountInline uri={uri} isLivestream={isLivestream} />
|
||||
<DateTime timeAgo uri={uri} />
|
||||
</>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</React.Fragment>
|
||||
|
||||
@@ -7,11 +7,12 @@ import UriIndicator from 'component/uriIndicator';
|
||||
import TruncatedText from 'component/common/truncated-text';
|
||||
import DateTime from 'component/dateTime';
|
||||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
import FileViewCountInline from 'component/fileViewCountInline';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import useGetThumbnail from 'effects/use-get-thumbnail';
|
||||
import { formatLbryUrlForWeb } from 'util/url';
|
||||
import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url';
|
||||
import { formatClaimPreviewTitle } from 'util/formatAriaLabel';
|
||||
import { parseURI, COLLECTIONS_CONSTS, isURIEqual } from 'lbry-redux';
|
||||
import { parseURI, isURIEqual } from 'lbry-redux';
|
||||
import PreviewOverlayProperties from 'component/previewOverlayProperties';
|
||||
import FileDownloadLink from 'component/fileDownloadLink';
|
||||
import FileWatchLaterLink from 'component/fileWatchLaterLink';
|
||||
@@ -96,13 +97,10 @@ function ClaimPreviewTile(props: Props) {
|
||||
const shouldFetch = claim === undefined;
|
||||
const thumbnailUrl = useGetThumbnail(uri, claim, streamingUrl, getFile, placeholder) || thumbnail;
|
||||
const canonicalUrl = claim && claim.canonical_url;
|
||||
let navigateUrl = formatLbryUrlForWeb(canonicalUrl || uri || '/');
|
||||
const permanentUrl = claim && claim.permanent_url;
|
||||
const listId = collectionId || collectionClaimId;
|
||||
if (listId) {
|
||||
const collectionParams = new URLSearchParams();
|
||||
collectionParams.set(COLLECTIONS_CONSTS.COLLECTION_ID, listId);
|
||||
navigateUrl = navigateUrl + `?` + collectionParams.toString();
|
||||
}
|
||||
const navigateUrl =
|
||||
formatLbryUrlForWeb(canonicalUrl || uri || '/') + (listId ? generateListSearchUrlParams(listId) : '');
|
||||
const navLinkProps = {
|
||||
to: navigateUrl,
|
||||
onClick: (e) => e.stopPropagation(),
|
||||
@@ -122,6 +120,7 @@ function ClaimPreviewTile(props: Props) {
|
||||
const isChannel = claim && claim.value_type === 'channel';
|
||||
const channelUri = !isChannel ? signingChannel && signingChannel.permanent_url : claim && claim.permanent_url;
|
||||
const channelTitle = signingChannel && ((signingChannel.value && signingChannel.value.title) || signingChannel.name);
|
||||
const repostedChannelUri = isRepost && isChannel ? permanentUrl || canonicalUrl : undefined;
|
||||
|
||||
// Aria-label value for claim preview
|
||||
let ariaLabelData = isChannel ? title : formatClaimPreviewTitle(title, channelTitle, date, mediaDuration);
|
||||
@@ -210,15 +209,11 @@ function ClaimPreviewTile(props: Props) {
|
||||
{!isChannel && (
|
||||
<React.Fragment>
|
||||
<div className="claim-preview__hover-actions">
|
||||
{isPlayable && (
|
||||
<FileWatchLaterLink focusable={false} uri={uri} />
|
||||
)}
|
||||
{isPlayable && <FileWatchLaterLink focusable={false} uri={uri} />}
|
||||
</div>
|
||||
{/* @if TARGET='app' */}
|
||||
<div className="claim-preview__hover-actions">
|
||||
{isStream && (
|
||||
<FileDownloadLink focusable={false} uri={canonicalUrl} hideOpenButton />
|
||||
)}
|
||||
{isStream && <FileDownloadLink focusable={false} uri={canonicalUrl} hideOpenButton />}
|
||||
</div>
|
||||
{/* @endif */}
|
||||
|
||||
@@ -226,7 +221,6 @@ function ClaimPreviewTile(props: Props) {
|
||||
<PreviewOverlayProperties uri={uri} properties={liveProperty || properties} />
|
||||
</div>
|
||||
</React.Fragment>
|
||||
|
||||
)}
|
||||
{isCollection && (
|
||||
<React.Fragment>
|
||||
@@ -254,7 +248,7 @@ function ClaimPreviewTile(props: Props) {
|
||||
<div className="claim-tile__info">
|
||||
{isChannel ? (
|
||||
<div className="claim-tile__about--channel">
|
||||
<SubscribeButton uri={uri} />
|
||||
<SubscribeButton uri={repostedChannelUri || uri} />
|
||||
</div>
|
||||
) : (
|
||||
<React.Fragment>
|
||||
@@ -264,7 +258,10 @@ function ClaimPreviewTile(props: Props) {
|
||||
|
||||
<div className="claim-tile__about">
|
||||
<UriIndicator uri={uri} link />
|
||||
<DateTime timeAgo uri={uri} />
|
||||
<div className="claim-tile__about--counts">
|
||||
<FileViewCountInline uri={uri} isLivestream={isLivestream} />
|
||||
<DateTime timeAgo uri={uri} />
|
||||
</div>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
)}
|
||||
@@ -279,4 +276,34 @@ function ClaimPreviewTile(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
export default withRouter(ClaimPreviewTile);
|
||||
export default React.memo<Props>(withRouter(ClaimPreviewTile), areEqual);
|
||||
|
||||
const BLOCKLIST_KEYS = ['blackListedOutpoints', 'filteredOutpoints', 'blockedChannelUris'];
|
||||
const HANDLED_KEYS = [...BLOCKLIST_KEYS, 'date'];
|
||||
|
||||
function areEqual(prev: Props, next: Props) {
|
||||
for (let i = 0; i < BLOCKLIST_KEYS.length; ++i) {
|
||||
const key = BLOCKLIST_KEYS[i];
|
||||
const a = prev[key];
|
||||
const b = next[key];
|
||||
|
||||
if (((!a || !b) && a !== b) || (a && b && a.length !== b.length)) {
|
||||
// The arrays are huge, so just compare the length instead of each entry.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Number(prev.date) !== Number(next.date)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const propKeys = Object.keys(next);
|
||||
for (let i = 0; i < propKeys.length; ++i) {
|
||||
const pk = propKeys[i];
|
||||
if (!HANDLED_KEYS.includes(pk) && prev[pk] !== next[pk]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
SETTINGS,
|
||||
selectClaimsByUri,
|
||||
} from 'lbry-redux';
|
||||
import { doFetchViewCount } from 'lbryinc';
|
||||
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
|
||||
import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { selectModerationBlockList } from 'redux/selectors/comments';
|
||||
@@ -25,6 +26,7 @@ const select = (state) => ({
|
||||
const perform = {
|
||||
doClaimSearch,
|
||||
doToggleTagFollowDesktop,
|
||||
doFetchViewCount,
|
||||
};
|
||||
|
||||
export default connect(select, perform)(ClaimListDiscover);
|
||||
@@ -86,18 +86,15 @@ export function prioritizeActiveLivestreams(
|
||||
|
||||
type Props = {
|
||||
prefixUris?: Array<string>,
|
||||
pinUrls?: Array<string>,
|
||||
uris: Array<string>,
|
||||
doClaimSearch: ({}) => void,
|
||||
showNsfw: boolean,
|
||||
hideReposts: boolean,
|
||||
history: { action: string, push: (string) => void, replace: (string) => void },
|
||||
claimSearchByQuery: { [string]: Array<string> },
|
||||
fetchingClaimSearchByQuery: { [string]: boolean },
|
||||
claimsByUri: { [string]: any },
|
||||
liveLivestreamsFirst?: boolean,
|
||||
livestreamMap?: { [string]: any },
|
||||
showNoSourceClaims?: boolean,
|
||||
renderProperties?: (Claim) => ?Node,
|
||||
fetchViewCount?: boolean,
|
||||
// claim search options are below
|
||||
tags: Array<string>,
|
||||
blockedUris: Array<string>,
|
||||
mutedUris: Array<string>,
|
||||
claimIds?: Array<string>,
|
||||
channelIds?: Array<string>,
|
||||
pageSize: number,
|
||||
@@ -111,11 +108,17 @@ type Props = {
|
||||
limitClaimsPerChannel?: number,
|
||||
hasSource?: boolean,
|
||||
hasNoSource?: boolean,
|
||||
renderProperties?: (Claim) => ?Node,
|
||||
liveLivestreamsFirst?: boolean,
|
||||
livestreamMap?: { [string]: any },
|
||||
pinUrls?: Array<string>,
|
||||
showNoSourceClaims?: boolean,
|
||||
// --- select ---
|
||||
claimSearchByQuery: { [string]: Array<string> },
|
||||
claimsByUri: { [string]: any },
|
||||
fetchingClaimSearchByQuery: { [string]: boolean },
|
||||
showNsfw: boolean,
|
||||
hideReposts: boolean,
|
||||
mutedUris: Array<string>,
|
||||
blockedUris: Array<string>,
|
||||
// --- perform ---
|
||||
doClaimSearch: ({}) => void,
|
||||
doFetchViewCount: (claimIdCsv: string) => void,
|
||||
};
|
||||
|
||||
function ClaimTilesDiscover(props: Props) {
|
||||
@@ -125,6 +128,7 @@ function ClaimTilesDiscover(props: Props) {
|
||||
claimsByUri,
|
||||
showNsfw,
|
||||
hideReposts,
|
||||
fetchViewCount,
|
||||
// Below are options to pass that are forwarded to claim_search
|
||||
tags,
|
||||
channelIds,
|
||||
@@ -149,6 +153,7 @@ function ClaimTilesDiscover(props: Props) {
|
||||
pinUrls,
|
||||
prefixUris,
|
||||
showNoSourceClaims,
|
||||
doFetchViewCount,
|
||||
} = props;
|
||||
|
||||
const { location } = useHistory();
|
||||
@@ -269,30 +274,6 @@ function ClaimTilesDiscover(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
if (shouldPerformSearch) {
|
||||
const searchOptions = JSON.parse(optionsStringForEffect);
|
||||
doClaimSearch(searchOptions);
|
||||
|
||||
if (liveLivestreamsFirst) {
|
||||
doClaimSearch(getLivestreamOnlyOptions(searchOptions));
|
||||
}
|
||||
}
|
||||
}, [doClaimSearch, shouldPerformSearch, optionsStringForEffect, liveLivestreamsFirst]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (JSON.stringify(prevUris) !== JSON.stringify(uris) && !shouldPerformSearch) {
|
||||
setPrevUris(uris);
|
||||
}
|
||||
}, [shouldPerformSearch, prevUris, uris]);
|
||||
|
||||
const resolveLive = (index) => {
|
||||
if (liveLivestreamsFirst && livestreamMap && index < liveUris.length) {
|
||||
return true;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const modifiedUris = uris ? uris.slice() : [];
|
||||
const fixUris = pinUrls || [];
|
||||
|
||||
@@ -307,6 +288,60 @@ function ClaimTilesDiscover(props: Props) {
|
||||
modifiedUris.splice(2, 0, ...fixUris);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
function resolveLive(index) {
|
||||
if (liveLivestreamsFirst && livestreamMap && index < liveUris.length) {
|
||||
return true;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function fetchViewCountForUris(uris) {
|
||||
const claimIds = [];
|
||||
|
||||
if (uris) {
|
||||
uris.forEach((uri) => {
|
||||
if (claimsByUri[uri]) {
|
||||
claimIds.push(claimsByUri[uri].claim_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (claimIds.length > 0) {
|
||||
doFetchViewCount(claimIds.join(','));
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
React.useEffect(() => {
|
||||
if (shouldPerformSearch) {
|
||||
const searchOptions = JSON.parse(optionsStringForEffect);
|
||||
doClaimSearch(searchOptions);
|
||||
|
||||
if (liveLivestreamsFirst) {
|
||||
doClaimSearch(getLivestreamOnlyOptions(searchOptions));
|
||||
}
|
||||
}
|
||||
}, [doClaimSearch, shouldPerformSearch, optionsStringForEffect, liveLivestreamsFirst]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (JSON.stringify(prevUris) !== JSON.stringify(uris) && !shouldPerformSearch) {
|
||||
// Stash new results for next render cycle:
|
||||
setPrevUris(uris);
|
||||
// Fetch view count:
|
||||
if (fetchViewCount) {
|
||||
fetchViewCountForUris(uris);
|
||||
}
|
||||
}
|
||||
}, [shouldPerformSearch, prevUris, uris]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
return (
|
||||
<ul className="claim-grid">
|
||||
{modifiedUris && modifiedUris.length
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimIsMine,
|
||||
makeSelectClaimForUri,
|
||||
selectMyChannelClaims,
|
||||
makeSelectClaimIsPending,
|
||||
makeSelectCollectionIsMine,
|
||||
makeSelectEditedCollectionForId,
|
||||
} from 'lbry-redux';
|
||||
import { makeSelectCostInfoForUri } from 'lbryinc';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import { selectListShuffle } from 'redux/selectors/content';
|
||||
import { doPlayUri, doSetPlayingUri, doToggleShuffleList, doToggleLoopList } from 'redux/actions/content';
|
||||
import { doToggleShuffleList, doToggleLoopList } from 'redux/actions/content';
|
||||
import CollectionActions from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
@@ -31,29 +27,23 @@ const select = (state, props) => {
|
||||
const shuffleList = selectListShuffle(state);
|
||||
const shuffle = shuffleList && shuffleList.collectionId === collectionId && shuffleList.newUrls;
|
||||
const playNextUri = shuffle && shuffle[0];
|
||||
const playNextClaim = makeSelectClaimForUri(playNextUri)(state);
|
||||
|
||||
return {
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||
myChannels: selectMyChannelClaims(state),
|
||||
claimIsPending: makeSelectClaimIsPending(props.uri)(state),
|
||||
isMyCollection: makeSelectCollectionIsMine(collectionId)(state),
|
||||
collectionHasEdits: Boolean(makeSelectEditedCollectionForId(collectionId)(state)),
|
||||
firstItem,
|
||||
playNextUri,
|
||||
playNextClaim,
|
||||
};
|
||||
};
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
||||
doToast: (options) => dispatch(doToast(options)),
|
||||
doPlayUri: (uri) => dispatch(doPlayUri(uri)),
|
||||
doSetPlayingUri: (uri) => dispatch(doSetPlayingUri({ uri })),
|
||||
doToggleShuffleList: (collectionId, shuffle) => dispatch(doToggleShuffleList(undefined, collectionId, shuffle, true)),
|
||||
doToggleLoopList: (collectionId, loop) => dispatch(doToggleLoopList(collectionId, loop)),
|
||||
doToggleShuffleList: (collectionId, shuffle) => {
|
||||
dispatch(doToggleLoopList(collectionId, false, true));
|
||||
dispatch(doToggleShuffleList(undefined, collectionId, shuffle, true));
|
||||
},
|
||||
});
|
||||
|
||||
export default connect(select, perform)(CollectionActions);
|
||||
@@ -11,15 +11,12 @@ import { useHistory } from 'react-router';
|
||||
import { EDIT_PAGE, PAGE_VIEW_QUERY } from 'page/collection/view';
|
||||
import classnames from 'classnames';
|
||||
import { ENABLE_FILE_REACTIONS } from 'config';
|
||||
import { COLLECTIONS_CONSTS } from 'lbry-redux';
|
||||
import { formatLbryUrlForWeb } from 'util/url';
|
||||
import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url';
|
||||
|
||||
type Props = {
|
||||
uri: string,
|
||||
claim: StreamClaim,
|
||||
openModal: (id: string, { uri: string, claimIsMine?: boolean, isSupport?: boolean }) => void,
|
||||
myChannels: ?Array<ChannelClaim>,
|
||||
doToast: ({ message: string }) => void,
|
||||
openModal: (id: string, {}) => void,
|
||||
claimIsPending: boolean,
|
||||
isMyCollection: boolean,
|
||||
collectionId: string,
|
||||
@@ -28,11 +25,7 @@ type Props = {
|
||||
collectionHasEdits: boolean,
|
||||
isBuiltin: boolean,
|
||||
doToggleShuffleList: (string, boolean) => void,
|
||||
doToggleLoopList: (string, boolean) => void,
|
||||
playNextUri: string,
|
||||
playNextClaim: StreamClaim,
|
||||
doPlayUri: (string) => void,
|
||||
doSetPlayingUri: (string) => void,
|
||||
firstItem: string,
|
||||
};
|
||||
|
||||
@@ -49,11 +42,7 @@ function CollectionActions(props: Props) {
|
||||
collectionHasEdits,
|
||||
isBuiltin,
|
||||
doToggleShuffleList,
|
||||
doToggleLoopList,
|
||||
playNextUri,
|
||||
playNextClaim,
|
||||
doPlayUri,
|
||||
doSetPlayingUri,
|
||||
firstItem,
|
||||
} = props;
|
||||
const [doShuffle, setDoShuffle] = React.useState(false);
|
||||
@@ -63,23 +52,23 @@ function CollectionActions(props: Props) {
|
||||
const webShareable = true; // collections have cost?
|
||||
|
||||
const doPlay = React.useCallback(
|
||||
(uri) => {
|
||||
const collectionParams = new URLSearchParams();
|
||||
collectionParams.set(COLLECTIONS_CONSTS.COLLECTION_ID, collectionId);
|
||||
const navigateUrl = formatLbryUrlForWeb(uri) + `?` + collectionParams.toString();
|
||||
push(navigateUrl);
|
||||
doSetPlayingUri(uri);
|
||||
doPlayUri(uri);
|
||||
(playUri) => {
|
||||
const navigateUrl = formatLbryUrlForWeb(playUri);
|
||||
push({
|
||||
pathname: navigateUrl,
|
||||
search: generateListSearchUrlParams(collectionId),
|
||||
state: { forceAutoplay: true },
|
||||
});
|
||||
},
|
||||
[collectionId, push, doSetPlayingUri, doPlayUri]
|
||||
[collectionId, push]
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (playNextClaim && doShuffle) {
|
||||
if (playNextUri && doShuffle) {
|
||||
setDoShuffle(false);
|
||||
doPlay(playNextUri);
|
||||
}
|
||||
}, [doPlay, doShuffle, playNextClaim, playNextUri]);
|
||||
}, [doPlay, doShuffle, playNextUri]);
|
||||
|
||||
const lhsSection = (
|
||||
<>
|
||||
@@ -90,7 +79,6 @@ function CollectionActions(props: Props) {
|
||||
title={__('Play')}
|
||||
onClick={() => {
|
||||
doToggleShuffleList(collectionId, false);
|
||||
doToggleLoopList(collectionId, false);
|
||||
doPlay(firstItem);
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function CollectionContent(props: Props) {
|
||||
<span className="file-page__recommended-collection__row">
|
||||
<Button
|
||||
button="alt"
|
||||
title="Loop"
|
||||
title={__('Loop')}
|
||||
icon={ICONS.REPEAT}
|
||||
iconColor={loop && 'blue'}
|
||||
className="button--file-action"
|
||||
@@ -53,7 +53,7 @@ export default function CollectionContent(props: Props) {
|
||||
/>
|
||||
<Button
|
||||
button="alt"
|
||||
title="Shuffle"
|
||||
title={__('Shuffle')}
|
||||
icon={ICONS.SHUFFLE}
|
||||
iconColor={shuffle && 'blue'}
|
||||
className="button--file-action"
|
||||
|
||||
@@ -17,10 +17,10 @@ import {
|
||||
makeSelectClaimIdsForCollectionId,
|
||||
ACTIONS as LBRY_REDUX_ACTIONS,
|
||||
} from 'lbry-redux';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
|
||||
import CollectionForm from './view';
|
||||
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
|
||||
import { doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
@@ -44,10 +44,11 @@ const select = (state, props) => ({
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
||||
publishCollectionUpdate: (params) => dispatch(doCollectionPublishUpdate(params)),
|
||||
publishCollection: (params, collectionId) => dispatch(doCollectionPublish(params, collectionId)),
|
||||
clearCollectionErrors: () => dispatch({ type: LBRY_REDUX_ACTIONS.CLEAR_COLLECTION_ERRORS }),
|
||||
setActiveChannel: (claimId) => dispatch(doSetActiveChannel(claimId)),
|
||||
setIncognito: (incognito) => dispatch(doSetIncognito(incognito)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(CollectionForm);
|
||||
@@ -10,9 +10,9 @@ import ChannelSelector from 'component/channelSelector';
|
||||
import ClaimList from 'component/claimList';
|
||||
import Card from 'component/common/card';
|
||||
import LbcSymbol from 'component/common/lbc-symbol';
|
||||
import ThumbnailPicker from 'component/thumbnailPicker';
|
||||
import SelectThumbnail from 'component/selectThumbnail';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { isNameValid, regexInvalidURI } from 'lbry-redux';
|
||||
import { isNameValid, regexInvalidURI, THUMBNAIL_STATUSES } from 'lbry-redux';
|
||||
import { Tabs, TabList, Tab, TabPanels, TabPanel } from 'component/common/tabs';
|
||||
import { FormField } from 'component/common/form';
|
||||
import { handleBidChange } from 'util/publish';
|
||||
@@ -21,6 +21,7 @@ import { INVALID_NAME_ERROR } from 'constants/claim';
|
||||
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import analytics from 'analytics';
|
||||
|
||||
const LANG_NONE = 'none';
|
||||
const MAX_TAG_SELECT = 5;
|
||||
|
||||
@@ -39,23 +40,20 @@ type Props = {
|
||||
tags: Array<string>,
|
||||
locations: Array<string>,
|
||||
languages: Array<string>,
|
||||
|
||||
collectionId: string,
|
||||
collection: Collection,
|
||||
collectionClaimIds: Array<string>,
|
||||
collectionUrls: Array<string>,
|
||||
publishCollectionUpdate: (CollectionUpdateParams) => Promise<any>,
|
||||
updatingCollection: boolean,
|
||||
updateError: string,
|
||||
publishCollection: (CollectionPublishParams, string) => Promise<any>,
|
||||
createError: string,
|
||||
creatingCollection: boolean,
|
||||
publishCollectionUpdate: (CollectionUpdateParams) => Promise<any>,
|
||||
publishCollection: (CollectionPublishParams, string) => Promise<any>,
|
||||
clearCollectionErrors: () => void,
|
||||
onDone: (string) => void,
|
||||
openModal: (
|
||||
id: string,
|
||||
{ onUpdate: (string) => void, assetName: string, helpText: string, currentValue: string, title: string }
|
||||
) => void,
|
||||
setActiveChannel: (string) => void,
|
||||
setIncognito: (boolean) => void,
|
||||
};
|
||||
|
||||
function CollectionForm(props: Props) {
|
||||
@@ -72,11 +70,8 @@ function CollectionForm(props: Props) {
|
||||
locations,
|
||||
languages = [],
|
||||
// rest
|
||||
onDone,
|
||||
publishCollectionUpdate,
|
||||
updateError,
|
||||
updatingCollection,
|
||||
publishCollection,
|
||||
creatingCollection,
|
||||
createError,
|
||||
disabled,
|
||||
@@ -86,7 +81,12 @@ function CollectionForm(props: Props) {
|
||||
collection,
|
||||
collectionUrls,
|
||||
collectionClaimIds,
|
||||
publishCollectionUpdate,
|
||||
publishCollection,
|
||||
clearCollectionErrors,
|
||||
setActiveChannel,
|
||||
setIncognito,
|
||||
onDone,
|
||||
} = props;
|
||||
const activeChannelName = activeChannelClaim && activeChannelClaim.name;
|
||||
let prefix = IS_WEB ? `${DOMAIN}/` : 'lbry://';
|
||||
@@ -95,18 +95,27 @@ function CollectionForm(props: Props) {
|
||||
}
|
||||
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
|
||||
const collectionName = (claim && claim.name) || (collection && collection.name);
|
||||
|
||||
const collectionChannel = claim && claim.signing_channel ? claim.signing_channel.claim_id : undefined;
|
||||
const hasClaim = !!claim;
|
||||
const [initialized, setInitialized] = React.useState(false);
|
||||
const [nameError, setNameError] = React.useState(undefined);
|
||||
const [bidError, setBidError] = React.useState('');
|
||||
const [params, setParams]: [any, (any) => void] = React.useState(getCollectionParams());
|
||||
const [thumbStatus, setThumbStatus] = React.useState('');
|
||||
const [thumbError, setThumbError] = React.useState('');
|
||||
const [params, setParams]: [any, (any) => void] = React.useState({});
|
||||
const name = params.name;
|
||||
const isNewCollection = !uri;
|
||||
const { replace } = useHistory();
|
||||
const languageParam = params.languages;
|
||||
const languageParam = params.languages || [];
|
||||
const primaryLanguage = Array.isArray(languageParam) && languageParam.length && languageParam[0];
|
||||
const secondaryLanguage = Array.isArray(languageParam) && languageParam.length >= 2 && languageParam[1];
|
||||
|
||||
const hasClaims = params.claims && params.claims.length;
|
||||
const collectionClaimIdsString = JSON.stringify(collectionClaimIds);
|
||||
const itemError = !hasClaims ? __('Cannot publish empty list') : '';
|
||||
const thumbnailError =
|
||||
(thumbError && thumbStatus !== THUMBNAIL_STATUSES.COMPLETE && __('Invalid thumbnail')) ||
|
||||
(thumbStatus === THUMBNAIL_STATUSES.IN_PROGRESS && __('Please wait for thumbnail to finish uploading'));
|
||||
const submitError = nameError || bidError || itemError || updateError || createError || thumbnailError;
|
||||
|
||||
function parseName(newName) {
|
||||
let INVALID_URI_CHARS = new RegExp(regexInvalidURI, 'gu');
|
||||
@@ -117,6 +126,42 @@ function CollectionForm(props: Props) {
|
||||
setParams({ ...params, ...paramObj });
|
||||
}
|
||||
|
||||
function updateParams(paramsObj) {
|
||||
setParams({ ...params, ...paramsObj });
|
||||
}
|
||||
|
||||
// TODO remove this or better decide whether app should delete languages[2+]
|
||||
// This was added because a previous update setting was duplicating language codes
|
||||
function dedupeLanguages(languages) {
|
||||
if (languages.length <= 1) {
|
||||
return languages;
|
||||
} else if (languages.length === 2) {
|
||||
if (languages[0] !== languages[1]) {
|
||||
return languages;
|
||||
} else {
|
||||
return [languages[0]];
|
||||
}
|
||||
} else if (languages.length > 2) {
|
||||
const newLangs = [];
|
||||
languages.forEach((l) => {
|
||||
if (!newLangs.includes(l)) {
|
||||
newLangs.push(l);
|
||||
}
|
||||
});
|
||||
return newLangs;
|
||||
}
|
||||
}
|
||||
|
||||
function handleUpdateThumbnail(update: { [string]: string }) {
|
||||
if (update.thumbnail_url) {
|
||||
setParam(update);
|
||||
} else if (update.thumbnail_status) {
|
||||
setThumbStatus(update.thumbnail_status);
|
||||
} else {
|
||||
setThumbError(update.thumbnail_error);
|
||||
}
|
||||
}
|
||||
|
||||
function getCollectionParams() {
|
||||
const collectionParams: {
|
||||
thumbnail_url?: string,
|
||||
@@ -132,41 +177,25 @@ function CollectionForm(props: Props) {
|
||||
claims: ?Array<string>,
|
||||
} = {
|
||||
thumbnail_url: thumbnailUrl,
|
||||
name: parseName(collectionName),
|
||||
description,
|
||||
title: claim ? title : collectionName,
|
||||
bid: String(amount || 0.001),
|
||||
languages: languages || [],
|
||||
languages: languages ? dedupeLanguages(languages) : [],
|
||||
locations: locations || [],
|
||||
tags: tags
|
||||
? tags.map((tag) => {
|
||||
return { name: tag };
|
||||
})
|
||||
: [],
|
||||
claim_id: claim ? claim.claim_id : undefined,
|
||||
channel_id: claim ? collectionChannel : activeChannelId || undefined,
|
||||
claims: collectionClaimIds,
|
||||
};
|
||||
collectionParams['name'] = parseName(collectionName);
|
||||
|
||||
if (activeChannelId) {
|
||||
collectionParams['channel_id'] = activeChannelId;
|
||||
}
|
||||
|
||||
if (!claim) {
|
||||
collectionParams['title'] = collectionName;
|
||||
}
|
||||
|
||||
if (claim) {
|
||||
collectionParams['claim_id'] = claim.claim_id;
|
||||
collectionParams['title'] = title;
|
||||
}
|
||||
|
||||
return collectionParams;
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
const collectionClaimIds = JSON.parse(collectionClaimIdsString);
|
||||
setParams({ ...params, claims: collectionClaimIds });
|
||||
clearCollectionErrors();
|
||||
}, [collectionClaimIdsString, setParams]);
|
||||
|
||||
function handleLanguageChange(index, code) {
|
||||
let langs = [...languageParam];
|
||||
if (index === 0) {
|
||||
@@ -175,6 +204,9 @@ function CollectionForm(props: Props) {
|
||||
langs = [];
|
||||
} else {
|
||||
langs[0] = code;
|
||||
if (langs[0] === langs[1]) {
|
||||
langs.length = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (code === LANG_NONE || code === langs[0]) {
|
||||
@@ -186,10 +218,6 @@ function CollectionForm(props: Props) {
|
||||
setParams({ ...params, languages: langs });
|
||||
}
|
||||
|
||||
function handleThumbnailChange(thumbnailUrl: string) {
|
||||
setParams({ ...params, thumbnail_url: thumbnailUrl });
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
if (uri) {
|
||||
publishCollectionUpdate(params).then((pendingClaim) => {
|
||||
@@ -210,6 +238,12 @@ function CollectionForm(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
const collectionClaimIds = JSON.parse(collectionClaimIdsString);
|
||||
setParams({ ...params, claims: collectionClaimIds });
|
||||
clearCollectionErrors();
|
||||
}, [collectionClaimIdsString, setParams]);
|
||||
|
||||
React.useEffect(() => {
|
||||
let nameError;
|
||||
if (!name && name !== undefined) {
|
||||
@@ -221,19 +255,38 @@ function CollectionForm(props: Props) {
|
||||
setNameError(nameError);
|
||||
}, [name]);
|
||||
|
||||
// on mount, if we get a collectionChannel, set it.
|
||||
React.useEffect(() => {
|
||||
if (incognito) {
|
||||
const newParams = Object.assign({}, params);
|
||||
delete newParams.channel_id;
|
||||
setParams(newParams);
|
||||
} else if (activeChannelId) {
|
||||
setParams({ ...params, channel_id: activeChannelId });
|
||||
if (hasClaim && !initialized) {
|
||||
if (collectionChannel) {
|
||||
setActiveChannel(collectionChannel);
|
||||
setIncognito(false);
|
||||
} else if (!collectionChannel && hasClaim) {
|
||||
setIncognito(true);
|
||||
}
|
||||
setInitialized(true);
|
||||
}
|
||||
}, [activeChannelId, incognito, setParams]);
|
||||
}, [setInitialized, setActiveChannel, collectionChannel, setIncognito, hasClaim, incognito, initialized]);
|
||||
|
||||
const itemError = !params.claims.length ? __('Cannot publish empty list') : '';
|
||||
const submitError = nameError || bidError || itemError || updateError || createError;
|
||||
// every time activechannel or incognito changes, set it.
|
||||
React.useEffect(() => {
|
||||
if (initialized) {
|
||||
if (activeChannelId) {
|
||||
setParam({ channel_id: activeChannelId });
|
||||
} else if (incognito) {
|
||||
setParam({ channel_id: undefined });
|
||||
}
|
||||
}
|
||||
}, [activeChannelId, incognito, initialized]);
|
||||
|
||||
// setup initial params after we're sure if it's published or not
|
||||
React.useEffect(() => {
|
||||
if (!uri || (uri && hasClaim)) {
|
||||
updateParams(getCollectionParams());
|
||||
}
|
||||
}, [uri, hasClaim]);
|
||||
|
||||
console.log('params', params);
|
||||
return (
|
||||
<>
|
||||
<div className={classnames('main--contained', { 'card--disabled': disabled })}>
|
||||
@@ -252,11 +305,6 @@ function CollectionForm(props: Props) {
|
||||
<Card
|
||||
body={
|
||||
<>
|
||||
<fieldset-group className="fieldset-group--smushed fieldset-group--disabled-prefix">
|
||||
<fieldset-section>
|
||||
<label htmlFor="channel_name">{__('Channel')}</label>
|
||||
</fieldset-section>
|
||||
</fieldset-group>
|
||||
<fieldset-group class="fieldset-group--smushed fieldset-group--disabled-prefix">
|
||||
<fieldset-section>
|
||||
<label htmlFor="channel_name">{__('Name')}</label>
|
||||
@@ -286,11 +334,14 @@ function CollectionForm(props: Props) {
|
||||
value={params.title}
|
||||
onChange={(e) => setParams({ ...params, title: e.target.value })}
|
||||
/>
|
||||
<ThumbnailPicker
|
||||
inline
|
||||
thumbnailParam={params.thumbnail_url}
|
||||
updateThumbnailParam={handleThumbnailChange}
|
||||
/>
|
||||
<fieldset-section>
|
||||
<SelectThumbnail
|
||||
thumbnailParam={params.thumbnail_url}
|
||||
thumbnailParamError={thumbError}
|
||||
thumbnailParamStatus={thumbStatus}
|
||||
updateThumbnailParams={handleUpdateThumbnail}
|
||||
/>
|
||||
</fieldset-section>
|
||||
<FormField
|
||||
type="markdown"
|
||||
name="content_description2"
|
||||
@@ -411,7 +462,9 @@ function CollectionForm(props: Props) {
|
||||
<div className="section__actions">
|
||||
<Button
|
||||
button="primary"
|
||||
disabled={creatingCollection || updatingCollection || nameError || bidError || !params.claims.length}
|
||||
disabled={
|
||||
creatingCollection || updatingCollection || nameError || bidError || thumbnailError || !hasClaims
|
||||
}
|
||||
label={creatingCollection || updatingCollection ? __('Submitting') : __('Submit')}
|
||||
onClick={handleSubmit}
|
||||
/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doCollectionEdit, makeSelectNameForCollectionId, doCollectionDelete } from 'lbry-redux';
|
||||
import { makeSelectNameForCollectionId } from 'lbry-redux';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import { selectListShuffle } from 'redux/selectors/content';
|
||||
import { doSetPlayingUri, doToggleShuffleList } from 'redux/actions/content';
|
||||
import { doToggleLoopList, doToggleShuffleList } from 'redux/actions/content';
|
||||
import CollectionMenuList from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
@@ -17,10 +17,12 @@ const select = (state, props) => {
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(select, {
|
||||
doCollectionEdit,
|
||||
doOpenModal,
|
||||
doCollectionDelete,
|
||||
doSetPlayingUri,
|
||||
doToggleShuffleList,
|
||||
})(CollectionMenuList);
|
||||
const perform = (dispatch) => ({
|
||||
doOpenModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
||||
doToggleShuffleList: (collectionId) => {
|
||||
dispatch(doToggleLoopList(collectionId, false, true));
|
||||
dispatch(doToggleShuffleList(undefined, collectionId, true, true));
|
||||
},
|
||||
});
|
||||
|
||||
export default connect(select, perform)(CollectionMenuList);
|
||||
@@ -7,8 +7,7 @@ import { Menu, MenuButton, MenuList, MenuItem } from '@reach/menu-button';
|
||||
import Icon from 'component/common/icon';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import { useHistory } from 'react-router';
|
||||
import { formatLbryUrlForWeb } from 'util/url';
|
||||
import { COLLECTIONS_CONSTS } from 'lbry-redux';
|
||||
import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url';
|
||||
|
||||
type Props = {
|
||||
inline?: boolean,
|
||||
@@ -16,34 +15,26 @@ type Props = {
|
||||
collectionName?: string,
|
||||
collectionId: string,
|
||||
playNextUri: string,
|
||||
doSetPlayingUri: ({ uri: ?string }) => void,
|
||||
doToggleShuffleList: (string, string, boolean, boolean) => void,
|
||||
doToggleShuffleList: (string) => void,
|
||||
};
|
||||
|
||||
function CollectionMenuList(props: Props) {
|
||||
const {
|
||||
inline = false,
|
||||
collectionId,
|
||||
collectionName,
|
||||
doOpenModal,
|
||||
playNextUri,
|
||||
doSetPlayingUri,
|
||||
doToggleShuffleList,
|
||||
} = props;
|
||||
const { inline = false, collectionId, collectionName, doOpenModal, playNextUri, doToggleShuffleList } = props;
|
||||
const [doShuffle, setDoShuffle] = React.useState(false);
|
||||
|
||||
const { push } = useHistory();
|
||||
|
||||
React.useEffect(() => {
|
||||
if (playNextUri && doShuffle) {
|
||||
const collectionParams = new URLSearchParams();
|
||||
collectionParams.set(COLLECTIONS_CONSTS.COLLECTION_ID, collectionId);
|
||||
const navigateUrl = formatLbryUrlForWeb(playNextUri) + `?` + collectionParams.toString();
|
||||
setDoShuffle(false);
|
||||
doSetPlayingUri({ uri: playNextUri });
|
||||
push(navigateUrl);
|
||||
const navigateUrl = formatLbryUrlForWeb(playNextUri);
|
||||
push({
|
||||
pathname: navigateUrl,
|
||||
search: generateListSearchUrlParams(collectionId),
|
||||
state: { forceAutoplay: true },
|
||||
});
|
||||
}
|
||||
}, [push, doSetPlayingUri, collectionId, playNextUri, doShuffle]);
|
||||
}, [collectionId, doShuffle, playNextUri, push]);
|
||||
|
||||
return (
|
||||
<Menu>
|
||||
@@ -68,7 +59,7 @@ function CollectionMenuList(props: Props) {
|
||||
<MenuItem
|
||||
className="comment__menu-option"
|
||||
onSelect={() => {
|
||||
doToggleShuffleList('', collectionId, true, true);
|
||||
doToggleShuffleList(collectionId);
|
||||
setDoShuffle(true);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -7,8 +7,7 @@ import TruncatedText from 'component/common/truncated-text';
|
||||
import CollectionCount from './collectionCount';
|
||||
import CollectionPrivate from './collectionPrivate';
|
||||
import CollectionMenuList from 'component/collectionMenuList';
|
||||
import { formatLbryUrlForWeb } from 'util/url';
|
||||
import { COLLECTIONS_CONSTS } from 'lbry-redux';
|
||||
import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url';
|
||||
import FileThumbnail from 'component/fileThumbnail';
|
||||
|
||||
type Props = {
|
||||
@@ -62,16 +61,12 @@ function CollectionPreviewTile(props: Props) {
|
||||
if (collectionId && hasClaim && resolveCollectionItems) {
|
||||
resolveCollectionItems({ collectionId, page_size: 5 });
|
||||
}
|
||||
}, [collectionId, hasClaim]);
|
||||
}, [collectionId, hasClaim, resolveCollectionItems]);
|
||||
|
||||
// const signingChannel = claim && claim.signing_channel;
|
||||
|
||||
let navigateUrl = formatLbryUrlForWeb(collectionItemUrls[0] || '/');
|
||||
if (collectionId) {
|
||||
const collectionParams = new URLSearchParams();
|
||||
collectionParams.set(COLLECTIONS_CONSTS.COLLECTION_ID, collectionId);
|
||||
navigateUrl = navigateUrl + `?` + collectionParams.toString();
|
||||
}
|
||||
const navigateUrl =
|
||||
formatLbryUrlForWeb(collectionItemUrls[0] || '/') + (collectionId ? generateListSearchUrlParams(collectionId) : '');
|
||||
|
||||
function handleClick(e) {
|
||||
if (navigateUrl) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
selectMyPublishedPlaylistCollections,
|
||||
selectMyUnpublishedCollections, // should probably distinguish types
|
||||
// selectSavedCollections,
|
||||
selectFetchingMyCollections,
|
||||
} from 'lbry-redux';
|
||||
import CollectionsListMine from './view';
|
||||
|
||||
@@ -12,6 +13,7 @@ const select = (state) => ({
|
||||
publishedCollections: selectMyPublishedPlaylistCollections(state),
|
||||
unpublishedCollections: selectMyUnpublishedCollections(state),
|
||||
// savedCollections: selectSavedCollections(state),
|
||||
fetchingCollections: selectFetchingMyCollections(state),
|
||||
});
|
||||
|
||||
export default connect(select)(CollectionsListMine);
|
||||
@@ -7,6 +7,8 @@ import { COLLECTIONS_CONSTS } from 'lbry-redux';
|
||||
import Icon from 'component/common/icon';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
|
||||
import Yrbl from 'component/yrbl';
|
||||
import classnames from 'classnames';
|
||||
import { FormField, Form } from 'component/common/form';
|
||||
@@ -14,9 +16,9 @@ import { FormField, Form } from 'component/common/form';
|
||||
type Props = {
|
||||
builtinCollections: CollectionGroup,
|
||||
publishedCollections: CollectionGroup,
|
||||
publishedCollections: CollectionGroup,
|
||||
unpublishedCollections: CollectionGroup,
|
||||
// savedCollections: CollectionGroup,
|
||||
fetchingCollections: boolean,
|
||||
};
|
||||
|
||||
const ALL = 'All';
|
||||
@@ -30,6 +32,7 @@ export default function CollectionsListMine(props: Props) {
|
||||
publishedCollections,
|
||||
unpublishedCollections,
|
||||
// savedCollections, these are resolved on startup from sync'd claimIds or urls
|
||||
fetchingCollections,
|
||||
} = props;
|
||||
|
||||
const builtinCollectionsList = (Object.values(builtinCollections || {}): any);
|
||||
@@ -66,8 +69,7 @@ export default function CollectionsListMine(props: Props) {
|
||||
const favorites = builtinCollectionsList.find((list) => list.id === COLLECTIONS_CONSTS.FAVORITES_ID);
|
||||
const builtin = [watchLater, favorites];
|
||||
function escapeListener(e: SyntheticKeyboardEvent<*>) {
|
||||
const KEYCODE_ESCAPE = 27;
|
||||
if (e.keyCode === KEYCODE_ESCAPE) {
|
||||
if (e.keyCode === KEYCODES.ESCAPE) {
|
||||
e.preventDefault();
|
||||
setSearchText('');
|
||||
}
|
||||
@@ -129,7 +131,10 @@ export default function CollectionsListMine(props: Props) {
|
||||
<div className="claim-grid__header section">
|
||||
<h1 className="claim-grid__title">
|
||||
{__('Playlists')}
|
||||
{!hasCollections && (
|
||||
{!hasCollections && !fetchingCollections && (
|
||||
<div className="claim-grid__title--empty">{__('(Empty) --[indicates empty playlist]--')}</div>
|
||||
)}
|
||||
{!hasCollections && fetchingCollections && (
|
||||
<div className="claim-grid__title--empty">{__('(Empty) --[indicates empty playlist]--')}</div>
|
||||
)}
|
||||
</h1>
|
||||
@@ -174,11 +179,16 @@ export default function CollectionsListMine(props: Props) {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{!hasCollections && (
|
||||
{!hasCollections && !fetchingCollections && (
|
||||
<div className="main--empty">
|
||||
<Yrbl type={'sad'} title={__('You have no lists yet. Better start hoarding!')} />
|
||||
</div>
|
||||
)}
|
||||
{!hasCollections && fetchingCollections && (
|
||||
<div className="main--empty">
|
||||
<h2 className="main--empty empty">{__('Loading...')}</h2>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// @flow
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import { COMMENT_HIGHLIGHTED } from 'constants/classnames';
|
||||
import { SORT_BY, COMMENT_PAGE_SIZE_REPLIES } from 'constants/comment';
|
||||
import { FF_MAX_CHARS_IN_COMMENT } from 'constants/form-field';
|
||||
@@ -71,7 +72,6 @@ type Props = {
|
||||
};
|
||||
|
||||
const LENGTH_TO_COLLAPSE = 300;
|
||||
const ESCAPE_KEY = 27;
|
||||
|
||||
function Comment(props: Props) {
|
||||
const {
|
||||
@@ -157,7 +157,7 @@ function Comment(props: Props) {
|
||||
|
||||
// a user will try and press the escape key to cancel editing their comment
|
||||
const handleEscape = (event) => {
|
||||
if (event.keyCode === ESCAPE_KEY) {
|
||||
if (event.keyCode === KEYCODES.ESCAPE) {
|
||||
setEditing(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { ElementRef } from 'react';
|
||||
import { SIMPLE_SITE } from 'config';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import { FormField, Form } from 'component/common/form';
|
||||
@@ -157,8 +158,7 @@ export function CommentCreate(props: Props) {
|
||||
}
|
||||
|
||||
function altEnterListener(e: SyntheticKeyboardEvent<*>) {
|
||||
const KEYCODE_ENTER = 13;
|
||||
if ((livestream || e.ctrlKey || e.metaKey) && e.keyCode === KEYCODE_ENTER) {
|
||||
if ((livestream || e.ctrlKey || e.metaKey) && e.keyCode === KEYCODES.ENTER) {
|
||||
e.preventDefault();
|
||||
buttonRef.current.click();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { makeSelectChannelPermUrlForClaimUri, makeSelectClaimIsMine, makeSelectClaimForUri } from 'lbry-redux';
|
||||
import {
|
||||
doCommentPin,
|
||||
doCommentModBlock,
|
||||
doCommentModBlockAsAdmin,
|
||||
doCommentModBlockAsModerator,
|
||||
doCommentModAddDelegate,
|
||||
} from 'redux/actions/comments';
|
||||
import { doCommentPin, doCommentModAddDelegate } from 'redux/actions/comments';
|
||||
import { doChannelMute } from 'redux/actions/blocked';
|
||||
// import { doSetActiveChannel } from 'redux/actions/app';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
@@ -31,10 +25,6 @@ const perform = (dispatch) => ({
|
||||
muteChannel: (channelUri) => dispatch(doChannelMute(channelUri)),
|
||||
pinComment: (commentId, claimId, remove) => dispatch(doCommentPin(commentId, claimId, remove)),
|
||||
// setActiveChannel: channelId => dispatch(doSetActiveChannel(channelId)),
|
||||
commentModBlock: (commenterUri) => dispatch(doCommentModBlock(commenterUri)),
|
||||
commentModBlockAsAdmin: (commenterUri, blockerId) => dispatch(doCommentModBlockAsAdmin(commenterUri, blockerId)),
|
||||
commentModBlockAsModerator: (commenterUri, creatorId, blockerId) =>
|
||||
dispatch(doCommentModBlockAsModerator(commenterUri, creatorId, blockerId)),
|
||||
commentModAddDelegate: (modChanId, modChanName, creatorChannelClaim) =>
|
||||
dispatch(doCommentModAddDelegate(modChanId, modChanName, creatorChannelClaim, true)),
|
||||
});
|
||||
|
||||
@@ -6,8 +6,10 @@ import { MenuList, MenuItem } from '@reach/menu-button';
|
||||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
import Icon from 'component/common/icon';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
import { getChannelFromClaim } from 'util/claim';
|
||||
|
||||
type Props = {
|
||||
uri: ?string,
|
||||
authorUri: string, // full LBRY Channel URI: lbry://@channel#123...
|
||||
commentId: string, // sha256 digest identifying the comment
|
||||
isTopLevel: boolean,
|
||||
@@ -29,15 +31,13 @@ type Props = {
|
||||
clearPlayingUri: () => void,
|
||||
muteChannel: (string) => void,
|
||||
pinComment: (string, string, boolean) => Promise<any>,
|
||||
commentModBlock: (string) => void,
|
||||
commentModBlockAsAdmin: (string, string) => void,
|
||||
commentModBlockAsModerator: (string, string, string) => void,
|
||||
commentModAddDelegate: (string, string, ChannelClaim) => void,
|
||||
setQuickReply: (any) => void,
|
||||
};
|
||||
|
||||
function CommentMenuList(props: Props) {
|
||||
const {
|
||||
uri,
|
||||
claim,
|
||||
authorUri,
|
||||
commentIsMine,
|
||||
@@ -50,27 +50,17 @@ function CommentMenuList(props: Props) {
|
||||
isTopLevel,
|
||||
isPinned,
|
||||
handleEditComment,
|
||||
commentModBlock,
|
||||
commentModBlockAsAdmin,
|
||||
commentModBlockAsModerator,
|
||||
commentModAddDelegate,
|
||||
playingUri,
|
||||
moderationDelegatorsById,
|
||||
disableEdit,
|
||||
disableRemove,
|
||||
moderationDelegatorsById,
|
||||
openModal,
|
||||
supportAmount,
|
||||
setQuickReply,
|
||||
} = props;
|
||||
|
||||
const contentChannelClaim = !claim
|
||||
? null
|
||||
: claim.value_type === 'channel'
|
||||
? claim
|
||||
: claim.signing_channel && claim.is_channel_signature_valid
|
||||
? claim.signing_channel
|
||||
: null;
|
||||
|
||||
const contentChannelClaim = getChannelFromClaim(claim);
|
||||
const activeModeratorInfo = activeChannelClaim && moderationDelegatorsById[activeChannelClaim.claim_id];
|
||||
const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl;
|
||||
const activeChannelIsAdmin = activeChannelClaim && activeModeratorInfo && activeModeratorInfo.global;
|
||||
@@ -98,7 +88,7 @@ function CommentMenuList(props: Props) {
|
||||
}
|
||||
|
||||
function handleCommentBlock() {
|
||||
commentModBlock(authorUri);
|
||||
openModal(MODALS.BLOCK_CHANNEL, { contentUri: uri, commenterUri: authorUri });
|
||||
}
|
||||
|
||||
function handleCommentMute() {
|
||||
@@ -112,16 +102,57 @@ function CommentMenuList(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
function blockCommentAsModerator() {
|
||||
if (activeChannelClaim && contentChannelClaim) {
|
||||
commentModBlockAsModerator(authorUri, contentChannelClaim.claim_id, activeChannelClaim.claim_id);
|
||||
}
|
||||
}
|
||||
function getBlockOptionElem() {
|
||||
const isPersonalBlockTheOnlyOption = !activeChannelIsModerator && !activeChannelIsAdmin;
|
||||
const isTimeoutBlockAvailable = (claim && claim.is_my_output) || activeChannelIsModerator;
|
||||
const personalPermanentBlockOnly = isPersonalBlockTheOnlyOption && !isTimeoutBlockAvailable;
|
||||
|
||||
function blockCommentAsAdmin() {
|
||||
if (activeChannelClaim) {
|
||||
commentModBlockAsAdmin(authorUri, activeChannelClaim.claim_id);
|
||||
function getSubtitle() {
|
||||
if (personalPermanentBlockOnly) {
|
||||
return {
|
||||
line1: __('Prevent this channel from interacting with you.'),
|
||||
line2: null,
|
||||
};
|
||||
} else {
|
||||
if (activeChannelIsModerator && activeChannelIsAdmin) {
|
||||
return {
|
||||
line1: __('Personal | Moderator | Admin'),
|
||||
line2: __('Choose a permanent or temporary ban.'),
|
||||
};
|
||||
} else if (activeChannelIsModerator && !activeChannelIsAdmin) {
|
||||
return {
|
||||
line1: __('Personal | Moderator'),
|
||||
line2: __('Choose a permanent or temporary ban.'),
|
||||
};
|
||||
} else if (!activeChannelIsModerator && activeChannelIsAdmin) {
|
||||
return {
|
||||
line1: __('Personal | Admin'),
|
||||
line2: __('Choose a permanent or temporary ban.'),
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
line1: null,
|
||||
line2: __('Choose a permanent or temporary ban.'),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const subtitle = getSubtitle();
|
||||
return (
|
||||
<>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.BLOCK} />
|
||||
{__('Block')}
|
||||
</div>
|
||||
{subtitle.line1 && <span className="comment__menu-help">{subtitle.line1}</span>}
|
||||
{subtitle.line2 && (
|
||||
<span className="comment__menu-help">
|
||||
{subtitle.line2} {!personalPermanentBlockOnly && <Icon aria-hidden icon={ICONS.EXTERNAL} />}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -175,13 +206,7 @@ function CommentMenuList(props: Props) {
|
||||
|
||||
{!commentIsMine && (
|
||||
<MenuItem className="comment__menu-option" onSelect={handleCommentBlock}>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.BLOCK} />
|
||||
{__('Block')}
|
||||
</div>
|
||||
{activeChannelIsCreator && (
|
||||
<span className="comment__menu-help">{__('Prevent this channel from interacting with you.')}</span>
|
||||
)}
|
||||
{getBlockOptionElem()}
|
||||
</MenuItem>
|
||||
)}
|
||||
|
||||
@@ -197,34 +222,6 @@ function CommentMenuList(props: Props) {
|
||||
</MenuItem>
|
||||
)}
|
||||
|
||||
{!commentIsMine && (activeChannelIsAdmin || activeChannelIsModerator) && (
|
||||
<div className="comment__menu-title">{__('Moderator tools')}</div>
|
||||
)}
|
||||
|
||||
{!commentIsMine && activeChannelIsAdmin && (
|
||||
<MenuItem className="comment__menu-option" onSelect={blockCommentAsAdmin}>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.GLOBE} />
|
||||
{__('Global Block')}
|
||||
</div>
|
||||
<span className="comment__menu-help">{__('Block this channel as global admin')}</span>
|
||||
</MenuItem>
|
||||
)}
|
||||
|
||||
{!commentIsMine && activeChannelIsModerator && (
|
||||
<MenuItem className="comment__menu-option" onSelect={blockCommentAsModerator}>
|
||||
<div className="menu__link">
|
||||
<Icon aria-hidden icon={ICONS.BLOCK} />
|
||||
{__('Moderator Block')}
|
||||
</div>
|
||||
<span className="comment__menu-help">
|
||||
{__('Block this channel on behalf of %creator%', {
|
||||
creator: contentChannelClaim ? contentChannelClaim.name : __('creator'),
|
||||
})}
|
||||
</span>
|
||||
</MenuItem>
|
||||
)}
|
||||
|
||||
{activeChannelClaim && (
|
||||
<div className="comment__menu-active">
|
||||
<ChannelThumbnail xsmall noLazyLoad uri={activeChannelClaim.permanent_url} />
|
||||
|
||||
@@ -14,7 +14,7 @@ import usePersistedState from 'effects/use-persisted-state';
|
||||
import { ENABLE_COMMENT_REACTIONS } from 'config';
|
||||
import Empty from 'component/common/empty';
|
||||
import debounce from 'util/debounce';
|
||||
import { useIsMobile } from 'effects/use-screensize';
|
||||
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
|
||||
import { getChannelIdFromClaim } from 'util/claim';
|
||||
|
||||
const DEBOUNCE_SCROLL_HANDLER_MS = 200;
|
||||
@@ -87,7 +87,8 @@ function CommentList(props: Props) {
|
||||
linkedCommentId ? 0 : MAX_LINKED_COMMENT_SCROLL_ATTEMPTS
|
||||
);
|
||||
const isMobile = useIsMobile();
|
||||
const [expandedComments, setExpandedComments] = React.useState(!isMobile);
|
||||
const isMediumScreen = useIsMediumScreen();
|
||||
const [expandedComments, setExpandedComments] = React.useState(!isMobile && !isMediumScreen);
|
||||
const totalFetchedComments = allCommentIds ? allCommentIds.length : 0;
|
||||
const channelId = getChannelIdFromClaim(claim);
|
||||
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
|
||||
@@ -243,7 +244,7 @@ function CommentList(props: Props) {
|
||||
}
|
||||
|
||||
const handleCommentScroll = debounce(() => {
|
||||
if (!isMobile && shouldFetchNextPage(page, topLevelTotalPages, window, document)) {
|
||||
if (!isMobile && !isMediumScreen && shouldFetchNextPage(page, topLevelTotalPages, window, document)) {
|
||||
setPage(page + 1);
|
||||
}
|
||||
}, DEBOUNCE_SCROLL_HANDLER_MS);
|
||||
@@ -258,6 +259,7 @@ function CommentList(props: Props) {
|
||||
}
|
||||
}, [
|
||||
isMobile,
|
||||
isMediumScreen,
|
||||
page,
|
||||
moreBelow,
|
||||
spinnerRef,
|
||||
@@ -267,6 +269,13 @@ function CommentList(props: Props) {
|
||||
topLevelTotalPages,
|
||||
]);
|
||||
|
||||
// Expand comments
|
||||
useEffect(() => {
|
||||
if (!isMobile && !isMediumScreen && !expandedComments) {
|
||||
setExpandedComments(true);
|
||||
}
|
||||
}, [isMobile, isMediumScreen, expandedComments]);
|
||||
|
||||
return (
|
||||
<Card
|
||||
title={
|
||||
@@ -340,7 +349,7 @@ function CommentList(props: Props) {
|
||||
{readyToDisplayComments && topLevelComments && getCommentElems(topLevelComments)}
|
||||
</ul>
|
||||
|
||||
{isMobile && (
|
||||
{(isMobile || isMediumScreen) && (
|
||||
<div className="card__bottom-actions--comments">
|
||||
{(!expandedComments || moreBelow) && (
|
||||
<Button
|
||||
@@ -369,7 +378,7 @@ function CommentList(props: Props) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(isFetchingComments || (!isMobile && moreBelow)) && (
|
||||
{(isFetchingComments || (!isMobile && !isMediumScreen && moreBelow)) && (
|
||||
<div className="main--empty" ref={spinnerRef}>
|
||||
<Spinner type="small" />
|
||||
</div>
|
||||
|
||||
@@ -2440,6 +2440,12 @@ export const icons = {
|
||||
</svg>
|
||||
),
|
||||
[ICONS.PLAY]: buildIcon(<polygon points="5 3 19 12 5 21 5 3" />),
|
||||
[ICONS.PLAY_PREVIOUS]: buildIcon(
|
||||
<g>
|
||||
<polygon points="19 20 9 12 19 4 19 20" />
|
||||
<line x1="5" y1="19" x2="5" y2="5" />
|
||||
</g>
|
||||
),
|
||||
[ICONS.REPLAY]: buildIcon(
|
||||
<g>
|
||||
<polyline points="1 4 1 10 7 10" />
|
||||
|
||||
@@ -10,16 +10,18 @@ const PAGINATE_PARAM = 'page';
|
||||
type Props = {
|
||||
totalPages: number,
|
||||
location: { search: string },
|
||||
history: { push: string => void },
|
||||
onPageChange?: number => void,
|
||||
history: { push: (string) => void },
|
||||
onPageChange?: (number) => void,
|
||||
disableHistory?: boolean, // Disables the use of '&page=' param and history stack.
|
||||
};
|
||||
|
||||
function Paginate(props: Props) {
|
||||
const { totalPages = 1, location, history, onPageChange } = props;
|
||||
const { totalPages = 1, location, history, onPageChange, disableHistory } = props;
|
||||
const { search } = location;
|
||||
const [textValue, setTextValue] = React.useState('');
|
||||
const urlParams = new URLSearchParams(search);
|
||||
const currentPage = Number(urlParams.get(PAGINATE_PARAM)) || 1;
|
||||
const initialPage = disableHistory ? 1 : Number(urlParams.get(PAGINATE_PARAM)) || 1;
|
||||
const [currentPage, setCurrentPage] = React.useState(initialPage);
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
function handleChangePage(newPageNumber: number) {
|
||||
@@ -28,9 +30,13 @@ function Paginate(props: Props) {
|
||||
}
|
||||
|
||||
if (currentPage !== newPageNumber) {
|
||||
const params = new URLSearchParams(search);
|
||||
params.set(PAGINATE_PARAM, newPageNumber.toString());
|
||||
history.push('?' + params.toString());
|
||||
setCurrentPage(newPageNumber);
|
||||
|
||||
if (!disableHistory) {
|
||||
const params = new URLSearchParams(search);
|
||||
params.set(PAGINATE_PARAM, newPageNumber.toString());
|
||||
history.push('?' + params.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +64,7 @@ function Paginate(props: Props) {
|
||||
nextClassName="pagination__item pagination__item--next"
|
||||
breakClassName="pagination__item pagination__item--break"
|
||||
marginPagesDisplayed={2}
|
||||
onPageChange={e => handleChangePage(e.selected + 1)}
|
||||
onPageChange={(e) => handleChangePage(e.selected + 1)}
|
||||
forcePage={currentPage - 1}
|
||||
initialPage={currentPage - 1}
|
||||
containerClassName="pagination"
|
||||
@@ -67,7 +73,7 @@ function Paginate(props: Props) {
|
||||
{!isMobile && (
|
||||
<FormField
|
||||
value={textValue}
|
||||
onChange={e => setTextValue(e.target.value)}
|
||||
onChange={(e) => setTextValue(e.target.value)}
|
||||
className="paginate-channel"
|
||||
label={__('Go to page:')}
|
||||
type="text"
|
||||
|
||||
@@ -12,12 +12,12 @@ type Props = {
|
||||
uri: string,
|
||||
thumbnail: string,
|
||||
claim: ?Claim,
|
||||
doResolveUri: string => void,
|
||||
doFetchCostInfoForUri: string => void,
|
||||
doResolveUri: (string) => void,
|
||||
doFetchCostInfoForUri: (string) => void,
|
||||
costInfo: ?{ cost: number },
|
||||
floatingPlayerEnabled: boolean,
|
||||
doPlayUri: (string, ?boolean, ?boolean, (GetResponse) => void) => void,
|
||||
doAnaltyicsPurchaseEvent: GetResponse => void,
|
||||
doAnaltyicsPurchaseEvent: (GetResponse) => void,
|
||||
parentCommentId?: string,
|
||||
isMarkdownPost: boolean,
|
||||
doSetPlayingUri: ({}) => void,
|
||||
@@ -69,8 +69,8 @@ export default function EmbedPlayButton(props: Props) {
|
||||
const formattedUrl = formatLbryUrlForWeb(uri);
|
||||
push(formattedUrl);
|
||||
} else {
|
||||
doPlayUri(uri, undefined, undefined, fileInfo => {
|
||||
let playingOptions: PlayingUri = { uri, pathname };
|
||||
doPlayUri(uri, undefined, undefined, (fileInfo) => {
|
||||
let playingOptions = { uri, pathname, source: undefined, commentId: undefined };
|
||||
if (parentCommentId) {
|
||||
playingOptions.source = 'comment';
|
||||
playingOptions.commentId = parentCommentId;
|
||||
|
||||
@@ -99,6 +99,7 @@ function FileActions(props: Props) {
|
||||
React.useEffect(() => {
|
||||
if (downloadClicked && streamingUrl) {
|
||||
webDownloadClaim(streamingUrl, fileName);
|
||||
setDownloadClicked(false);
|
||||
}
|
||||
}, [downloadClicked, streamingUrl, fileName]);
|
||||
// @endif
|
||||
|
||||
@@ -4,6 +4,7 @@ import React from 'react';
|
||||
import { lazyImport } from 'util/lazyImport';
|
||||
import classnames from 'classnames';
|
||||
import * as RENDER_MODES from 'constants/file_render_modes';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import VideoViewer from 'component/viewers/videoViewer';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import fs from 'fs';
|
||||
@@ -57,7 +58,7 @@ class FileRender extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
escapeListener(e: SyntheticKeyboardEvent<*>) {
|
||||
if (e.keyCode === 27) {
|
||||
if (e.keyCode === KEYCODES.ESCAPE) {
|
||||
e.preventDefault();
|
||||
|
||||
this.exitFullscreen();
|
||||
|
||||
@@ -4,6 +4,9 @@ import {
|
||||
makeSelectTitleForUri,
|
||||
makeSelectStreamingUrlForUri,
|
||||
makeSelectClaimIsNsfw,
|
||||
makeSelectClaimWasPurchased,
|
||||
makeSelectNextUrlForCollectionAndUrl,
|
||||
makeSelectPreviousUrlForCollectionAndUrl,
|
||||
SETTINGS,
|
||||
} from 'lbry-redux';
|
||||
import {
|
||||
@@ -13,8 +16,10 @@ import {
|
||||
makeSelectFileRenderModeForUri,
|
||||
} from 'redux/selectors/content';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { makeSelectCostInfoForUri } from 'lbryinc';
|
||||
import { doPlayUri, doSetPlayingUri } from 'redux/actions/content';
|
||||
import { doFetchRecommendedContent } from 'redux/actions/search';
|
||||
import { doAnaltyicsPurchaseEvent } from 'redux/actions/app';
|
||||
import { withRouter } from 'react-router';
|
||||
import FileRenderFloating from './view';
|
||||
|
||||
@@ -30,12 +35,16 @@ const select = (state, props) => {
|
||||
playingUri,
|
||||
title: makeSelectTitleForUri(uri)(state),
|
||||
fileInfo: makeSelectFileInfoForUri(uri)(state),
|
||||
mature: makeSelectClaimIsNsfw(props.uri)(state),
|
||||
mature: makeSelectClaimIsNsfw(uri)(state),
|
||||
isFloating: makeSelectIsPlayerFloating(props.location)(state),
|
||||
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
|
||||
floatingPlayerEnabled: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
|
||||
renderMode: makeSelectFileRenderModeForUri(uri)(state),
|
||||
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
|
||||
costInfo: makeSelectCostInfoForUri(uri)(state),
|
||||
claimWasPurchased: makeSelectClaimWasPurchased(uri)(state),
|
||||
nextListUri: collectionId && makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state),
|
||||
previousListUri: collectionId && makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state),
|
||||
collectionId,
|
||||
};
|
||||
};
|
||||
@@ -43,6 +52,19 @@ const select = (state, props) => {
|
||||
const perform = (dispatch) => ({
|
||||
closeFloatingPlayer: () => dispatch(doSetPlayingUri({ uri: null })),
|
||||
doFetchRecommendedContent: (uri, mature) => dispatch(doFetchRecommendedContent(uri, mature)),
|
||||
doPlayUri: (uri, collectionId, hideFailModal) =>
|
||||
dispatch(
|
||||
doPlayUri(
|
||||
uri,
|
||||
false,
|
||||
false,
|
||||
(fileInfo) => {
|
||||
dispatch(doAnaltyicsPurchaseEvent(fileInfo));
|
||||
},
|
||||
hideFailModal
|
||||
),
|
||||
dispatch(doSetPlayingUri({ uri, collectionId }))
|
||||
),
|
||||
});
|
||||
|
||||
export default withRouter(connect(select, perform)(FileRenderFloating));
|
||||
@@ -11,10 +11,12 @@ import usePersistedState from 'effects/use-persisted-state';
|
||||
import { PRIMARY_PLAYER_WRAPPER_CLASS } from 'page/file/view';
|
||||
import Draggable from 'react-draggable';
|
||||
import { onFullscreenChange } from 'util/full-screen';
|
||||
import { generateListSearchUrlParams, formatLbryUrlForWeb } from 'util/url';
|
||||
import { useIsMobile } from 'effects/use-screensize';
|
||||
import debounce from 'util/debounce';
|
||||
import { useHistory } from 'react-router';
|
||||
import { isURIEqual, COLLECTIONS_CONSTS } from 'lbry-redux';
|
||||
import { isURIEqual } from 'lbry-redux';
|
||||
import AutoplayCountdown from 'component/autoplayCountdown';
|
||||
|
||||
const IS_DESKTOP_MAC = typeof process === 'object' ? process.platform === 'darwin' : false;
|
||||
const DEBOUNCE_WINDOW_RESIZE_HANDLER_MS = 60;
|
||||
@@ -34,7 +36,12 @@ type Props = {
|
||||
primaryUri: ?string,
|
||||
videoTheaterMode: boolean,
|
||||
doFetchRecommendedContent: (string, boolean) => void,
|
||||
doPlayUri: (string, string, boolean) => void,
|
||||
collectionId: string,
|
||||
costInfo: any,
|
||||
claimWasPurchased: boolean,
|
||||
nextListUri: string,
|
||||
previousListUri: string,
|
||||
};
|
||||
|
||||
export default function FileRenderFloating(props: Props) {
|
||||
@@ -52,16 +59,23 @@ export default function FileRenderFloating(props: Props) {
|
||||
primaryUri,
|
||||
videoTheaterMode,
|
||||
doFetchRecommendedContent,
|
||||
doPlayUri,
|
||||
collectionId,
|
||||
costInfo,
|
||||
claimWasPurchased,
|
||||
nextListUri,
|
||||
previousListUri,
|
||||
} = props;
|
||||
const {
|
||||
location: { pathname },
|
||||
} = useHistory();
|
||||
const { location, push } = useHistory();
|
||||
const hideFloatingPlayer = location.state && location.state.hideFloatingPlayer;
|
||||
const isMobile = useIsMobile();
|
||||
const mainFilePlaying = playingUri && isURIEqual(playingUri.uri, primaryUri);
|
||||
const mainFilePlaying = !isFloating && isURIEqual(uri, primaryUri);
|
||||
const [fileViewerRect, setFileViewerRect] = useState();
|
||||
const [desktopPlayStartTime, setDesktopPlayStartTime] = useState();
|
||||
const [wasDragging, setWasDragging] = useState(false);
|
||||
const [doNavigate, setDoNavigate] = useState(false);
|
||||
const [playNextUrl, setPlayNextUrl] = useState(true);
|
||||
const [countdownCanceled, setCountdownCanceled] = useState(false);
|
||||
const [position, setPosition] = usePersistedState('floating-file-viewer:position', {
|
||||
x: -25,
|
||||
y: window.innerHeight - 400,
|
||||
@@ -71,13 +85,11 @@ export default function FileRenderFloating(props: Props) {
|
||||
y: 0,
|
||||
});
|
||||
|
||||
let navigateUrl;
|
||||
if (collectionId) {
|
||||
const collectionParams = new URLSearchParams();
|
||||
collectionParams.set(COLLECTIONS_CONSTS.COLLECTION_ID, collectionId);
|
||||
navigateUrl = uri + `?` + collectionParams.toString();
|
||||
}
|
||||
const navigateUrl =
|
||||
playingUri && playingUri.primaryUri + (collectionId ? generateListSearchUrlParams(collectionId) : '');
|
||||
|
||||
const isFree = costInfo && costInfo.cost === 0;
|
||||
const canViewFile = isFree || claimWasPurchased;
|
||||
const playingUriSource = playingUri && playingUri.source;
|
||||
const isPlayable = RENDER_MODES.FLOATING_MODES.includes(renderMode);
|
||||
const isReadyToPlay = isPlayable && (streamingUrl || (fileInfo && fileInfo.completed));
|
||||
@@ -102,7 +114,7 @@ export default function FileRenderFloating(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
function clampToScreen(pos) {
|
||||
const clampToScreen = React.useCallback((pos) => {
|
||||
const ESTIMATED_SCROLL_BAR_PX = 50;
|
||||
const FLOATING_PLAYER_CLASS = 'content__viewer--floating';
|
||||
const fpPlayerElem = document.querySelector(`.${FLOATING_PLAYER_CLASS}`);
|
||||
@@ -115,7 +127,7 @@ export default function FileRenderFloating(props: Props) {
|
||||
pos.y = getScreenHeight() - fpPlayerElem.getBoundingClientRect().height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Updated 'relativePos' based on persisted 'position':
|
||||
const stringifiedPosition = JSON.stringify(position);
|
||||
@@ -139,11 +151,11 @@ export default function FileRenderFloating(props: Props) {
|
||||
setPosition({ x: pos.x, y: pos.y });
|
||||
}
|
||||
}
|
||||
}, [isFloating, stringifiedPosition]);
|
||||
}, [clampToScreen, isFloating, position.x, position.y, setPosition, stringifiedPosition]);
|
||||
|
||||
// Listen to main-window resizing and adjust the fp position accordingly:
|
||||
useEffect(() => {
|
||||
const handleMainWindowResize = debounce((e) => {
|
||||
const handleMainWindowResize = debounce(() => {
|
||||
let newPos = {
|
||||
x: Math.round(relativePos.x * getScreenWidth()),
|
||||
y: Math.round(relativePos.y * getScreenHeight()),
|
||||
@@ -157,20 +169,18 @@ export default function FileRenderFloating(props: Props) {
|
||||
|
||||
// 'relativePos' is needed in the dependency list to avoid stale closure.
|
||||
// Otherwise, this could just be changed to a one-time effect.
|
||||
}, [relativePos]);
|
||||
}, [clampToScreen, relativePos.x, relativePos.y, setPosition]);
|
||||
|
||||
function handleResize() {
|
||||
const handleResize = React.useCallback(() => {
|
||||
const element = mainFilePlaying
|
||||
? document.querySelector(`.${PRIMARY_PLAYER_WRAPPER_CLASS}`)
|
||||
: document.querySelector(`.${INLINE_PLAYER_WRAPPER_CLASS}`);
|
||||
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
if (!element) return;
|
||||
|
||||
const rect = element.getBoundingClientRect();
|
||||
|
||||
// getBoundingCLientRect returns a DomRect, not an object
|
||||
// getBoundingClientRect returns a DomRect, not an object
|
||||
const objectRect = {
|
||||
top: rect.top,
|
||||
right: rect.right,
|
||||
@@ -184,13 +194,14 @@ export default function FileRenderFloating(props: Props) {
|
||||
|
||||
// $FlowFixMe
|
||||
setFileViewerRect({ ...objectRect, windowOffset: window.pageYOffset });
|
||||
}
|
||||
}, [mainFilePlaying]);
|
||||
|
||||
useEffect(() => {
|
||||
if (streamingUrl) {
|
||||
if (playingUri && playingUri.primaryUri) {
|
||||
handleResize();
|
||||
setCountdownCanceled(false);
|
||||
}
|
||||
}, [streamingUrl, pathname, playingUriSource, isFloating, mainFilePlaying]);
|
||||
}, [handleResize, playingUri, videoTheaterMode]);
|
||||
|
||||
useEffect(() => {
|
||||
handleResize();
|
||||
@@ -201,7 +212,7 @@ export default function FileRenderFloating(props: Props) {
|
||||
window.removeEventListener('resize', handleResize);
|
||||
onFullscreenChange(window, 'remove', handleResize);
|
||||
};
|
||||
}, [setFileViewerRect, isFloating, playingUriSource, mainFilePlaying, videoTheaterMode]);
|
||||
}, [handleResize]);
|
||||
|
||||
useEffect(() => {
|
||||
// @if TARGET='app'
|
||||
@@ -219,13 +230,46 @@ export default function FileRenderFloating(props: Props) {
|
||||
if (isFloating) {
|
||||
doFetchRecommendedContent(uri, mature);
|
||||
}
|
||||
}, [uri, mature, isFloating]);
|
||||
}, [doFetchRecommendedContent, isFloating, mature, uri]);
|
||||
|
||||
if (!isPlayable || !uri || (isFloating && (isMobile || !floatingPlayerEnabled))) {
|
||||
const doPlay = React.useCallback(
|
||||
(playUri) => {
|
||||
setDoNavigate(false);
|
||||
if (!isFloating) {
|
||||
const navigateUrl = formatLbryUrlForWeb(playUri);
|
||||
push({
|
||||
pathname: navigateUrl,
|
||||
search: collectionId && generateListSearchUrlParams(collectionId),
|
||||
state: { collectionId, forceAutoplay: true, hideFloatingPlayer: true },
|
||||
});
|
||||
} else {
|
||||
doPlayUri(playUri, collectionId, true);
|
||||
}
|
||||
},
|
||||
[collectionId, doPlayUri, isFloating, push]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!doNavigate) return;
|
||||
|
||||
if (playNextUrl && nextListUri) {
|
||||
doPlay(nextListUri);
|
||||
} else if (previousListUri) {
|
||||
doPlay(previousListUri);
|
||||
}
|
||||
setPlayNextUrl(true);
|
||||
}, [doNavigate, doPlay, nextListUri, playNextUrl, previousListUri]);
|
||||
|
||||
if (
|
||||
!isPlayable ||
|
||||
!uri ||
|
||||
(isFloating && (isMobile || !floatingPlayerEnabled || hideFloatingPlayer)) ||
|
||||
(collectionId && !isFloating && ((!canViewFile && !nextListUri) || countdownCanceled))
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function handleDragStart(e, ui) {
|
||||
function handleDragStart() {
|
||||
// Not really necessary, but reset just in case 'handleStop' didn't fire.
|
||||
setWasDragging(false);
|
||||
}
|
||||
@@ -241,7 +285,7 @@ export default function FileRenderFloating(props: Props) {
|
||||
});
|
||||
}
|
||||
|
||||
function handleDragStop(e, ui) {
|
||||
function handleDragStop(e) {
|
||||
if (wasDragging) {
|
||||
e.stopPropagation();
|
||||
setWasDragging(false);
|
||||
@@ -307,17 +351,30 @@ export default function FileRenderFloating(props: Props) {
|
||||
// @endif
|
||||
/>
|
||||
) : (
|
||||
<LoadingScreen status={loadingMessage} />
|
||||
<>
|
||||
{collectionId && !canViewFile ? (
|
||||
<div className="content__loading">
|
||||
<AutoplayCountdown
|
||||
nextRecommendedUri={nextListUri}
|
||||
doNavigate={() => setDoNavigate(true)}
|
||||
doReplay={() => doPlayUri(uri, collectionId, false)}
|
||||
doPrevious={() => {
|
||||
setPlayNextUrl(false);
|
||||
setDoNavigate(true);
|
||||
}}
|
||||
onCanceled={() => setCountdownCanceled(true)}
|
||||
skipPaid
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<LoadingScreen status={loadingMessage} />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{isFloating && (
|
||||
<div className="draggable content__info">
|
||||
<div className="claim-preview__title" title={title || uri}>
|
||||
<Button
|
||||
label={title || uri}
|
||||
navigate={navigateUrl || uri}
|
||||
button="link"
|
||||
className="content__floating-link"
|
||||
/>
|
||||
<Button label={title || uri} navigate={navigateUrl} button="link" className="content__floating-link" />
|
||||
</div>
|
||||
<UriIndicator link uri={uri} />
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectStreamingUrlForUri,
|
||||
makeSelectClaimWasPurchased,
|
||||
SETTINGS,
|
||||
COLLECTIONS_CONSTS,
|
||||
@@ -16,7 +15,6 @@ import { withRouter } from 'react-router';
|
||||
import {
|
||||
makeSelectIsPlaying,
|
||||
makeSelectShouldObscurePreview,
|
||||
selectPlayingUri,
|
||||
makeSelectInsufficientCreditsForUri,
|
||||
makeSelectFileRenderModeForUri,
|
||||
} from 'redux/selectors/content';
|
||||
@@ -33,11 +31,8 @@ const select = (state, props) => {
|
||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||
obscurePreview: makeSelectShouldObscurePreview(props.uri)(state),
|
||||
isPlaying: makeSelectIsPlaying(props.uri)(state),
|
||||
playingUri: selectPlayingUri(state),
|
||||
insufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
|
||||
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
||||
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY_MEDIA)(state),
|
||||
hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)),
|
||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
@@ -48,9 +43,9 @@ const select = (state, props) => {
|
||||
};
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
play: (uri, collectionId) => {
|
||||
play: (uri, collectionId, isPlayable) => {
|
||||
dispatch(doSetPrimaryUri(uri));
|
||||
dispatch(doSetPlayingUri({ uri, collectionId }));
|
||||
if (isPlayable) dispatch(doSetPlayingUri({ uri, collectionId }));
|
||||
dispatch(doPlayUri(uri, undefined, undefined, (fileInfo) => dispatch(doAnaltyicsPurchaseEvent(fileInfo))));
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import React, { useEffect, useCallback } from 'react';
|
||||
import classnames from 'classnames';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import * as RENDER_MODES from 'constants/file_render_modes';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import Button from 'component/button';
|
||||
import isUserTyping from 'util/detect-typing';
|
||||
import { getThumbnailCdnUrl } from 'util/thumbnail';
|
||||
@@ -14,21 +15,17 @@ import Nag from 'component/common/nag';
|
||||
// $FlowFixMe cannot resolve ...
|
||||
import FileRenderPlaceholder from 'static/img/fileRenderPlaceholder.png';
|
||||
|
||||
const SPACE_BAR_KEYCODE = 32;
|
||||
|
||||
type Props = {
|
||||
play: (string, string) => void,
|
||||
isLoading: boolean,
|
||||
play: (string, string, boolean) => void,
|
||||
isPlaying: boolean,
|
||||
fileInfo: FileListItem,
|
||||
uri: string,
|
||||
history: { push: (string) => void },
|
||||
location: { search: ?string, pathname: string },
|
||||
location: { search: ?string, pathname: string, href: string, state: { forceAutoplay: boolean } },
|
||||
obscurePreview: boolean,
|
||||
insufficientCredits: boolean,
|
||||
claimThumbnail?: string,
|
||||
autoplay: boolean,
|
||||
hasCostInfo: boolean,
|
||||
costInfo: any,
|
||||
inline: boolean,
|
||||
renderMode: string,
|
||||
@@ -51,7 +48,6 @@ export default function FileRenderInitiator(props: Props) {
|
||||
location,
|
||||
claimThumbnail,
|
||||
renderMode,
|
||||
hasCostInfo,
|
||||
costInfo,
|
||||
claimWasPurchased,
|
||||
authenticated,
|
||||
@@ -59,24 +55,20 @@ export default function FileRenderInitiator(props: Props) {
|
||||
collectionId,
|
||||
} = props;
|
||||
|
||||
// force autoplay if a timestamp is present
|
||||
let autoplay = props.autoplay;
|
||||
// get current url
|
||||
const url = window.location.href;
|
||||
// check if there is a time parameter, if so force autoplay
|
||||
if (url.indexOf('t=') > -1) {
|
||||
autoplay = true;
|
||||
}
|
||||
// check if there is a time or autoplay parameter, if so force autoplay
|
||||
const urlTimeParam = location && location.href && location.href.indexOf('t=') > -1;
|
||||
const forceAutoplayParam = location && location.state && location.state.forceAutoplay;
|
||||
const autoplay = forceAutoplayParam || urlTimeParam || props.autoplay;
|
||||
|
||||
const cost = costInfo && costInfo.cost;
|
||||
const isFree = hasCostInfo && cost === 0;
|
||||
const isFree = costInfo && costInfo.cost === 0;
|
||||
const canViewFile = isFree || claimWasPurchased;
|
||||
const fileStatus = fileInfo && fileInfo.status;
|
||||
const isPlayable = RENDER_MODES.FLOATING_MODES.includes(renderMode);
|
||||
const isText = RENDER_MODES.TEXT_MODES.includes(renderMode);
|
||||
const [thumbnail, setThumbnail] = React.useState(FileRenderPlaceholder);
|
||||
const containerRef = React.useRef<any>();
|
||||
|
||||
React.useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (claimThumbnail) {
|
||||
setTimeout(() => {
|
||||
let newThumbnail = claimThumbnail;
|
||||
@@ -97,7 +89,7 @@ export default function FileRenderInitiator(props: Props) {
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}, [claimThumbnail]);
|
||||
}, [claimThumbnail, thumbnail]);
|
||||
|
||||
function doAuthRedirect() {
|
||||
history.push(`/$/${PAGES.AUTH}?redirect=${encodeURIComponent(location.pathname)}`);
|
||||
@@ -111,16 +103,16 @@ export default function FileRenderInitiator(props: Props) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
play(uri, collectionId);
|
||||
play(uri, collectionId, isPlayable);
|
||||
},
|
||||
[play, uri, collectionId]
|
||||
[play, uri, isPlayable, collectionId]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// This is just for beginning to download a file
|
||||
// Play/Pause/Fullscreen will be handled by the respective viewers because not every file type should behave the same
|
||||
function handleKeyDown(e: KeyboardEvent) {
|
||||
if (!isUserTyping() && e.keyCode === SPACE_BAR_KEYCODE) {
|
||||
if (!isUserTyping() && e.keyCode === KEYCODES.SPACEBAR) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!isPlaying || fileStatus === 'stopped') {
|
||||
@@ -138,19 +130,20 @@ export default function FileRenderInitiator(props: Props) {
|
||||
useEffect(() => {
|
||||
const videoOnPage = document.querySelector('video');
|
||||
if (
|
||||
(isFree || claimWasPurchased) &&
|
||||
((autoplay && !videoOnPage && isPlayable) || RENDER_MODES.AUTO_RENDER_MODES.includes(renderMode))
|
||||
(canViewFile || forceAutoplayParam) &&
|
||||
((autoplay && (!videoOnPage || forceAutoplayParam) && isPlayable) ||
|
||||
RENDER_MODES.AUTO_RENDER_MODES.includes(renderMode))
|
||||
) {
|
||||
viewFile();
|
||||
}
|
||||
}, [autoplay, viewFile, isFree, renderMode, isPlayable, claimWasPurchased]);
|
||||
}, [autoplay, canViewFile, forceAutoplayParam, isPlayable, renderMode, viewFile]);
|
||||
|
||||
/*
|
||||
once content is playing, let the appropriate <FileRender> take care of it...
|
||||
but for playables, always render so area can be used to fill with floating player
|
||||
*/
|
||||
if (isPlaying && !isPlayable) {
|
||||
if (isFree || claimWasPurchased) {
|
||||
if (canViewFile && !collectionId) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { makeSelectClaimForUri } from 'lbry-redux';
|
||||
import { makeSelectViewCountForUri } from 'lbryinc';
|
||||
import { selectLanguage } from 'redux/selectors/settings';
|
||||
import FileViewCountInline from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
return {
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
viewCount: makeSelectViewCountForUri(props.uri)(state),
|
||||
lang: selectLanguage(state),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(select, null)(FileViewCountInline);
|
||||
@@ -0,0 +1,46 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
|
||||
type Props = {
|
||||
uri: string,
|
||||
isLivestream?: boolean,
|
||||
// --- select ---
|
||||
claim: ?StreamClaim,
|
||||
viewCount: string,
|
||||
lang: ?string,
|
||||
};
|
||||
|
||||
export default function FileViewCountInline(props: Props) {
|
||||
const { isLivestream, claim, viewCount, lang } = props;
|
||||
let formattedViewCount;
|
||||
|
||||
try {
|
||||
formattedViewCount = Number(viewCount).toLocaleString(lang || 'en', {
|
||||
compactDisplay: 'short',
|
||||
notation: 'compact',
|
||||
});
|
||||
} catch (err) {
|
||||
// No soup for you!
|
||||
formattedViewCount = Number(viewCount).toLocaleString();
|
||||
}
|
||||
|
||||
// Limit the view-count visibility to Channel Pages for now. I believe we'll
|
||||
// eventually show it everywhere, so this band-aid would be the easiest to
|
||||
// clean up (only one place edit/remove).
|
||||
const isChannelPage = window.location.pathname.startsWith('/@');
|
||||
|
||||
if (!viewCount || (claim && claim.repost_url) || isLivestream || !isChannelPage) {
|
||||
// (1) Currently, makeSelectViewCountForUri doesn't differentiate between
|
||||
// un-fetched view-count vs zero view-count. But since it's probably not
|
||||
// ideal to highlight that a view has 0 count, let's just not show anything.
|
||||
// (2) No idea how to get the repost source's claim ID from the repost claim,
|
||||
// so hiding it for now.
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<span className="view_count">
|
||||
{viewCount !== 1 ? __('%view_count% views', { view_count: formattedViewCount }) : __('1 view')}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import { connect } from 'react-redux';
|
||||
import fileViewerEmbeddedTitle from './view';
|
||||
import { makeSelectTitleForUri } from 'lbry-redux';
|
||||
import { makeSelectTagInClaimOrChannelForUri, makeSelectTitleForUri } from 'lbry-redux';
|
||||
import { PREFERENCE_EMBED } from 'constants/tags';
|
||||
|
||||
export default connect((state, props) => {
|
||||
return {
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
preferEmbed: makeSelectTagInClaimOrChannelForUri(props.uri, PREFERENCE_EMBED)(state),
|
||||
};
|
||||
})(fileViewerEmbeddedTitle);
|
||||
@@ -11,10 +11,11 @@ type Props = {
|
||||
uri: string,
|
||||
title: ?string,
|
||||
isInApp: boolean,
|
||||
preferEmbed: boolean,
|
||||
};
|
||||
|
||||
function FileViewerEmbeddedTitle(props: Props) {
|
||||
const { uri, title, isInApp } = props;
|
||||
const { uri, title, isInApp, preferEmbed } = props;
|
||||
|
||||
let contentLink = `${formatLbryUrlForWeb(uri)}`;
|
||||
|
||||
@@ -28,15 +29,22 @@ function FileViewerEmbeddedTitle(props: Props) {
|
||||
return (
|
||||
<div className="file-viewer__embedded-header">
|
||||
<div className="file-viewer__embedded-gradient" />
|
||||
<Button
|
||||
label={title}
|
||||
aria-label={title}
|
||||
button="link"
|
||||
className="file-viewer__embedded-title"
|
||||
{...contentLinkProps}
|
||||
/>
|
||||
{preferEmbed ? (
|
||||
<div className="file-viewer__embedded-title ">
|
||||
<span dir="auto">{title}</span>
|
||||
</div>
|
||||
) : (
|
||||
<Button
|
||||
label={title}
|
||||
aria-label={title}
|
||||
button="link"
|
||||
className="file-viewer__embedded-title"
|
||||
{...contentLinkProps}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="file-viewer__embedded-info">
|
||||
<Button className="file-viewer__overlay-logo" aria-label={__('Home')} {...lbryLinkProps}>
|
||||
<Button className="file-viewer__overlay-logo" disabled={preferEmbed} aria-label={__('Home')} {...lbryLinkProps}>
|
||||
<Logo type={'embed'} />
|
||||
</Button>
|
||||
{isInApp && <FilePrice uri={uri} />}
|
||||
|
||||
@@ -55,6 +55,8 @@ export default function LivestreamComments(props: Props) {
|
||||
const [showPinned, setShowPinned] = React.useState(true);
|
||||
const claimId = claim && claim.claim_id;
|
||||
const commentsLength = commentsByChronologicalOrder && commentsByChronologicalOrder.length;
|
||||
|
||||
// which kind of superchat to display, either
|
||||
const commentsToDisplay = viewMode === VIEW_MODE_CHAT ? commentsByChronologicalOrder : superChatsByTipAmount;
|
||||
|
||||
const discussionElement = document.querySelector('.livestream__comments');
|
||||
@@ -136,19 +138,11 @@ export default function LivestreamComments(props: Props) {
|
||||
if (superChatsByTipAmount) {
|
||||
const clonedSuperchats = JSON.parse(JSON.stringify(superChatsByTipAmount));
|
||||
|
||||
// sort by fiat first then by support amount
|
||||
// for top to bottom display, oldest superchat on top most recent on bottom
|
||||
superChatsReversed = clonedSuperchats
|
||||
.sort((a, b) => {
|
||||
// if both are fiat, organize by support
|
||||
if (a.is_fiat === b.is_fiat) {
|
||||
return b.support_amount - a.support_amount;
|
||||
// otherwise, if they are not both fiat, put the fiat transaction first
|
||||
} else {
|
||||
return a.is_fiat === b.is_fiat ? 0 : a.is_fiat ? -1 : 1;
|
||||
}
|
||||
})
|
||||
.reverse();
|
||||
}
|
||||
return b.timestamp - a.timestamp;
|
||||
}); }
|
||||
|
||||
// todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine
|
||||
function isMyComment(channelId: string) {
|
||||
@@ -283,6 +277,7 @@ export default function LivestreamComments(props: Props) {
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* listing comments on top of eachother */}
|
||||
{viewMode === VIEW_MODE_SUPER_CHAT &&
|
||||
superChatsReversed &&
|
||||
superChatsReversed.map((comment) => (
|
||||
|
||||
@@ -39,7 +39,7 @@ export default function LivestreamLayout(props: Props) {
|
||||
{Boolean(chatDisabled) && (
|
||||
<div className="help--notice">
|
||||
{channelName
|
||||
? __('%channelName% has disabled chat for this stream. Enjoy the stream!', { channelName })
|
||||
? __('%channel% has disabled chat for this stream. Enjoy the stream!', { channel: channelName })
|
||||
: __('This channel has disabled chat for this stream. Enjoy the stream!')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -449,7 +449,12 @@ function PublishFile(props: Props) {
|
||||
{publishing && <Spinner type={'small'} />}
|
||||
{inProgress && (
|
||||
<div>
|
||||
<Button button="close" label={__('New')} icon={ICONS.REFRESH} onClick={clearPublish} />
|
||||
<Button
|
||||
button="close"
|
||||
label={__('New --[clears Publish Form]--')}
|
||||
icon={ICONS.REFRESH}
|
||||
onClick={clearPublish}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -46,10 +46,11 @@ function PublishFormErrors(props: Props) {
|
||||
{!bid && <div>{__('A deposit amount is required')}</div>}
|
||||
{bidError && <div>{__('Please check your deposit amount.')}</div>}
|
||||
{isUploadingThumbnail && <div>{__('Please wait for thumbnail to finish uploading')}</div>}
|
||||
{!isUploadingThumbnail && !thumbnail && (
|
||||
{!isUploadingThumbnail && !thumbnail ? (
|
||||
<div>{__('A thumbnail is required. Please upload or provide an image URL above.')}</div>
|
||||
) : (
|
||||
thumbnailError && !thumbnailUploaded && <div>{__('Thumbnail is invalid.')}</div>
|
||||
)}
|
||||
{thumbnailError && !thumbnailUploaded && <div>{__('Thumbnail is invalid.')}</div>}
|
||||
{editingURI && !isStillEditing && !filePath && (
|
||||
<div>{__('Please reselect a file after changing the LBRY URL')}</div>
|
||||
)}
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { makeSelectClaimIsNsfw, makeSelectClaimForUri } from 'lbry-redux';
|
||||
import { doRecommendationUpdate, doRecommendationClicked } from 'redux/actions/content';
|
||||
import { makeSelectClaimForUri } from 'lbry-redux';
|
||||
import { doFetchRecommendedContent } from 'redux/actions/search';
|
||||
import { makeSelectRecommendedContentForUri, selectIsSearching } from 'redux/selectors/search';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import { makeSelectNextUnplayedRecommended } from 'redux/selectors/content';
|
||||
import RecommendedContent from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
mature: makeSelectClaimIsNsfw(props.uri)(state),
|
||||
recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state),
|
||||
nextRecommendedUri: makeSelectNextUnplayedRecommended(props.uri)(state),
|
||||
isSearching: selectIsSearching(state),
|
||||
isAuthenticated: selectUserVerifiedEmail(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
});
|
||||
const select = (state, props) => {
|
||||
const claim = makeSelectClaimForUri(props.uri)(state);
|
||||
const { claim_id: claimId } = claim;
|
||||
const recommendedContentUris = makeSelectRecommendedContentForUri(props.uri)(state);
|
||||
const nextRecommendedUri = recommendedContentUris && recommendedContentUris[0];
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
doFetchRecommendedContent: (uri, mature) => dispatch(doFetchRecommendedContent(uri, mature)),
|
||||
doRecommendationUpdate: (claimId, urls, id, parentId) =>
|
||||
dispatch(doRecommendationUpdate(claimId, urls, id, parentId)),
|
||||
doRecommendationClicked: (claimId, index) => dispatch(doRecommendationClicked(claimId, index)),
|
||||
});
|
||||
return {
|
||||
claim,
|
||||
claimId,
|
||||
recommendedContentUris,
|
||||
nextRecommendedUri,
|
||||
isSearching: selectIsSearching(state),
|
||||
isAuthenticated: selectUserVerifiedEmail(state),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(select, perform)(RecommendedContent);
|
||||
export default connect(select, { doFetchRecommendedContent })(RecommendedContent);
|
||||
@@ -1,8 +1,6 @@
|
||||
// @flow
|
||||
import { SHOW_ADS } from 'config';
|
||||
import React from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import ClaimList from 'component/claimList';
|
||||
import ClaimListDiscover from 'component/claimListDiscover';
|
||||
import Ads from 'web/component/ads';
|
||||
@@ -10,95 +8,59 @@ import Card from 'component/common/card';
|
||||
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
|
||||
import Button from 'component/button';
|
||||
import classnames from 'classnames';
|
||||
import { CONTAINER_ID } from 'constants/navigation';
|
||||
import RecSys from 'recsys';
|
||||
|
||||
const VIEW_ALL_RELATED = 'view_all_related';
|
||||
const VIEW_MORE_FROM = 'view_more_from';
|
||||
|
||||
type Props = {
|
||||
uri: string,
|
||||
recommendedContent: Array<string>,
|
||||
recommendedContentUris: Array<string>,
|
||||
nextRecommendedUri: string,
|
||||
isSearching: boolean,
|
||||
doFetchRecommendedContent: (string, boolean) => void,
|
||||
mature: boolean,
|
||||
doFetchRecommendedContent: (string) => void,
|
||||
isAuthenticated: boolean,
|
||||
claim: ?StreamClaim,
|
||||
doRecommendationUpdate: (claimId: string, urls: Array<string>, id: string, parentId: string) => void,
|
||||
doRecommendationClicked: (claimId: string, index: number) => void,
|
||||
claimId: string,
|
||||
};
|
||||
|
||||
export default React.memo<Props>(function RecommendedContent(props: Props) {
|
||||
const {
|
||||
uri,
|
||||
doFetchRecommendedContent,
|
||||
mature,
|
||||
recommendedContent,
|
||||
recommendedContentUris,
|
||||
nextRecommendedUri,
|
||||
isSearching,
|
||||
isAuthenticated,
|
||||
claim,
|
||||
doRecommendationUpdate,
|
||||
doRecommendationClicked,
|
||||
claimId,
|
||||
} = props;
|
||||
const [viewMode, setViewMode] = React.useState(VIEW_ALL_RELATED);
|
||||
const [recommendationId, setRecommendationId] = React.useState('');
|
||||
const [recommendationUrls, setRecommendationUrls] = React.useState();
|
||||
const history = useHistory();
|
||||
const signingChannel = claim && claim.signing_channel;
|
||||
const channelName = signingChannel ? signingChannel.name : null;
|
||||
const isMobile = useIsMobile();
|
||||
const isMedium = useIsMediumScreen();
|
||||
const { onRecsLoaded: onRecommendationsLoaded, onClickedRecommended: onRecommendationClicked } = RecSys;
|
||||
|
||||
React.useEffect(() => {
|
||||
function moveAutoplayNextItemToTop(recommendedContent) {
|
||||
let newList = recommendedContent;
|
||||
if (newList) {
|
||||
const index = newList.indexOf(nextRecommendedUri);
|
||||
if (index > 0) {
|
||||
const a = newList[0];
|
||||
newList[0] = nextRecommendedUri;
|
||||
newList[index] = a;
|
||||
}
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
|
||||
function listEq(prev, next) {
|
||||
if (prev && next) {
|
||||
return prev.length === next.length && prev.every((value, index) => value === next[index]);
|
||||
} else {
|
||||
return prev === next;
|
||||
}
|
||||
}
|
||||
|
||||
const newRecommendationUrls = moveAutoplayNextItemToTop(recommendedContent);
|
||||
|
||||
if (claim && !listEq(recommendationUrls, newRecommendationUrls)) {
|
||||
const parentId = (history.location.state && history.location.state[CONTAINER_ID]) || '';
|
||||
const id = uuidv4();
|
||||
setRecommendationId(id);
|
||||
setRecommendationUrls(newRecommendationUrls);
|
||||
|
||||
doRecommendationUpdate(claim.claim_id, newRecommendationUrls, id, parentId);
|
||||
}
|
||||
}, [
|
||||
recommendedContent,
|
||||
nextRecommendedUri,
|
||||
recommendationUrls,
|
||||
setRecommendationUrls,
|
||||
claim,
|
||||
doRecommendationUpdate,
|
||||
history.location.state,
|
||||
]);
|
||||
doFetchRecommendedContent(uri);
|
||||
}, [uri, doFetchRecommendedContent]);
|
||||
|
||||
React.useEffect(() => {
|
||||
doFetchRecommendedContent(uri, mature);
|
||||
}, [uri, mature, doFetchRecommendedContent]);
|
||||
// Right now we only want to record the recs if they actually saw them.
|
||||
if (
|
||||
recommendedContentUris &&
|
||||
recommendedContentUris.length &&
|
||||
nextRecommendedUri &&
|
||||
viewMode === VIEW_ALL_RELATED
|
||||
) {
|
||||
onRecommendationsLoaded(claimId, recommendedContentUris);
|
||||
}
|
||||
}, [recommendedContentUris, onRecommendationsLoaded, claimId, nextRecommendedUri, viewMode]);
|
||||
|
||||
function handleRecommendationClicked(e: any, index: number) {
|
||||
function handleRecommendationClicked(e, clickedClaim) {
|
||||
if (claim) {
|
||||
doRecommendationClicked(claim.claim_id, index);
|
||||
onRecommendationClicked(claim.claim_id, clickedClaim.claim_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,10 +95,9 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
|
||||
<div>
|
||||
{viewMode === VIEW_ALL_RELATED && (
|
||||
<ClaimList
|
||||
id={recommendationId}
|
||||
type="small"
|
||||
loading={isSearching}
|
||||
uris={recommendationUrls}
|
||||
uris={recommendedContentUris}
|
||||
hideMenu={isMobile}
|
||||
injectedItem={SHOW_ADS && IS_WEB && !isAuthenticated && <Ads small type={'video'} />}
|
||||
empty={__('No related content found')}
|
||||
@@ -176,9 +137,8 @@ function areEqual(prevProps: Props, nextProps: Props) {
|
||||
a.nextRecommendedUri !== b.nextRecommendedUri ||
|
||||
a.isAuthenticated !== b.isAuthenticated ||
|
||||
a.isSearching !== b.isSearching ||
|
||||
a.mature !== b.mature ||
|
||||
(a.recommendedContent && !b.recommendedContent) ||
|
||||
(!a.recommendedContent && b.recommendedContent) ||
|
||||
(a.recommendedContentUris && !b.recommendedContentUris) ||
|
||||
(!a.recommendedContentUris && b.recommendedContentUris) ||
|
||||
(a.claim && !b.claim) ||
|
||||
(!a.claim && b.claim)
|
||||
) {
|
||||
@@ -189,14 +149,14 @@ function areEqual(prevProps: Props, nextProps: Props) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a.recommendedContent && b.recommendedContent) {
|
||||
if (a.recommendedContent.length !== b.recommendedContent.length) {
|
||||
if (a.recommendedContentUris && b.recommendedContentUris) {
|
||||
if (a.recommendedContentUris.length !== b.recommendedContentUris.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let i = a.recommendedContent.length;
|
||||
let i = a.recommendedContentUris.length;
|
||||
while (i--) {
|
||||
if (a.recommendedContent[i] !== b.recommendedContent[i]) {
|
||||
if (a.recommendedContentUris[i] !== b.recommendedContentUris[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import SearchChannelField from './view';
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
doToast: (options) => dispatch(doToast(options)),
|
||||
});
|
||||
|
||||
export default connect(null, perform)(SearchChannelField);
|
||||
@@ -0,0 +1,199 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { isNameValid, parseURI } from 'lbry-redux';
|
||||
import Button from 'component/button';
|
||||
import ClaimPreview from 'component/claimPreview';
|
||||
import { FormField } from 'component/common/form-components/form-field';
|
||||
import Icon from 'component/common/icon';
|
||||
import TagsSearch from 'component/tagsSearch';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import { getUriForSearchTerm } from 'util/search';
|
||||
|
||||
type Props = {
|
||||
label: string,
|
||||
labelAddNew: string,
|
||||
labelFoundAction: string,
|
||||
values: Array<string>, // [ 'name#id', 'name#id' ]
|
||||
onAdd?: (channelUri: string) => void,
|
||||
onRemove?: (channelUri: string) => void,
|
||||
// --- perform ---
|
||||
doToast: ({ message: string }) => void,
|
||||
};
|
||||
|
||||
export default function SearchChannelField(props: Props) {
|
||||
const { label, labelAddNew, labelFoundAction, values, onAdd, onRemove, doToast } = props;
|
||||
|
||||
const [searchTerm, setSearchTerm] = React.useState('');
|
||||
const [searchTermError, setSearchTermError] = React.useState('');
|
||||
const [searchUri, setSearchUri] = React.useState('');
|
||||
const addTagRef = React.useRef<any>();
|
||||
|
||||
function parseUri(name: string) {
|
||||
try {
|
||||
return parseURI(name);
|
||||
} catch (e) {}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function addTag(newTags: Array<Tag>) {
|
||||
// Ignoring multiple entries for now, although <TagsSearch> supports it.
|
||||
const uri = parseUri(newTags[0].name);
|
||||
|
||||
if (uri && uri.isChannel && uri.claimName && uri.claimId) {
|
||||
if (!values.includes(newTags[0].name)) {
|
||||
if (onAdd) {
|
||||
onAdd(newTags[0].name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
doToast({ message: __('Invalid channel URL "%url%"', { url: newTags[0].name }), isError: true });
|
||||
}
|
||||
}
|
||||
|
||||
function removeTag(tagToRemove: Tag) {
|
||||
const uri = parseUri(tagToRemove.name);
|
||||
|
||||
if (uri && uri.isChannel && uri.claimName && uri.claimId) {
|
||||
if (values.includes(tagToRemove.name)) {
|
||||
if (onRemove) {
|
||||
onRemove(tagToRemove.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clearSearchTerm() {
|
||||
setSearchTerm('');
|
||||
setSearchTermError('');
|
||||
setSearchUri('');
|
||||
}
|
||||
|
||||
function handleKeyPress(e) {
|
||||
// We have to use 'key' instead of 'keyCode' in this event.
|
||||
if (e.key === 'Enter' && addTagRef && addTagRef.current && addTagRef.current.click) {
|
||||
e.preventDefault();
|
||||
addTagRef.current.click();
|
||||
}
|
||||
}
|
||||
|
||||
function getFoundChannelRenderActionsFn() {
|
||||
function handleFoundChannelClick(claim) {
|
||||
if (claim && claim.name && claim.claim_id) {
|
||||
addTag([{ name: claim.name + '#' + claim.claim_id }]);
|
||||
clearSearchTerm();
|
||||
}
|
||||
}
|
||||
|
||||
return (claim) => {
|
||||
return (
|
||||
<Button
|
||||
ref={addTagRef}
|
||||
requiresAuth
|
||||
button="primary"
|
||||
label={labelFoundAction}
|
||||
onClick={() => handleFoundChannelClick(claim)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
// 'searchTerm' sanitization
|
||||
React.useEffect(() => {
|
||||
if (!searchTerm) {
|
||||
clearSearchTerm();
|
||||
} else {
|
||||
const isUrl = searchTerm.startsWith('https://') || searchTerm.startsWith('lbry://');
|
||||
const autoAlias = !isUrl && !searchTerm.startsWith('@') ? '@' : '';
|
||||
|
||||
const [uri, error] = getUriForSearchTerm(`${autoAlias}${searchTerm}`);
|
||||
setSearchTermError(error ? __('Something not quite right..') : '');
|
||||
|
||||
try {
|
||||
const { streamName, channelName, isChannel } = parseURI(uri);
|
||||
|
||||
if (!isChannel && streamName && isNameValid(streamName)) {
|
||||
setSearchTermError(__('Not a channel (prefix with "@", or enter the channel URL)'));
|
||||
setSearchUri('');
|
||||
} else if (isChannel && channelName && isNameValid(channelName)) {
|
||||
setSearchUri(uri);
|
||||
}
|
||||
} catch (e) {
|
||||
setSearchTermError(e.message);
|
||||
setSearchUri('');
|
||||
}
|
||||
}
|
||||
}, [searchTerm, setSearchTermError]);
|
||||
|
||||
return (
|
||||
<div className="search__channel tag--blocked-words">
|
||||
<TagsSearch
|
||||
label={label}
|
||||
labelAddNew={labelAddNew}
|
||||
tagsPassedIn={values.map((x) => ({ name: x }))}
|
||||
onSelect={addTag}
|
||||
onRemove={removeTag}
|
||||
disableAutoFocus
|
||||
hideInputField
|
||||
hideSuggestions
|
||||
disableControlTags
|
||||
/>
|
||||
|
||||
<div className="search__channel--popup">
|
||||
<FormField
|
||||
type="text"
|
||||
name="moderator_search"
|
||||
className="form-field--address"
|
||||
label={
|
||||
<>
|
||||
{labelAddNew}
|
||||
<Icon
|
||||
customTooltipText={__(HELP.CHANNEL_SEARCH)}
|
||||
className="icon--help"
|
||||
icon={ICONS.HELP}
|
||||
tooltip
|
||||
size={16}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
placeholder={__('Enter full channel name or URL')}
|
||||
value={searchTerm}
|
||||
error={searchTermError}
|
||||
onKeyPress={(e) => handleKeyPress(e)}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
|
||||
{searchUri && (
|
||||
<div className="search__channel--popup-results">
|
||||
<ClaimPreview
|
||||
uri={searchUri}
|
||||
hideMenu
|
||||
hideRepostLabel
|
||||
disableNavigation
|
||||
showNullPlaceholder
|
||||
properties={''}
|
||||
renderActions={getFoundChannelRenderActionsFn()}
|
||||
empty={
|
||||
<div className="claim-preview claim-preview--inactive claim-preview--large claim-preview__empty">
|
||||
{__('Channel not found')}
|
||||
<Icon
|
||||
customTooltipText={__(HELP.CHANNEL_SEARCH)}
|
||||
className="icon--help"
|
||||
icon={ICONS.HELP}
|
||||
tooltip
|
||||
size={22}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
const HELP = {
|
||||
CHANNEL_SEARCH: 'Enter the full channel name or URL to search.\n\nExamples:\n - @channel\n - @channel#3\n - https://odysee.com/@Odysee:8\n - lbry://@Odysee#8',
|
||||
};
|
||||
@@ -17,8 +17,8 @@ type Props = {
|
||||
winningUri: ?string,
|
||||
doResolveUris: (Array<string>) => void,
|
||||
hideLink?: boolean,
|
||||
setChannelActive: boolean => void,
|
||||
beginPublish: string => void,
|
||||
setChannelActive: (boolean) => void,
|
||||
beginPublish: (string) => void,
|
||||
pendingIds: Array<string>,
|
||||
isResolvingWinningUri: boolean,
|
||||
winningClaim: ?Claim,
|
||||
@@ -92,7 +92,7 @@ export default function SearchTopClaim(props: Props) {
|
||||
hideRepostLabel
|
||||
showNullPlaceholder
|
||||
uri={winningUri}
|
||||
properties={claim => (
|
||||
properties={(claim) => (
|
||||
<span className="claim-preview__custom-properties">
|
||||
<ClaimRepostAuthor short uri={winningUri} />
|
||||
<ClaimEffectiveAmount uri={winningUri} />
|
||||
|
||||
@@ -6,23 +6,19 @@ import {
|
||||
selectFileInfosByOutpoint,
|
||||
doResetThumbnailStatus,
|
||||
} from 'lbry-redux';
|
||||
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import PublishPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
const select = (state) => ({
|
||||
...selectPublishFormValues(state),
|
||||
fileInfos: selectFileInfosByOutpoint(state),
|
||||
myClaimForUri: selectMyClaimForUri(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
||||
const perform = (dispatch) => ({
|
||||
updatePublishForm: (value) => dispatch(doUpdatePublishForm(value)),
|
||||
resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()),
|
||||
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(PublishPage);
|
||||
export default connect(select, perform)(PublishPage);
|
||||
@@ -18,166 +18,178 @@ type Props = {
|
||||
uploadThumbnailStatus: string,
|
||||
thumbnailPath: ?string,
|
||||
thumbnailError: ?string,
|
||||
thumbnailParam: ?string,
|
||||
thumbnailParamError: boolean,
|
||||
thumbnailParamStatus: string,
|
||||
openModal: (id: string, {}) => void,
|
||||
updatePublishForm: ({}) => void,
|
||||
updateThumbnailParams: ({}) => void,
|
||||
resetThumbnailStatus: () => void,
|
||||
};
|
||||
|
||||
class SelectThumbnail extends React.PureComponent<Props> {
|
||||
constructor() {
|
||||
super();
|
||||
(this: any).handleThumbnailChange = this.handleThumbnailChange.bind(this);
|
||||
function SelectThumbnail(props: Props) {
|
||||
const {
|
||||
filePath,
|
||||
fileInfos,
|
||||
myClaimForUri,
|
||||
formDisabled,
|
||||
uploadThumbnailStatus: status,
|
||||
openModal,
|
||||
updatePublishForm,
|
||||
thumbnailParam,
|
||||
thumbnailParamStatus,
|
||||
updateThumbnailParams,
|
||||
thumbnailPath,
|
||||
resetThumbnailStatus,
|
||||
} = props;
|
||||
|
||||
const publishForm = !updateThumbnailParams;
|
||||
const thumbnail = publishForm ? props.thumbnail : thumbnailParam;
|
||||
const thumbnailError = publishForm ? props.thumbnailError : props.thumbnailParamError;
|
||||
|
||||
const accept = '.png, .jpg, .jpeg, .gif';
|
||||
const manualInput = status === THUMBNAIL_STATUSES.API_DOWN || status === THUMBNAIL_STATUSES.MANUAL;
|
||||
const thumbUploaded = status === THUMBNAIL_STATUSES.COMPLETE && thumbnail;
|
||||
const isUrlInput = thumbnail !== ThumbnailMissingImage && thumbnail !== ThumbnailBrokenImage;
|
||||
|
||||
const outpoint = myClaimForUri ? `${myClaimForUri.txid}:${myClaimForUri.nout}` : undefined;
|
||||
const fileInfo = outpoint ? fileInfos[outpoint] : undefined;
|
||||
const downloadPath = fileInfo ? fileInfo.download_path : undefined;
|
||||
|
||||
const actualFilePath = filePath || downloadPath;
|
||||
let isSupportedVideo = false;
|
||||
if (typeof actualFilePath === 'string') {
|
||||
isSupportedVideo = Lbry.getMediaType(null, actualFilePath) === 'video';
|
||||
} else if (actualFilePath && actualFilePath.type) {
|
||||
isSupportedVideo = actualFilePath.type.split('/')[0] === 'video';
|
||||
}
|
||||
|
||||
handleThumbnailChange(e: SyntheticInputEvent<*>) {
|
||||
const { updatePublishForm } = this.props;
|
||||
function handleThumbnailChange(e: SyntheticInputEvent<*>) {
|
||||
const newThumbnail = e.target.value.replace(' ', '');
|
||||
|
||||
updatePublishForm({
|
||||
thumbnail: newThumbnail,
|
||||
thumbnailError: newThumbnail.startsWith('data:image'),
|
||||
});
|
||||
if (updateThumbnailParams) {
|
||||
updateThumbnailParams({ thumbnail_url: newThumbnail });
|
||||
} else {
|
||||
updatePublishForm({ thumbnail: newThumbnail });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
filePath,
|
||||
fileInfos,
|
||||
myClaimForUri,
|
||||
thumbnail,
|
||||
formDisabled,
|
||||
uploadThumbnailStatus: status,
|
||||
openModal,
|
||||
updatePublishForm,
|
||||
thumbnailPath,
|
||||
thumbnailError,
|
||||
resetThumbnailStatus,
|
||||
} = this.props;
|
||||
|
||||
const accept = '.png, .jpg, .jpeg, .gif';
|
||||
|
||||
const outpoint = myClaimForUri ? `${myClaimForUri.txid}:${myClaimForUri.nout}` : undefined;
|
||||
const fileInfo = outpoint ? fileInfos[outpoint] : undefined;
|
||||
const downloadPath = fileInfo ? fileInfo.download_path : undefined;
|
||||
|
||||
const actualFilePath = filePath || downloadPath;
|
||||
let isSupportedVideo = false;
|
||||
if (typeof actualFilePath === 'string') {
|
||||
isSupportedVideo = Lbry.getMediaType(null, actualFilePath) === 'video';
|
||||
} else if (actualFilePath && actualFilePath.type) {
|
||||
isSupportedVideo = actualFilePath.type.split('/')[0] === 'video';
|
||||
React.useEffect(() => {
|
||||
if (updateThumbnailParams && status !== thumbnailParamStatus) {
|
||||
updateThumbnailParams({ thumbnail_status: status });
|
||||
}
|
||||
}, [status, thumbnailParamStatus, updateThumbnailParams]);
|
||||
|
||||
let thumbnailInputSrc;
|
||||
if (!thumbnail) {
|
||||
thumbnailInputSrc = ThumbnailMissingImage;
|
||||
} else if (thumbnailError) {
|
||||
thumbnailInputSrc = ThumbnailBrokenImage;
|
||||
} else {
|
||||
thumbnailInputSrc = thumbnail;
|
||||
}
|
||||
let thumbnailSrc;
|
||||
if (!thumbnail) {
|
||||
thumbnailSrc = ThumbnailMissingImage;
|
||||
} else if (thumbnailError) {
|
||||
thumbnailSrc =
|
||||
(manualInput && ThumbnailBrokenImage) || (status !== THUMBNAIL_STATUSES.COMPLETE && ThumbnailMissingImage);
|
||||
} else {
|
||||
thumbnailSrc = thumbnail;
|
||||
}
|
||||
|
||||
/*
|
||||
Note:
|
||||
We are using backgroundImage instead of an <img /> to zoom if the selected thumbnail isn't
|
||||
the proper aspect ratio. This is to avoid blackbars on the side of images and inconsistent thumbnails
|
||||
We still need to render the image to see if there is an error loading the url
|
||||
*/
|
||||
/*
|
||||
Note:
|
||||
We are using backgroundImage instead of an <img /> to zoom if the selected thumbnail isn't
|
||||
the proper aspect ratio. This is to avoid blackbars on the side of images and inconsistent thumbnails
|
||||
We still need to render the image to see if there is an error loading the url
|
||||
*/
|
||||
const thumbPreview = (
|
||||
<div className="column__item thumbnail-picker__preview" style={{ backgroundImage: `url(${String(thumbnailSrc)})` }}>
|
||||
{thumbUploaded && thumbnailError !== false && __('This will be visible in a few minutes.')}
|
||||
<img
|
||||
style={{ display: 'none' }}
|
||||
src={thumbnail}
|
||||
alt={__('Thumbnail Preview')}
|
||||
onError={() =>
|
||||
publishForm
|
||||
? updatePublishForm({ thumbnailError: true })
|
||||
: updateThumbnailParams({ thumbnail_error: Boolean(thumbnail) })
|
||||
}
|
||||
onLoad={() =>
|
||||
publishForm
|
||||
? updatePublishForm({ thumbnailError: !isUrlInput })
|
||||
: updateThumbnailParams({ thumbnail_error: !isUrlInput })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{status === THUMBNAIL_STATUSES.API_DOWN || status === THUMBNAIL_STATUSES.MANUAL ? (
|
||||
<div className="column">
|
||||
<div className="column__item thumbnail-preview" style={{ backgroundImage: `url(${thumbnailInputSrc})` }}>
|
||||
<img
|
||||
style={{ display: 'none' }}
|
||||
src={thumbnailInputSrc}
|
||||
alt={__('Thumbnail Preview')}
|
||||
onError={() => updatePublishForm({ thumbnailError: true })}
|
||||
/>
|
||||
</div>
|
||||
return (
|
||||
<>
|
||||
{status !== THUMBNAIL_STATUSES.IN_PROGRESS && (
|
||||
<div className="column">
|
||||
{thumbPreview}
|
||||
{publishForm && thumbUploaded ? (
|
||||
<div className="column__item">
|
||||
<FormField
|
||||
type="text"
|
||||
name="content_thumbnail"
|
||||
label="URL"
|
||||
placeholder="https://images.fbi.gov/alien"
|
||||
value={thumbnail}
|
||||
disabled={formDisabled}
|
||||
onChange={this.handleThumbnailChange}
|
||||
/>
|
||||
<p>{__('Upload complete.')}</p>
|
||||
<div className="section__actions">
|
||||
<Button button="link" label={__('New thumbnail')} onClick={resetThumbnailStatus} />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="column__item">
|
||||
{manualInput ? (
|
||||
<FormField
|
||||
type="text"
|
||||
name="content_thumbnail"
|
||||
label="URL"
|
||||
placeholder="https://images.fbi.gov/alien"
|
||||
value={thumbnail}
|
||||
disabled={formDisabled}
|
||||
onChange={handleThumbnailChange}
|
||||
/>
|
||||
) : (
|
||||
<FileSelector
|
||||
currentPath={thumbnailPath}
|
||||
label={__('Thumbnail')}
|
||||
placeholder={__('Choose an enticing thumbnail')}
|
||||
accept={accept}
|
||||
onFileChosen={(file) =>
|
||||
openModal(MODALS.CONFIRM_THUMBNAIL_UPLOAD, {
|
||||
file,
|
||||
cb: (url) => !publishForm && updateThumbnailParams({ thumbnail_url: url }),
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<div className="card__actions">
|
||||
<Button
|
||||
button="link"
|
||||
label={__('Use thumbnail upload tool')}
|
||||
onClick={() => updatePublishForm({ uploadThumbnailStatus: THUMBNAIL_STATUSES.READY })}
|
||||
label={manualInput ? __('Use thumbnail upload tool') : __('Enter a thumbnail URL')}
|
||||
onClick={() =>
|
||||
updatePublishForm({
|
||||
uploadThumbnailStatus: manualInput ? THUMBNAIL_STATUSES.READY : THUMBNAIL_STATUSES.MANUAL,
|
||||
})
|
||||
}
|
||||
/>
|
||||
{status === THUMBNAIL_STATUSES.READY && isSupportedVideo && IS_WEB && (
|
||||
// Disabled on desktop until this is resolved
|
||||
// https://github.com/electron/electron/issues/20750#issuecomment-709505902
|
||||
<Button
|
||||
button="link"
|
||||
label={__('Take a snapshot from your video')}
|
||||
onClick={() => openModal(MODALS.AUTO_GENERATE_THUMBNAIL, { filePath: actualFilePath })}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<React.Fragment>
|
||||
{status === THUMBNAIL_STATUSES.READY && (
|
||||
<FileSelector
|
||||
currentPath={thumbnailPath}
|
||||
label={__('Thumbnail')}
|
||||
placeholder={__('Choose an enticing thumbnail')}
|
||||
accept={accept}
|
||||
onFileChosen={(file) => openModal(MODALS.CONFIRM_THUMBNAIL_UPLOAD, { file })}
|
||||
/>
|
||||
)}
|
||||
{status === THUMBNAIL_STATUSES.COMPLETE && thumbnail && (
|
||||
<div className="column column--space-between">
|
||||
<div className="column__item thumbnail-preview" style={{ backgroundImage: `url(${thumbnail})` }}>
|
||||
{(thumbnailError !== false) && __('This will be visible in a few minutes.')}
|
||||
<img
|
||||
style={{ display: 'none' }}
|
||||
src={thumbnail}
|
||||
alt={__('Thumbnail Preview')}
|
||||
onError={() => updatePublishForm({ thumbnailError: true })}
|
||||
onLoad={() => updatePublishForm({ thumbnailError: false })}
|
||||
/>
|
||||
</div>
|
||||
<div className="column__item">
|
||||
<p>{__('Upload complete.')}</p>
|
||||
<div className="section__actions">
|
||||
<Button button="link" label={__('New thumbnail')} onClick={resetThumbnailStatus} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</React.Fragment>
|
||||
)}
|
||||
{status === THUMBNAIL_STATUSES.READY && (
|
||||
<div className="section__actions">
|
||||
<Button
|
||||
button="link"
|
||||
label={__('Enter a thumbnail URL')}
|
||||
onClick={() => updatePublishForm({ uploadThumbnailStatus: THUMBNAIL_STATUSES.MANUAL })}
|
||||
/>
|
||||
{isSupportedVideo && IS_WEB && (
|
||||
// Disabled on desktop until this is resolved
|
||||
// https://github.com/electron/electron/issues/20750#issuecomment-709505902
|
||||
<Button
|
||||
button="link"
|
||||
label={__('Take a snapshot from your video')}
|
||||
onClick={() => openModal(MODALS.AUTO_GENERATE_THUMBNAIL, { filePath: actualFilePath })}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{status === THUMBNAIL_STATUSES.IN_PROGRESS && <p>{__('Uploading thumbnail')}...</p>}
|
||||
{status !== THUMBNAIL_STATUSES.COMPLETE && (
|
||||
<p className="help">
|
||||
{status === THUMBNAIL_STATUSES.API_DOWN
|
||||
? __('Enter a URL for your thumbnail.')
|
||||
: __('Upload your thumbnail to %domain%. Recommended size is 16:9.', { domain: DOMAIN })}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
{status === THUMBNAIL_STATUSES.IN_PROGRESS && <p>{__('Uploading thumbnail')}...</p>}
|
||||
{!thumbUploaded && (
|
||||
<p className="help">
|
||||
{manualInput
|
||||
? __('Enter a URL for your thumbnail.')
|
||||
: __('Upload your thumbnail to %domain%. Recommended size is 16:9.', { domain: DOMAIN })}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default SelectThumbnail;
|
||||
@@ -220,7 +220,7 @@ export default function SettingContent(props: Props) {
|
||||
const HELP = {
|
||||
FLOATING_PLAYER: 'Keep content playing in the corner when navigating to a different page.',
|
||||
AUTOPLAY_MEDIA: 'Autoplay video and audio files when navigating to a file.',
|
||||
AUTOPLAY_NEXT: 'Autoplay video and audio files as the next related item when a file finishes playing.',
|
||||
AUTOPLAY_NEXT: 'Autoplay the next related item when a file (video or audio) finishes playing.',
|
||||
HIDE_REPOSTS: 'You will not see reposts by people you follow or receive email notifying about them.',
|
||||
SHOW_MATURE: 'Mature content may include nudity, intense sexuality, profanity, or other adult content. By displaying mature content, you are affirming you are of legal age to view mature content in your country or jurisdiction. ',
|
||||
MAX_PURCHASE_PRICE: 'This will prevent you from purchasing any content over a certain cost, as a safety measure.',
|
||||
|
||||
@@ -35,20 +35,22 @@ function SettingLanguage(props: Props) {
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
{previousLanguage && <Spinner type="small" />}
|
||||
{!previousLanguage && (
|
||||
<FormField
|
||||
name="language_select"
|
||||
type="select"
|
||||
onChange={onLanguageChange}
|
||||
value={language || getDefaultLanguage()}
|
||||
>
|
||||
{sortLanguageMap(SUPPORTED_LANGUAGES).map(([langKey, langName]) => (
|
||||
<option key={langKey} value={langKey}>
|
||||
{langName}
|
||||
</option>
|
||||
))}
|
||||
</FormField>
|
||||
)}
|
||||
|
||||
<FormField
|
||||
name="language_select"
|
||||
type="select"
|
||||
onChange={onLanguageChange}
|
||||
value={language || getDefaultLanguage()}
|
||||
>
|
||||
{sortLanguageMap(SUPPORTED_LANGUAGES).map(([langKey, langName]) => (
|
||||
<option key={langKey} value={langKey}>
|
||||
{langName}
|
||||
</option>
|
||||
))}
|
||||
</FormField>
|
||||
{previousLanguage && <Spinner type="small" />}
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,11 @@ export default function SettingsSideNavigation() {
|
||||
const TOP_MARGIN_PX = 20;
|
||||
const element = document.getElementById(section);
|
||||
if (element) {
|
||||
window.scrollTo(0, element.offsetTop - TOP_MARGIN_PX);
|
||||
window.scrollTo({
|
||||
top: element.offsetTop - TOP_MARGIN_PX,
|
||||
left: 0,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import type { Node } from 'react';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import React from 'react';
|
||||
import Button from 'component/button';
|
||||
import classnames from 'classnames';
|
||||
@@ -15,9 +16,6 @@ import { SIMPLE_SITE, DOMAIN, ENABLE_UI_NOTIFICATIONS } from 'config';
|
||||
import { IS_MAC } from 'component/app/view';
|
||||
// @endif
|
||||
|
||||
const ESCAPE_KEY_CODE = 27;
|
||||
const BACKSLASH_KEY_CODE = 220;
|
||||
|
||||
const HOME = {
|
||||
title: 'Home',
|
||||
link: `/`,
|
||||
@@ -265,9 +263,9 @@ function SideNavigation(props: Props) {
|
||||
|
||||
React.useEffect(() => {
|
||||
function handleKeydown(e: SyntheticKeyboardEvent<*>) {
|
||||
if (e.keyCode === ESCAPE_KEY_CODE && isAbsolute) {
|
||||
if (e.keyCode === KEYCODES.ESCAPE && isAbsolute) {
|
||||
setSidebarOpen(false);
|
||||
} else if (e.keyCode === BACKSLASH_KEY_CODE) {
|
||||
} else if (e.keyCode === KEYCODES.BACKSLASH) {
|
||||
const hasActiveInput = document.querySelector('input:focus, textarea:focus');
|
||||
if (!hasActiveInput) {
|
||||
setSidebarOpen(!sidebarOpen);
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import ThumbnailPicker from './view';
|
||||
import { makeSelectThumbnailForUri } from 'lbry-redux';
|
||||
|
||||
const select = (state, props) => ({
|
||||
thumbnailForUri: makeSelectThumbnailForUri(props.uri)(state),
|
||||
});
|
||||
|
||||
// const perform = dispatch => ({
|
||||
// });
|
||||
|
||||
export default connect(select)(ThumbnailPicker);
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 KiB |
@@ -1,116 +0,0 @@
|
||||
// @flow
|
||||
import * as React from 'react';
|
||||
import Card from 'component/common/card';
|
||||
import ThumbnailMissingImage from './thumbnail-missing.png';
|
||||
import SelectAsset from 'component/selectAsset';
|
||||
|
||||
type Props = {
|
||||
// uploadThumbnailStatus: string,
|
||||
thumbnailParam: string,
|
||||
thumbnailForUri: string,
|
||||
updateThumbnailParam: (string) => void,
|
||||
inline?: boolean,
|
||||
};
|
||||
|
||||
const ThumbnailPicker = (props: Props) => {
|
||||
const { thumbnailForUri, thumbnailParam, updateThumbnailParam, inline } = props;
|
||||
|
||||
// uploadThumbnailStatus
|
||||
// {status === THUMBNAIL_STATUSES.API_DOWN || status === THUMBNAIL_STATUSES.MANUAL ? (
|
||||
// {status === THUMBNAIL_STATUSES.READY && (
|
||||
// {status === THUMBNAIL_STATUSES.COMPLETE && thumbnail && (
|
||||
const [thumbError, setThumbError] = React.useState(false); // possibly existing URL
|
||||
|
||||
const updateThumb = (thumb: string) => {
|
||||
setThumbError(false);
|
||||
updateThumbnailParam(thumb);
|
||||
};
|
||||
if (inline) {
|
||||
return (
|
||||
<fieldset-section>
|
||||
<label>{__('Thumbnail')}</label>
|
||||
<div className="column">
|
||||
{thumbError && (
|
||||
<div
|
||||
className="column__item thumbnail-picker__preview"
|
||||
style={{ backgroundImage: `url(${ThumbnailMissingImage})` }}
|
||||
/>
|
||||
)}
|
||||
{!thumbError && (
|
||||
<div
|
||||
className="column__item thumbnail-picker__preview"
|
||||
style={{ backgroundImage: `url(${thumbnailParam || thumbnailForUri})` }}
|
||||
>
|
||||
<img
|
||||
style={{ display: 'none' }}
|
||||
src={thumbnailParam || thumbnailForUri}
|
||||
alt={__('Thumbnail Preview')}
|
||||
onError={() => {
|
||||
if (thumbnailParam) {
|
||||
setThumbError(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="column__item">
|
||||
{/* if upload */}
|
||||
<SelectAsset
|
||||
inline
|
||||
onUpdate={updateThumb}
|
||||
currentValue={thumbnailParam}
|
||||
assetName={'Image'}
|
||||
recommended={__('(16:9)')}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset-section>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card
|
||||
body={
|
||||
<div className="column">
|
||||
{thumbError && (
|
||||
<div
|
||||
className="column__item thumbnail-preview"
|
||||
style={{ backgroundImage: `url(${ThumbnailMissingImage})` }}
|
||||
/>
|
||||
)}
|
||||
{!thumbError && (
|
||||
<div
|
||||
className="column__item thumbnail-preview"
|
||||
style={{ backgroundImage: `url(${thumbnailParam || thumbnailForUri})` }}
|
||||
>
|
||||
<img
|
||||
style={{ display: 'none' }}
|
||||
src={thumbnailParam || thumbnailForUri}
|
||||
alt={__('Thumbnail Preview')}
|
||||
onError={() => {
|
||||
if (thumbnailParam) {
|
||||
setThumbError(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="column__item">
|
||||
{/* if upload */}
|
||||
<SelectAsset
|
||||
inline
|
||||
onUpdate={updateThumb}
|
||||
currentValue={thumbnailParam}
|
||||
assetName={'Thumbnail'}
|
||||
recommended={__('(16:9)')}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ThumbnailPicker;
|
||||
@@ -57,8 +57,8 @@ class UriIndicator extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
const isChannelClaim = claim.value_type === 'channel';
|
||||
|
||||
if (!claim.signing_channel && !isChannelClaim) {
|
||||
const signingChannel = claim.signing_channel && claim.signing_channel.amount;
|
||||
if (!signingChannel && !isChannelClaim) {
|
||||
if (hideAnonymous) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ function UserChannelFollowIntro(props: Props) {
|
||||
<div className="section__body">
|
||||
<ClaimListDiscover
|
||||
hideFilters={SIMPLE_SITE}
|
||||
hideAdvancedFilter={SIMPLE_SITE}
|
||||
meta={
|
||||
<Button
|
||||
button={subscribedChannels.length < 1 ? 'alt' : 'primary'}
|
||||
|
||||
@@ -1,28 +1,31 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
SETTINGS,
|
||||
COLLECTIONS_CONSTS,
|
||||
makeSelectNextUrlForCollectionAndUrl,
|
||||
makeSelectPreviousUrlForCollectionAndUrl,
|
||||
makeSelectTagInClaimOrChannelForUri,
|
||||
} from 'lbry-redux';
|
||||
import { doChangeVolume, doChangeMute, doAnalyticsView, doAnalyticsBuffer } from 'redux/actions/app';
|
||||
import {
|
||||
doChangeVolume,
|
||||
doChangeMute,
|
||||
doAnalyticsView,
|
||||
doAnalyticsBuffer,
|
||||
doAnaltyicsPurchaseEvent,
|
||||
} from 'redux/actions/app';
|
||||
import { selectVolume, selectMute } from 'redux/selectors/app';
|
||||
import { savePosition, clearPosition, doPlayUri, doSetPlayingUri } from 'redux/actions/content';
|
||||
import {
|
||||
makeSelectContentPositionForUri,
|
||||
makeSelectIsPlayerFloating,
|
||||
makeSelectNextUnplayedRecommended,
|
||||
selectPlayingUri,
|
||||
} from 'redux/selectors/content';
|
||||
import { makeSelectContentPositionForUri, makeSelectIsPlayerFloating, selectPlayingUri } from 'redux/selectors/content';
|
||||
import { makeSelectRecommendedContentForUri } from 'redux/selectors/search';
|
||||
import VideoViewer from './view';
|
||||
import { withRouter } from 'react-router';
|
||||
import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards';
|
||||
import { selectDaemonSettings, makeSelectClientSetting, selectHomepageData } from 'redux/selectors/settings';
|
||||
import { toggleVideoTheaterMode, toggleAutoplayNext, doSetClientSetting } from 'redux/actions/settings';
|
||||
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
|
||||
import { PREFERENCE_EMBED } from 'constants/tags';
|
||||
|
||||
const select = (state, props) => {
|
||||
const { search } = props.location;
|
||||
@@ -34,6 +37,7 @@ const select = (state, props) => {
|
||||
const userId = selectUser(state) && selectUser(state).id;
|
||||
const playingUri = selectPlayingUri(state);
|
||||
const collectionId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) || (playingUri && playingUri.collectionId);
|
||||
const isMarkdownOrComment = playingUri && (playingUri.source === 'markdown' || playingUri.source === 'comment');
|
||||
|
||||
let nextRecommendedUri;
|
||||
let previousListUri;
|
||||
@@ -41,28 +45,29 @@ const select = (state, props) => {
|
||||
nextRecommendedUri = makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state);
|
||||
previousListUri = makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state);
|
||||
} else {
|
||||
nextRecommendedUri = makeSelectNextUnplayedRecommended(uri)(state);
|
||||
const recommendedContent = makeSelectRecommendedContentForUri(uri)(state);
|
||||
nextRecommendedUri = recommendedContent && recommendedContent[0];
|
||||
}
|
||||
|
||||
return {
|
||||
position,
|
||||
userId,
|
||||
collectionId,
|
||||
nextRecommendedUri,
|
||||
previousListUri,
|
||||
isMarkdownOrComment,
|
||||
preferEmbed: makeSelectTagInClaimOrChannelForUri(props.uri, PREFERENCE_EMBED)(state),
|
||||
autoplayIfEmbedded: Boolean(autoplay),
|
||||
autoplayMedia: Boolean(makeSelectClientSetting(SETTINGS.AUTOPLAY_MEDIA)(state)),
|
||||
autoplayNext: Boolean(makeSelectClientSetting(SETTINGS.AUTOPLAY_NEXT)(state)),
|
||||
autoplayNext: makeSelectClientSetting(SETTINGS.AUTOPLAY_NEXT)(state),
|
||||
volume: selectVolume(state),
|
||||
muted: selectMute(state),
|
||||
videoPlaybackRate: makeSelectClientSetting(SETTINGS.VIDEO_PLAYBACK_RATE)(state),
|
||||
position: position,
|
||||
hasFileInfo: Boolean(makeSelectFileInfoForUri(uri)(state)),
|
||||
thumbnail: makeSelectThumbnailForUri(uri)(state),
|
||||
claim: makeSelectClaimForUri(uri)(state),
|
||||
homepageData: selectHomepageData(state),
|
||||
authenticated: selectUserVerifiedEmail(state),
|
||||
userId: userId,
|
||||
shareTelemetry: IS_WEB || selectDaemonSettings(state).share_usage_data,
|
||||
isFloating: makeSelectIsPlayerFloating(props.location)(state),
|
||||
collectionId,
|
||||
nextRecommendedUri,
|
||||
previousListUri,
|
||||
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
|
||||
};
|
||||
};
|
||||
@@ -78,8 +83,19 @@ const perform = (dispatch) => ({
|
||||
toggleVideoTheaterMode: () => dispatch(toggleVideoTheaterMode()),
|
||||
toggleAutoplayNext: () => dispatch(toggleAutoplayNext()),
|
||||
setVideoPlaybackRate: (rate) => dispatch(doSetClientSetting(SETTINGS.VIDEO_PLAYBACK_RATE, rate)),
|
||||
doPlayUri: (uri) => dispatch(doPlayUri(uri)),
|
||||
doSetPlayingUri: (uri, collectionId) => dispatch(doSetPlayingUri({ uri, collectionId })),
|
||||
doPlayUri: (uri, collectionId) =>
|
||||
dispatch(
|
||||
doPlayUri(
|
||||
uri,
|
||||
false,
|
||||
false,
|
||||
(fileInfo) => {
|
||||
dispatch(doAnaltyicsPurchaseEvent(fileInfo));
|
||||
},
|
||||
true
|
||||
),
|
||||
dispatch(doSetPlayingUri({ uri, collectionId }))
|
||||
),
|
||||
});
|
||||
|
||||
export default withRouter(connect(select, perform)(VideoViewer));
|
||||
@@ -1,54 +1,20 @@
|
||||
// Created by xander on 6/21/2021
|
||||
import videojs from 'video.js';
|
||||
import {
|
||||
makeSelectRecommendationId,
|
||||
makeSelectRecommendationParentId,
|
||||
makeSelectRecommendedClaimIds,
|
||||
makeSelectRecommendationClicks,
|
||||
} from 'redux/selectors/content';
|
||||
import { makeSelectRecommendedRecsysIdForClaimId } from 'redux/selectors/search';
|
||||
|
||||
import RecSys from 'recsys';
|
||||
const VERSION = '0.0.1';
|
||||
|
||||
const recsysEndpoint = 'https://clickstream.odysee.com/log/video/view';
|
||||
const recsysId = 'lighthouse-v0';
|
||||
|
||||
/* RecSys */
|
||||
const RecsysData = {
|
||||
const PlayerEvent = {
|
||||
event: {
|
||||
start: 0,
|
||||
start: 0, // event types
|
||||
stop: 1,
|
||||
scrub: 2,
|
||||
speed: 3,
|
||||
},
|
||||
};
|
||||
|
||||
function createRecsys(claimId, userId, events, loadedAt, isEmbed) {
|
||||
const pageLoadedAt = loadedAt;
|
||||
const pageExitedAt = Date.now();
|
||||
|
||||
if (window.store) {
|
||||
const state = window.store.getState();
|
||||
|
||||
return {
|
||||
uuid: makeSelectRecommendationId(claimId)(state),
|
||||
parentUuid: makeSelectRecommendationParentId(claimId)(state),
|
||||
uid: userId,
|
||||
claimId: claimId,
|
||||
pageLoadedAt: pageLoadedAt,
|
||||
pageExitedAt: pageExitedAt,
|
||||
recsysId: makeSelectRecommendedRecsysIdForClaimId(claimId)(state) || recsysId,
|
||||
recClaimIds: makeSelectRecommendedClaimIds(claimId)(state),
|
||||
recClickedVideoIdx: makeSelectRecommendationClicks(claimId)(state),
|
||||
events: events,
|
||||
isEmbed: isEmbed,
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function newRecsysEvent(eventType, offset, arg) {
|
||||
function newRecsysPlayerEvent(eventType, offset, arg) {
|
||||
if (arg) {
|
||||
return {
|
||||
event: eventType,
|
||||
@@ -63,30 +29,11 @@ function newRecsysEvent(eventType, offset, arg) {
|
||||
}
|
||||
}
|
||||
|
||||
function sendRecsysEvents(recsys) {
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'text/plain' }, // application/json
|
||||
body: JSON.stringify(recsys),
|
||||
};
|
||||
|
||||
try {
|
||||
fetch(recsysEndpoint, requestOptions)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
// console.log(`Recsys response data:`, data);
|
||||
});
|
||||
} catch (error) {
|
||||
// console.error(`Recsys Error`, error);
|
||||
}
|
||||
}
|
||||
|
||||
const defaults = {
|
||||
endpoint: recsysEndpoint,
|
||||
recsysId: recsysId,
|
||||
videoId: null,
|
||||
userId: 0,
|
||||
debug: false,
|
||||
embedded: false,
|
||||
};
|
||||
|
||||
const Component = videojs.getComponent('Component');
|
||||
@@ -98,16 +45,13 @@ class RecsysPlugin extends Component {
|
||||
|
||||
// Plugin started
|
||||
if (options.debug) {
|
||||
this.log(`Created recsys plugin for: videoId:${options.videoId}, userId:${options.userId}`);
|
||||
this.log(`Created recsys plugin for: videoId:${options.videoId}`);
|
||||
}
|
||||
|
||||
// To help with debugging, we'll add a global vjs object with the video js player
|
||||
window.vjs = player;
|
||||
|
||||
this.player = player;
|
||||
|
||||
this.recsysEvents = [];
|
||||
this.loadedAt = Date.now();
|
||||
this.lastTimeUpdate = null;
|
||||
this.currentTimeUpdate = null;
|
||||
this.inPause = false;
|
||||
@@ -124,57 +68,37 @@ class RecsysPlugin extends Component {
|
||||
player.on('dispose', (event) => this.onDispose(event));
|
||||
}
|
||||
|
||||
addRecsysEvent(recsysEvent) {
|
||||
// For now, don't do client-side preprocessing. I think there
|
||||
// are browser inconsistencies and preprocessing loses too much info.
|
||||
this.recsysEvents.push(recsysEvent);
|
||||
}
|
||||
|
||||
getRecsysEvents() {
|
||||
return this.recsysEvents;
|
||||
}
|
||||
|
||||
sendRecsysEvents() {
|
||||
const event = createRecsys(
|
||||
this.options_.videoId,
|
||||
this.options_.userId,
|
||||
this.getRecsysEvents(),
|
||||
this.loadedAt,
|
||||
false
|
||||
);
|
||||
|
||||
if (event) {
|
||||
sendRecsysEvents(event);
|
||||
}
|
||||
}
|
||||
|
||||
onPlay(event) {
|
||||
const recsysEvent = newRecsysEvent(RecsysData.event.start, this.player.currentTime());
|
||||
const recsysEvent = newRecsysPlayerEvent(PlayerEvent.event.start, this.player.currentTime());
|
||||
this.log('onPlay', recsysEvent);
|
||||
this.addRecsysEvent(recsysEvent);
|
||||
RecSys.onRecsysPlayerEvent(this.options_.videoId, recsysEvent, this.options_.embedded);
|
||||
|
||||
this.inPause = false;
|
||||
this.lastTimeUpdate = recsysEvent.offset;
|
||||
}
|
||||
|
||||
onPause(event) {
|
||||
const recsysEvent = newRecsysEvent(RecsysData.event.stop, this.player.currentTime());
|
||||
const recsysEvent = newRecsysPlayerEvent(PlayerEvent.event.stop, this.player.currentTime());
|
||||
this.log('onPause', recsysEvent);
|
||||
this.addRecsysEvent(recsysEvent);
|
||||
RecSys.onRecsysPlayerEvent(this.options_.videoId, recsysEvent);
|
||||
|
||||
this.inPause = true;
|
||||
}
|
||||
|
||||
onEnded(event) {
|
||||
const recsysEvent = newRecsysEvent(RecsysData.event.stop, this.player.currentTime());
|
||||
const recsysEvent = newRecsysPlayerEvent(PlayerEvent.event.stop, this.player.currentTime());
|
||||
this.log('onEnded', recsysEvent);
|
||||
this.addRecsysEvent(recsysEvent);
|
||||
RecSys.onRecsysPlayerEvent(this.options_.videoId, recsysEvent);
|
||||
}
|
||||
|
||||
onRateChange(event) {
|
||||
const recsysEvent = newRecsysEvent(RecsysData.event.speed, this.player.currentTime(), this.player.playbackRate());
|
||||
const recsysEvent = newRecsysPlayerEvent(
|
||||
PlayerEvent.event.speed,
|
||||
this.player.currentTime(),
|
||||
this.player.playbackRate()
|
||||
);
|
||||
this.log('onRateChange', recsysEvent);
|
||||
this.addRecsysEvent(recsysEvent);
|
||||
RecSys.onRecsysPlayerEvent(this.options_.videoId, recsysEvent);
|
||||
}
|
||||
|
||||
onTimeUpdate(event) {
|
||||
@@ -212,19 +136,19 @@ class RecsysPlugin extends Component {
|
||||
|
||||
if (fromTime !== curTime) {
|
||||
// This removes duplicates that aren't useful.
|
||||
const recsysEvent = newRecsysEvent(RecsysData.event.scrub, fromTime, curTime);
|
||||
const recsysEvent = newRecsysPlayerEvent(PlayerEvent.event.scrub, fromTime, curTime);
|
||||
this.log('onSeeked', recsysEvent);
|
||||
this.addRecsysEvent(recsysEvent);
|
||||
RecSys.onRecsysPlayerEvent(this.options_.videoId, recsysEvent);
|
||||
}
|
||||
}
|
||||
|
||||
onDispose(event) {
|
||||
this.sendRecsysEvents();
|
||||
RecSys.onPlayerDispose(this.options_.videoId, this.options_.embedded);
|
||||
}
|
||||
|
||||
log(...args) {
|
||||
if (this.options_.debug) {
|
||||
// console.log(`Recsys Debug:`, JSON.stringify(args));
|
||||
console.log(`Recsys Player Debug:`, JSON.stringify(args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
||||
// import { SIMPLE_SITE } from 'config';
|
||||
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';
|
||||
@@ -54,6 +55,7 @@ type Props = {
|
||||
startMuted: boolean,
|
||||
autoplay: boolean,
|
||||
autoplaySetting: boolean,
|
||||
embedded: boolean,
|
||||
toggleVideoTheaterMode: () => void,
|
||||
adUrl: ?string,
|
||||
claimId: ?string,
|
||||
@@ -94,35 +96,6 @@ const VIDEO_JS_OPTIONS = {
|
||||
},
|
||||
};
|
||||
|
||||
const SPACE_BAR_KEYCODE = 32;
|
||||
const SMALL_F_KEYCODE = 70;
|
||||
const SMALL_M_KEYCODE = 77;
|
||||
const SMALL_T_KEYCODE = 84;
|
||||
const ARROW_LEFT_KEYCODE = 37;
|
||||
const ARROW_UP_KEYCODE = 38;
|
||||
const ARROW_RIGHT_KEYCODE = 39;
|
||||
const ARROW_DOWN_KEYCODE = 40;
|
||||
const COMMA_KEYCODE = 188;
|
||||
const PERIOD_KEYCODE = 190;
|
||||
const SMALL_J_KEYCODE = 74;
|
||||
const SMALL_K_KEYCODE = 75;
|
||||
const SMALL_L_KEYCODE = 76;
|
||||
|
||||
const P_KEYCODE = 80;
|
||||
const N_KEYCODE = 78;
|
||||
|
||||
const FULLSCREEN_KEYCODE = SMALL_F_KEYCODE;
|
||||
const MUTE_KEYCODE = SMALL_M_KEYCODE;
|
||||
const THEATER_MODE_KEYCODE = SMALL_T_KEYCODE;
|
||||
|
||||
const VOLUME_UP_KEYCODE = ARROW_UP_KEYCODE;
|
||||
const VOLUME_DOWN_KEYCODE = ARROW_DOWN_KEYCODE;
|
||||
|
||||
const SEEK_FORWARD_KEYCODE = SMALL_L_KEYCODE;
|
||||
const SEEK_BACKWARD_KEYCODE = SMALL_J_KEYCODE;
|
||||
const SEEK_FORWARD_KEYCODE_5 = ARROW_RIGHT_KEYCODE;
|
||||
const SEEK_BACKWARD_KEYCODE_5 = ARROW_LEFT_KEYCODE;
|
||||
|
||||
const SEEK_STEP_5 = 5;
|
||||
const SEEK_STEP = 10; // time to seek in seconds
|
||||
|
||||
@@ -194,6 +167,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
const {
|
||||
autoplay,
|
||||
autoplaySetting,
|
||||
embedded,
|
||||
startMuted,
|
||||
source,
|
||||
sourceType,
|
||||
@@ -307,49 +281,54 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
// 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) {
|
||||
try {
|
||||
const controlBar = player.getChild('controlBar');
|
||||
const ctrlBar = player.getChild('controlBar');
|
||||
switch (e.type) {
|
||||
case 'play':
|
||||
controlBar.getChild('PlayToggle').controlText(__('Pause (space)'));
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Pause (space)'));
|
||||
break;
|
||||
case 'pause':
|
||||
controlBar.getChild('PlayToggle').controlText(__('Play (space)'));
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Play (space)'));
|
||||
break;
|
||||
case 'volumechange':
|
||||
controlBar
|
||||
ctrlBar
|
||||
.getChild('VolumePanel')
|
||||
.getChild('MuteToggle')
|
||||
.controlText(player.muted() || player.volume() === 0 ? __('Unmute (m)') : __('Mute (m)'));
|
||||
break;
|
||||
case 'fullscreenchange':
|
||||
controlBar
|
||||
.getChild('FullscreenToggle')
|
||||
.controlText(player.isFullscreen() ? __('Exit Fullscreen (f)') : __('Fullscreen (f)'));
|
||||
setLabel(
|
||||
ctrlBar,
|
||||
'FullscreenToggle',
|
||||
player.isFullscreen() ? __('Exit Fullscreen (f)') : __('Fullscreen (f)')
|
||||
);
|
||||
break;
|
||||
case 'loadstart':
|
||||
// --- Do everything ---
|
||||
controlBar.getChild('PlaybackRateMenuButton').controlText(__('Playback Rate (<, >)'));
|
||||
controlBar.getChild('QualityButton').controlText(__('Quality'));
|
||||
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' });
|
||||
controlBar
|
||||
.getChild('TheaterModeButton')
|
||||
.controlText(videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||
controlBar.getChild('PlayNextButton').controlText(__('Play Next (SHIFT+N)'));
|
||||
controlBar.getChild('PlayPreviousButton').controlText(__('Play Previous (SHIFT+P)'));
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw Error('Unexpected: ' + e.type);
|
||||
break;
|
||||
}
|
||||
} catch {
|
||||
// Just fail silently. It'll just be due to hidden ctrls, and if it is
|
||||
// due to control hierarchy change, we'll notice that in the GUI.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,24 +380,24 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
|
||||
function handleShiftKeyActions(e: KeyboardEvent) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || !e.shiftKey) return;
|
||||
if (e.keyCode === PERIOD_KEYCODE) changePlaybackSpeed(true);
|
||||
if (e.keyCode === COMMA_KEYCODE) changePlaybackSpeed(false);
|
||||
if (e.keyCode === N_KEYCODE) playNext();
|
||||
if (e.keyCode === P_KEYCODE) playPrevious();
|
||||
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 === SPACE_BAR_KEYCODE || e.keyCode === SMALL_K_KEYCODE) togglePlay();
|
||||
if (e.keyCode === FULLSCREEN_KEYCODE) toggleFullscreen();
|
||||
if (e.keyCode === MUTE_KEYCODE) toggleMute();
|
||||
if (e.keyCode === VOLUME_UP_KEYCODE) volumeUp();
|
||||
if (e.keyCode === VOLUME_DOWN_KEYCODE) volumeDown();
|
||||
if (e.keyCode === THEATER_MODE_KEYCODE) toggleTheaterMode();
|
||||
if (e.keyCode === SEEK_FORWARD_KEYCODE) seekVideo(SEEK_STEP);
|
||||
if (e.keyCode === SEEK_BACKWARD_KEYCODE) seekVideo(-SEEK_STEP);
|
||||
if (e.keyCode === SEEK_FORWARD_KEYCODE_5) seekVideo(SEEK_STEP_5);
|
||||
if (e.keyCode === SEEK_BACKWARD_KEYCODE_5) seekVideo(-SEEK_STEP_5);
|
||||
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) {
|
||||
@@ -590,6 +569,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
player.recsys({
|
||||
videoId: claimId,
|
||||
userId: userId,
|
||||
embedded: embedded,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -645,7 +625,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
const autoplayButton = controlBar.getChild('AutoplayNextButton');
|
||||
|
||||
if (autoplayButton) {
|
||||
const title = autoplaySetting ? 'Autoplay Next On' : 'Autoplay Next Off';
|
||||
const title = autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off');
|
||||
|
||||
autoplayButton.controlText(title);
|
||||
autoplayButton.setAttribute('aria-label', title);
|
||||
|
||||
@@ -25,8 +25,7 @@ import I18nMessage from 'component/i18nMessage';
|
||||
import { useHistory } from 'react-router';
|
||||
import { getAllIds } from 'util/buildHomepage';
|
||||
import type { HomepageCat } from 'util/buildHomepage';
|
||||
import { formatLbryUrlForWeb } from 'util/url';
|
||||
import { COLLECTIONS_CONSTS } from 'lbry-redux';
|
||||
import { formatLbryUrlForWeb, generateListSearchUrlParams } from 'util/url';
|
||||
|
||||
const PLAY_TIMEOUT_ERROR = 'play_timeout_error';
|
||||
const PLAY_TIMEOUT_LIMIT = 2000;
|
||||
@@ -43,7 +42,6 @@ type Props = {
|
||||
videoPlaybackRate: number,
|
||||
volume: number,
|
||||
uri: string,
|
||||
autoplayMedia: boolean,
|
||||
autoplayNext: boolean,
|
||||
autoplayIfEmbedded: boolean,
|
||||
desktopPlayStartTime?: number,
|
||||
@@ -60,12 +58,13 @@ type Props = {
|
||||
homepageData?: { [string]: HomepageCat },
|
||||
shareTelemetry: boolean,
|
||||
isFloating: boolean,
|
||||
doPlayUri: (string) => void,
|
||||
doSetPlayingUri: (string, string) => void,
|
||||
doPlayUri: (string, string) => void,
|
||||
collectionId: string,
|
||||
nextRecommendedUri: string,
|
||||
previousListUri: string,
|
||||
videoTheaterMode: boolean,
|
||||
isMarkdownOrComment: boolean,
|
||||
preferEmbed: boolean,
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -86,7 +85,6 @@ function VideoViewer(props: Props) {
|
||||
uri,
|
||||
muted,
|
||||
volume,
|
||||
autoplayMedia,
|
||||
autoplayNext,
|
||||
autoplayIfEmbedded,
|
||||
doAnalyticsView,
|
||||
@@ -104,11 +102,12 @@ function VideoViewer(props: Props) {
|
||||
shareTelemetry,
|
||||
isFloating,
|
||||
doPlayUri,
|
||||
doSetPlayingUri,
|
||||
collectionId,
|
||||
nextRecommendedUri,
|
||||
previousListUri,
|
||||
videoTheaterMode,
|
||||
isMarkdownOrComment,
|
||||
preferEmbed,
|
||||
} = props;
|
||||
const permanentUrl = claim && claim.permanent_url;
|
||||
const adApprovedChannelIds = homepageData ? getAllIds(homepageData) : [];
|
||||
@@ -125,7 +124,7 @@ function VideoViewer(props: Props) {
|
||||
const [isPlaying, setIsPlaying] = useState(false);
|
||||
const [ended, setEnded] = useState(false);
|
||||
const [showAutoplayCountdown, setShowAutoplayCountdown] = useState(false);
|
||||
const [isEndededEmbed, setIsEndededEmbed] = useState(false);
|
||||
const [isEndedEmbed, setIsEndedEmbed] = useState(false);
|
||||
const vjsCallbackDataRef: any = React.useRef();
|
||||
const previousUri = usePrevious(uri);
|
||||
const embedded = useContext(EmbedContext);
|
||||
@@ -142,7 +141,7 @@ function VideoViewer(props: Props) {
|
||||
useEffect(() => {
|
||||
if (uri && previousUri && uri !== previousUri) {
|
||||
setShowAutoplayCountdown(false);
|
||||
setIsEndededEmbed(false);
|
||||
setIsEndedEmbed(false);
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, [uri, previousUri]);
|
||||
@@ -183,88 +182,88 @@ function VideoViewer(props: Props) {
|
||||
|
||||
const doPlay = useCallback(
|
||||
(playUri) => {
|
||||
let navigateUrl = formatLbryUrlForWeb(playUri);
|
||||
if (collectionId) {
|
||||
const collectionParams = new URLSearchParams();
|
||||
collectionParams.set(COLLECTIONS_CONSTS.COLLECTION_ID, collectionId);
|
||||
navigateUrl = navigateUrl + `?` + collectionParams.toString();
|
||||
clearPosition(playUri);
|
||||
}
|
||||
if (!isFloating) {
|
||||
push(navigateUrl);
|
||||
}
|
||||
doPlayUri(playUri);
|
||||
doSetPlayingUri(playUri, collectionId);
|
||||
setDoNavigate(false);
|
||||
if (!isFloating) {
|
||||
const navigateUrl = formatLbryUrlForWeb(playUri);
|
||||
push({
|
||||
pathname: navigateUrl,
|
||||
search: collectionId && generateListSearchUrlParams(collectionId),
|
||||
state: { collectionId, forceAutoplay: true, hideFloatingPlayer: true },
|
||||
});
|
||||
} else {
|
||||
doPlayUri(playUri, collectionId);
|
||||
}
|
||||
},
|
||||
[clearPosition, collectionId, doPlayUri, doSetPlayingUri, isFloating, push]
|
||||
[collectionId, doPlayUri, isFloating, push]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (doNavigate) {
|
||||
if (playNextUrl) {
|
||||
if (permanentUrl !== nextRecommendedUri) {
|
||||
if (nextRecommendedUri) doPlay(nextRecommendedUri);
|
||||
} else {
|
||||
setReplay(true);
|
||||
if (!doNavigate) return;
|
||||
|
||||
if (playNextUrl) {
|
||||
if (permanentUrl !== nextRecommendedUri) {
|
||||
if (nextRecommendedUri) {
|
||||
if (collectionId) clearPosition(permanentUrl);
|
||||
doPlay(nextRecommendedUri);
|
||||
}
|
||||
} else {
|
||||
if (videoNode) {
|
||||
const currentTime = videoNode.currentTime;
|
||||
setReplay(true);
|
||||
}
|
||||
} else {
|
||||
if (videoNode) {
|
||||
const currentTime = videoNode.currentTime;
|
||||
|
||||
if (currentTime <= 5) {
|
||||
if (previousListUri && permanentUrl !== previousListUri) doPlay(previousListUri);
|
||||
} else {
|
||||
videoNode.currentTime = 0;
|
||||
}
|
||||
setDoNavigate(false);
|
||||
if (currentTime <= 5) {
|
||||
if (previousListUri && permanentUrl !== previousListUri) doPlay(previousListUri);
|
||||
} else {
|
||||
videoNode.currentTime = 0;
|
||||
}
|
||||
setDoNavigate(false);
|
||||
}
|
||||
if (!ended) setDoNavigate(false);
|
||||
setEnded(false);
|
||||
setPlayNextUrl(true);
|
||||
}
|
||||
}, [doNavigate, doPlay, ended, nextRecommendedUri, permanentUrl, playNextUrl, previousListUri, videoNode]);
|
||||
if (!ended) setDoNavigate(false);
|
||||
setEnded(false);
|
||||
setPlayNextUrl(true);
|
||||
}, [
|
||||
clearPosition,
|
||||
collectionId,
|
||||
doNavigate,
|
||||
doPlay,
|
||||
ended,
|
||||
nextRecommendedUri,
|
||||
permanentUrl,
|
||||
playNextUrl,
|
||||
previousListUri,
|
||||
videoNode,
|
||||
]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (ended) {
|
||||
analytics.videoIsPlaying(false);
|
||||
if (!ended) return;
|
||||
|
||||
if (adUrl) {
|
||||
setAdUrl(null);
|
||||
return;
|
||||
}
|
||||
analytics.videoIsPlaying(false);
|
||||
|
||||
if (embedded) {
|
||||
setIsEndededEmbed(true);
|
||||
} else if (!collectionId && autoplayNext) {
|
||||
setShowAutoplayCountdown(true);
|
||||
} else if (collectionId) {
|
||||
setDoNavigate(true);
|
||||
}
|
||||
|
||||
clearPosition(uri);
|
||||
if (adUrl) {
|
||||
setAdUrl(null);
|
||||
return;
|
||||
}
|
||||
}, [
|
||||
embedded,
|
||||
setIsEndededEmbed,
|
||||
autoplayMedia,
|
||||
setShowAutoplayCountdown,
|
||||
adUrl,
|
||||
setAdUrl,
|
||||
clearPosition,
|
||||
uri,
|
||||
ended,
|
||||
collectionId,
|
||||
autoplayNext,
|
||||
]);
|
||||
|
||||
if (embedded) {
|
||||
setIsEndedEmbed(true);
|
||||
} else if (!collectionId && autoplayNext) {
|
||||
setShowAutoplayCountdown(true);
|
||||
} else if (collectionId) {
|
||||
setDoNavigate(true);
|
||||
}
|
||||
|
||||
clearPosition(uri);
|
||||
}, [adUrl, autoplayNext, clearPosition, collectionId, embedded, ended, setAdUrl, uri]);
|
||||
|
||||
function onPlay(player) {
|
||||
setEnded(false);
|
||||
setIsLoading(false);
|
||||
setIsPlaying(true);
|
||||
setShowAutoplayCountdown(false);
|
||||
setIsEndededEmbed(false);
|
||||
setIsEndedEmbed(false);
|
||||
setReplay(false);
|
||||
setDoNavigate(false);
|
||||
analytics.videoIsPlaying(true, player);
|
||||
@@ -298,12 +297,12 @@ function VideoViewer(props: Props) {
|
||||
|
||||
const doPlayNext = () => {
|
||||
setPlayNextUrl(true);
|
||||
setDoNavigate(true);
|
||||
setEnded(true);
|
||||
};
|
||||
|
||||
const doPlayPrevious = () => {
|
||||
setPlayNextUrl(false);
|
||||
setDoNavigate(true);
|
||||
setEnded(true);
|
||||
};
|
||||
|
||||
const onPlayerReady = useCallback((player: Player, videoNode: any) => {
|
||||
@@ -312,12 +311,14 @@ function VideoViewer(props: Props) {
|
||||
player.muted(muted);
|
||||
player.volume(volume);
|
||||
player.playbackRate(videoPlaybackRate);
|
||||
addTheaterModeButton(player, toggleVideoTheaterMode);
|
||||
if (collectionId) {
|
||||
addPlayNextButton(player, doPlayNext);
|
||||
addPlayPreviousButton(player, doPlayPrevious);
|
||||
} else {
|
||||
addAutoplayNextButton(player, toggleAutoplayNext, autoplayNext);
|
||||
if (!isMarkdownOrComment) {
|
||||
addTheaterModeButton(player, toggleVideoTheaterMode);
|
||||
if (collectionId) {
|
||||
addPlayNextButton(player, doPlayNext);
|
||||
addPlayPreviousButton(player, doPlayPrevious);
|
||||
} else {
|
||||
addAutoplayNextButton(player, toggleAutoplayNext, autoplayNext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +355,9 @@ function VideoViewer(props: Props) {
|
||||
|
||||
// first play tracking, used for initializing the watchman api
|
||||
player.on('tracking:firstplay', doTrackingFirstPlay);
|
||||
player.on('ended', () => setEnded(true));
|
||||
player.on('ended', () => {
|
||||
if (!preferEmbed) setEnded(true);
|
||||
});
|
||||
player.on('play', onPlay);
|
||||
player.on('pause', (event) => onPause(event, player));
|
||||
player.on('dispose', (event) => onDispose(event, player));
|
||||
@@ -391,20 +394,19 @@ function VideoViewer(props: Props) {
|
||||
<div
|
||||
className={classnames('file-viewer', {
|
||||
'file-viewer--is-playing': isPlaying,
|
||||
'file-viewer--ended-embed': isEndededEmbed,
|
||||
'file-viewer--ended-embed': isEndedEmbed,
|
||||
})}
|
||||
onContextMenu={stopContextMenu}
|
||||
>
|
||||
{showAutoplayCountdown && (
|
||||
<AutoplayCountdown
|
||||
uri={uri}
|
||||
nextRecommendedUri={nextRecommendedUri}
|
||||
doNavigate={() => setDoNavigate(true)}
|
||||
doReplay={() => setReplay(true)}
|
||||
/>
|
||||
)}
|
||||
{isEndededEmbed && <FileViewerEmbeddedEnded uri={uri} />}
|
||||
{embedded && !isEndededEmbed && <FileViewerEmbeddedTitle uri={uri} />}
|
||||
{isEndedEmbed && <FileViewerEmbeddedEnded uri={uri} />}
|
||||
{embedded && !isEndedEmbed && <FileViewerEmbeddedTitle uri={uri} />}
|
||||
{/* disable this loading behavior because it breaks when player.play() promise hangs */}
|
||||
{isLoading && <LoadingScreen status={__('Loading')} />}
|
||||
|
||||
@@ -458,6 +460,7 @@ function VideoViewer(props: Props) {
|
||||
videoTheaterMode={videoTheaterMode}
|
||||
playNext={doPlayNext}
|
||||
playPrevious={doPlayPrevious}
|
||||
embedded={embedded}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -22,6 +22,8 @@ const DEFAULT_TIP_AMOUNTS = [1, 5, 25, 100];
|
||||
const MINIMUM_FIAT_TIP = 1;
|
||||
const MAXIMUM_FIAT_TIP = 1000;
|
||||
|
||||
const DEFAULT_TIP_ERROR = __('Sorry, there was an error in processing your payment!');
|
||||
|
||||
const TAB_BOOST = 'TabBoost';
|
||||
const TAB_FIAT = 'TabFiat';
|
||||
const TAB_LBC = 'TabLBC';
|
||||
@@ -64,20 +66,48 @@ function WalletSendTip(props: Props) {
|
||||
doToast,
|
||||
isAuthenticated,
|
||||
} = props;
|
||||
|
||||
/** REACT STATE **/
|
||||
const [presetTipAmount, setPresetTipAmount] = usePersistedState('comment-support:presetTip', DEFAULT_TIP_AMOUNTS[0]);
|
||||
const [customTipAmount, setCustomTipAmount] = usePersistedState('comment-support:customTip', 1.0);
|
||||
const [useCustomTip, setUseCustomTip] = usePersistedState('comment-support:useCustomTip', false);
|
||||
const [tipError, setTipError] = React.useState();
|
||||
const [isConfirming, setIsConfirming] = React.useState(false);
|
||||
|
||||
// only allow certain creators to receive tips
|
||||
const [canReceiveFiatTip, setCanReceiveFiatTip] = React.useState(); // dont persist because it needs to be calc'd per creator
|
||||
|
||||
// show things conditionally based on if a user has a card already
|
||||
const [hasCardSaved, setHasSavedCard] = usePersistedState('comment-support:hasCardSaved', false);
|
||||
|
||||
// show the tip error on the frontend
|
||||
const [tipError, setTipError] = React.useState();
|
||||
|
||||
// denote which tab to show on the frontend
|
||||
const [activeTab, setActiveTab] = usePersistedState(TAB_BOOST);
|
||||
|
||||
// handle default active tab
|
||||
React.useEffect(() => {
|
||||
// force to boost tab if it's someone's own upload
|
||||
if (claimIsMine) {
|
||||
setActiveTab(TAB_BOOST);
|
||||
} else {
|
||||
// or set LBC tip as the default if none is set yet
|
||||
if (!activeTab || activeTab === 'undefined') {
|
||||
setActiveTab(TAB_LBC);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
// alphanumeric claim id
|
||||
const { claim_id: claimId } = claim;
|
||||
|
||||
// channel name used in url
|
||||
const { channelName } = parseURI(uri);
|
||||
|
||||
const activeChannelName = activeChannelClaim && activeChannelClaim.name;
|
||||
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
|
||||
|
||||
const [canReceiveFiatTip, setCanReceiveFiatTip] = React.useState(); // dont persist because it needs to be calc'd per creator
|
||||
const [hasCardSaved, setHasSavedCard] = usePersistedState('comment-support:hasCardSaved', false);
|
||||
|
||||
// setup variables for tip API
|
||||
// setup variables for backend tip API
|
||||
let channelClaimId, tipChannelName;
|
||||
// if there is a signing channel it's on a file
|
||||
if (claim.signing_channel) {
|
||||
@@ -114,7 +144,7 @@ function WalletSendTip(props: Props) {
|
||||
}
|
||||
}, [channelClaimId, isAuthenticated, stripeEnvironment]);
|
||||
|
||||
// check if creator has an account saved
|
||||
// focus tip element if it exists
|
||||
React.useEffect(() => {
|
||||
const tipInputElement = document.getElementById('tip-input');
|
||||
if (tipInputElement) {
|
||||
@@ -122,6 +152,7 @@ function WalletSendTip(props: Props) {
|
||||
}
|
||||
}, []);
|
||||
|
||||
// check if user can receive tips
|
||||
React.useEffect(() => {
|
||||
if (channelClaimId && stripeEnvironment) {
|
||||
Lbryio.call(
|
||||
@@ -147,11 +178,13 @@ function WalletSendTip(props: Props) {
|
||||
}
|
||||
}, [channelClaimId, stripeEnvironment]);
|
||||
|
||||
// if user has no balance, used to show conditional frontend
|
||||
const noBalance = balance === 0;
|
||||
|
||||
// the tip amount, based on if a preset or custom tip amount is being used
|
||||
const tipAmount = useCustomTip ? customTipAmount : presetTipAmount;
|
||||
|
||||
const [activeTab, setActiveTab] = usePersistedState(TAB_BOOST);
|
||||
|
||||
// get type of claim (stream/channel/repost/collection) for display on frontend
|
||||
function getClaimTypeText() {
|
||||
if (claim.value_type === 'stream') {
|
||||
return __('Content');
|
||||
@@ -167,6 +200,7 @@ function WalletSendTip(props: Props) {
|
||||
}
|
||||
const claimTypeText = getClaimTypeText();
|
||||
|
||||
// icon to use or explainer text to show per tab
|
||||
let iconToUse;
|
||||
let explainerText = '';
|
||||
if (activeTab === TAB_BOOST) {
|
||||
@@ -231,7 +265,7 @@ function WalletSendTip(props: Props) {
|
||||
setTipError(tipError);
|
||||
}, [tipAmount, balance, setTipError, activeTab]);
|
||||
|
||||
//
|
||||
// make call to the backend to send lbc or fiat
|
||||
function sendSupportOrConfirm(instantTipMaxAmount = null) {
|
||||
// send a tip
|
||||
if (!isConfirming && (!instantTipMaxAmount || !instantTipEnabled || tipAmount > instantTipMaxAmount)) {
|
||||
@@ -271,6 +305,7 @@ function WalletSendTip(props: Props) {
|
||||
} else if (isConfirming) {
|
||||
let sendAnonymously = !activeChannelClaim || incognito;
|
||||
|
||||
// hit backend to send tip
|
||||
Lbryio.call(
|
||||
'customer',
|
||||
'tip',
|
||||
@@ -297,10 +332,12 @@ function WalletSendTip(props: Props) {
|
||||
});
|
||||
})
|
||||
.catch(function (error) {
|
||||
let displayError = 'Sorry, there was an error in processing your payment!';
|
||||
|
||||
if (error.message !== 'payment intent failed to confirm') {
|
||||
// show error message from Stripe if one exists (being passed from backend by Beamer's API currently)
|
||||
let displayError;
|
||||
if (error.message) {
|
||||
displayError = error.message;
|
||||
} else {
|
||||
displayError = DEFAULT_TIP_ERROR;
|
||||
}
|
||||
|
||||
doToast({ message: displayError, isError: true });
|
||||
@@ -385,6 +422,7 @@ function WalletSendTip(props: Props) {
|
||||
// if it's a valid number display it, otherwise do an empty string
|
||||
const displayAmount = !isNan(tipAmount) ? amountToShow : '';
|
||||
|
||||
// build button text based on tab
|
||||
if (activeTab === TAB_BOOST) {
|
||||
return claimIsMine
|
||||
? __('Boost Your %claimTypeText%', { claimTypeText })
|
||||
@@ -396,12 +434,14 @@ function WalletSendTip(props: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
// dont allow user to click send button
|
||||
function shouldDisableAmountSelector(amount) {
|
||||
return (
|
||||
(amount > balance && activeTab !== TAB_FIAT) || (activeTab === TAB_FIAT && (!hasCardSaved || !canReceiveFiatTip))
|
||||
);
|
||||
}
|
||||
|
||||
// showed on confirm page above amount
|
||||
function setConfirmLabel() {
|
||||
if (activeTab === TAB_LBC) {
|
||||
return __('Tipping Credit');
|
||||
@@ -530,6 +570,7 @@ function WalletSendTip(props: Props) {
|
||||
<ChannelSelector />
|
||||
</div>
|
||||
|
||||
{/* prompt to save a card */}
|
||||
{activeTab === TAB_FIAT && !hasCardSaved && (
|
||||
<h3 className="add-card-prompt">
|
||||
<Button navigate={`/$/${PAGES.SETTINGS_STRIPE_CARD}`} label={__('Add a Card')} button="link" />{' '}
|
||||
|
||||
@@ -64,7 +64,11 @@ export default function WunderBarSuggestions(props: Props) {
|
||||
customSelectAction,
|
||||
} = props;
|
||||
const inputRef: ElementRef<any> = React.useRef();
|
||||
const isFocused = inputRef && inputRef.current && inputRef.current === document.activeElement;
|
||||
const viewResultsRef: ElementRef<any> = React.useRef();
|
||||
const exploreTagRef: ElementRef<any> = React.useRef();
|
||||
|
||||
const isRefFocused = (ref) => ref && ref.current && ref.current === document.activeElement;
|
||||
const isFocused = isRefFocused(inputRef) || isRefFocused(viewResultsRef) || isRefFocused(exploreTagRef);
|
||||
|
||||
const {
|
||||
push,
|
||||
@@ -321,6 +325,22 @@ export default function WunderBarSuggestions(props: Props) {
|
||||
className={classnames('wunderbar__suggestions', { 'wunderbar__suggestions--mobile': isMobile })}
|
||||
>
|
||||
<ComboboxList>
|
||||
{!noBottomLinks && (
|
||||
<div className="wunderbar__bottom-links">
|
||||
<ComboboxOption value={term} className="wunderbar__more-results">
|
||||
<Button ref={viewResultsRef} button="link" label={__('View All Results')} />
|
||||
</ComboboxOption>
|
||||
<ComboboxOption value={`${TAG_SEARCH_PREFIX}${term}`} className="wunderbar__more-results">
|
||||
<Button ref={exploreTagRef} className="wunderbar__tag-search" button="link">
|
||||
{__('Explore')}
|
||||
<div className="tag">{term.split(' ').join('')}</div>
|
||||
</Button>
|
||||
</ComboboxOption>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<hr className="wunderbar__top-separator" />
|
||||
|
||||
{uriFromQueryIsValid && !noTopSuggestion ? <WunderbarTopSuggestion query={nameFromQuery} /> : null}
|
||||
|
||||
<div className="wunderbar__label">{__('Search Results')}</div>
|
||||
@@ -330,20 +350,6 @@ export default function WunderBarSuggestions(props: Props) {
|
||||
{!showPlaceholder && results
|
||||
? results.slice(0, isMobile ? 20 : 5).map((uri) => <WunderbarSuggestion key={uri} uri={uri} />)
|
||||
: null}
|
||||
|
||||
{!noBottomLinks && (
|
||||
<div className="wunderbar__bottom-links">
|
||||
<ComboboxOption value={term} className="wunderbar__more-results">
|
||||
<Button button="link" label={__('View All Results')} />
|
||||
</ComboboxOption>
|
||||
<ComboboxOption value={`${TAG_SEARCH_PREFIX}${term}`} className="wunderbar__more-results">
|
||||
<Button className="wunderbar__tag-search" button="link">
|
||||
{__('Explore')}
|
||||
<div className="tag">{term.split(' ').join('')}</div>
|
||||
</Button>
|
||||
</ComboboxOption>
|
||||
</div>
|
||||
)}
|
||||
</ComboboxList>
|
||||
</ComboboxPopover>
|
||||
)}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doResolveUris, makeSelectClaimForUri, makeSelectIsUriResolving, parseURI } from 'lbry-redux';
|
||||
import {
|
||||
doResolveUris,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectIsUriResolving,
|
||||
makeSelectTagInClaimOrChannelForUri,
|
||||
parseURI,
|
||||
} from 'lbry-redux';
|
||||
import { makeSelectWinningUriForQuery } from 'redux/selectors/search';
|
||||
import WunderbarTopSuggestion from './view';
|
||||
import { PREFERENCE_EMBED } from 'constants/tags';
|
||||
|
||||
const select = (state, props) => {
|
||||
const uriFromQuery = `lbry://${props.query}`;
|
||||
@@ -16,11 +23,12 @@ const select = (state, props) => {
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
const resolvingUris = uris.some(uri => makeSelectIsUriResolving(uri)(state));
|
||||
const resolvingUris = uris.some((uri) => makeSelectIsUriResolving(uri)(state));
|
||||
const winningUri = makeSelectWinningUriForQuery(props.query)(state);
|
||||
const winningClaim = winningUri ? makeSelectClaimForUri(winningUri)(state) : undefined;
|
||||
const preferEmbed = makeSelectTagInClaimOrChannelForUri(winningUri, PREFERENCE_EMBED)(state);
|
||||
|
||||
return { resolvingUris, winningUri, winningClaim, uris };
|
||||
return { resolvingUris, winningUri, winningClaim, uris, preferEmbed };
|
||||
};
|
||||
|
||||
export default connect(select, {
|
||||
|
||||
@@ -8,10 +8,11 @@ type Props = {
|
||||
doResolveUris: (Array<string>) => void,
|
||||
uris: Array<string>,
|
||||
resolvingUris: boolean,
|
||||
preferEmbed: boolean,
|
||||
};
|
||||
|
||||
export default function WunderbarTopSuggestion(props: Props) {
|
||||
const { uris, resolvingUris, winningUri, doResolveUris } = props;
|
||||
const { uris, resolvingUris, winningUri, doResolveUris, preferEmbed } = props;
|
||||
|
||||
const stringifiedUris = JSON.stringify(uris);
|
||||
React.useEffect(() => {
|
||||
@@ -38,7 +39,7 @@ export default function WunderbarTopSuggestion(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
if (!winningUri) {
|
||||
if (!winningUri || preferEmbed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
export const PAGE_SIZE = 20;
|
||||
|
||||
export const FRESH_KEY = 'fresh';
|
||||
export const ORDER_BY_KEY = 'order';
|
||||
export const ORDER_BY_KEY = 'order'; // Trending, Top, New
|
||||
export const SORT_BY_KEY = 'sort'; // Newest vs Oldest First
|
||||
export const DURATION_KEY = 'duration';
|
||||
export const LANGUAGE_KEY = 'language';
|
||||
export const TAGS_KEY = 't';
|
||||
@@ -39,6 +40,14 @@ export const DURATION_LONG = 'long';
|
||||
export const DURATION_ALL = 'all';
|
||||
export const DURATION_TYPES = [DURATION_ALL, DURATION_SHORT, DURATION_LONG];
|
||||
|
||||
export const SORT_BY = {
|
||||
// key: Enumeration; can be anything as long as unique. Also used as URLParam.
|
||||
// opt: Value to use for 'claim_search' options; for this case, it is the prefix to 'order_by'.
|
||||
// str: Customer-facing string representation.
|
||||
NEWEST: { key: 'new', opt: '', str: 'Newest first' },
|
||||
OLDEST: { key: 'old', opt: '^', str: 'Oldest first' },
|
||||
};
|
||||
|
||||
export const FILE_VIDEO = 'video';
|
||||
export const FILE_AUDIO = 'audio';
|
||||
export const FILE_DOCUMENT = 'document';
|
||||
|
||||
@@ -45,6 +45,7 @@ export const WEB = 'Globe';
|
||||
export const SHARE = 'Share2';
|
||||
export const EXTERNAL = 'ExternalLink';
|
||||
export const PLAY = 'Play';
|
||||
export const PLAY_PREVIOUS = 'Play Previous';
|
||||
export const FACEBOOK = 'Facebook';
|
||||
export const TWITTER = 'Twitter';
|
||||
export const TELEGRAM = 'Telegram';
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
export const BACKSPACE = 8;
|
||||
export const TAB = 9;
|
||||
export const ENTER = 13;
|
||||
export const SHIFT = 16;
|
||||
export const CTRL = 17;
|
||||
export const ALT = 18;
|
||||
export const PAUSE = 19;
|
||||
export const CAPS_LOCK = 20;
|
||||
export const ESCAPE = 27;
|
||||
export const SPACEBAR = 32;
|
||||
export const PG_UP = 33;
|
||||
export const PG_DN = 34;
|
||||
export const END = 35;
|
||||
export const HOME = 36;
|
||||
export const LEFT = 37;
|
||||
export const UP = 38;
|
||||
export const RIGHT = 39;
|
||||
export const DOWN = 40;
|
||||
export const INSERT = 45;
|
||||
export const DELETE = 46;
|
||||
export const COMMAND = 91;
|
||||
export const COMMAND_LEFT = 91;
|
||||
export const COMMAND_RIGHT = 93;
|
||||
export const NUMPAD_MULTIPLY = 106;
|
||||
export const NUMPAD_PLUS = 107;
|
||||
export const NUMPAD_MINUS = 109;
|
||||
export const NUMPAD_DOT = 110;
|
||||
export const NUMPAD_SLASH = 111;
|
||||
export const NUM_LOCK = 144;
|
||||
export const SCROLL_LOCK = 145;
|
||||
export const BACKSLASH = 220;
|
||||
export const PERIOD = 190;
|
||||
export const COMMA = 188;
|
||||
export const A = 65;
|
||||
export const B = 66;
|
||||
export const C = 67;
|
||||
export const D = 68;
|
||||
export const E = 69;
|
||||
export const F = 70;
|
||||
export const G = 71;
|
||||
export const H = 72;
|
||||
export const I = 73;
|
||||
export const J = 74;
|
||||
export const K = 75;
|
||||
export const L = 76;
|
||||
export const M = 77;
|
||||
export const N = 78;
|
||||
export const O = 79;
|
||||
export const P = 80;
|
||||
export const Q = 81;
|
||||
export const R = 82;
|
||||
export const S = 83;
|
||||
export const T = 84;
|
||||
export const U = 85;
|
||||
export const V = 86;
|
||||
export const W = 87;
|
||||
export const X = 88;
|
||||
export const Y = 89;
|
||||
export const Z = 90;
|
||||
@@ -43,6 +43,7 @@ export const IMAGE_UPLOAD = 'image_upload';
|
||||
export const MOBILE_SEARCH = 'mobile_search';
|
||||
export const VIEW_IMAGE = 'view_image';
|
||||
export const CONFIRM_REMOVE_BTC_SWAP_ADDRESS = 'confirm_remove_btc_swap_address';
|
||||
export const BLOCK_CHANNEL = 'block_channel';
|
||||
export const COLLECTION_ADD = 'collection_add';
|
||||
export const COLLECTION_DELETE = 'collection_delete';
|
||||
export const CONFIRM_REMOVE_CARD = 'CONFIRM_REMOVE_CARD';
|
||||
|
||||
@@ -13,9 +13,11 @@ export const SEARCH_TYPES = {
|
||||
export const SEARCH_OPTIONS = {
|
||||
RESULT_COUNT: 'size',
|
||||
CLAIM_TYPE: 'claimType',
|
||||
RELATED_TO: 'related_to',
|
||||
INCLUDE_FILES: 'file',
|
||||
INCLUDE_CHANNELS: 'channel',
|
||||
INCLUDE_FILES_AND_CHANNELS: 'file,channel',
|
||||
INCLUDE_MATURE: 'nsfw',
|
||||
MEDIA_AUDIO: 'audio',
|
||||
MEDIA_VIDEO: 'video',
|
||||
MEDIA_TEXT: 'text',
|
||||
@@ -25,6 +27,7 @@ export const SEARCH_OPTIONS = {
|
||||
SORT_ACCENDING: '^release_time',
|
||||
SORT_DESCENDING: 'release_time',
|
||||
EXACT: 'exact',
|
||||
PRICE_FILTER_FREE: 'free_only',
|
||||
TIME_FILTER: 'time_filter',
|
||||
TIME_FILTER_LAST_HOUR: 'lasthour',
|
||||
TIME_FILTER_TODAY: 'today',
|
||||
|
||||
@@ -15,7 +15,7 @@ export const THEMES = 'themes';
|
||||
export const AUTOMATIC_DARK_MODE_ENABLED = 'automatic_dark_mode_enabled';
|
||||
export const CLOCK_24H = 'clock_24h';
|
||||
export const AUTOPLAY_MEDIA = 'autoplay';
|
||||
export const AUTOPLAY_NEXT = 'autoplay';
|
||||
export const AUTOPLAY_NEXT = 'autoplay_next';
|
||||
export const OS_NOTIFICATIONS_ENABLED = 'os_notifications_enabled';
|
||||
export const AUTO_DOWNLOAD = 'auto_download';
|
||||
export const AUTO_LAUNCH = 'auto_launch';
|
||||
|
||||
@@ -14,8 +14,10 @@ export const DEFAULT_FOLLOWED_TAGS = [
|
||||
];
|
||||
|
||||
export const DISABLE_COMMENTS_TAG = 'disable-comments';
|
||||
export const DISABLE_SUPPORT_TAG = 'disable-support';
|
||||
export const PREFERENCE_EMBED = 'preference-embed';
|
||||
|
||||
export const UTILITY_TAGS = [DISABLE_COMMENTS_TAG];
|
||||
export const UTILITY_TAGS = [DISABLE_COMMENTS_TAG, DISABLE_SUPPORT_TAG, PREFERENCE_EMBED];
|
||||
|
||||
export const MATURE_TAGS = [
|
||||
'porn',
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { makeSelectClaimForUri } from 'lbry-redux';
|
||||
import { doHideModal } from 'redux/actions/app';
|
||||
import { doCommentModBlock, doCommentModBlockAsAdmin, doCommentModBlockAsModerator } from 'redux/actions/comments';
|
||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { selectModerationDelegatorsById } from 'redux/selectors/comments';
|
||||
|
||||
import ModalBlockChannel from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
activeChannelClaim: selectActiveChannelClaim(state),
|
||||
contentClaim: makeSelectClaimForUri(props.contentUri)(state),
|
||||
moderationDelegatorsById: selectModerationDelegatorsById(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
closeModal: () => dispatch(doHideModal()),
|
||||
commentModBlock: (a, b) => dispatch(doCommentModBlock(a, b)),
|
||||
commentModBlockAsAdmin: (a, b, c) => dispatch(doCommentModBlockAsAdmin(a, b, c)),
|
||||
commentModBlockAsModerator: (a, b, c, d) => dispatch(doCommentModBlockAsModerator(a, b, c, d)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(ModalBlockChannel);
|
||||
@@ -0,0 +1,313 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import parseDuration from 'parse-duration';
|
||||
import Button from 'component/button';
|
||||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
import ClaimPreview from 'component/claimPreview';
|
||||
import Card from 'component/common/card';
|
||||
import { FormField } from 'component/common/form';
|
||||
import Icon from 'component/common/icon';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import usePersistedState from 'effects/use-persisted-state';
|
||||
import { Modal } from 'modal/modal';
|
||||
import { getChannelFromClaim } from 'util/claim';
|
||||
|
||||
const TAB = {
|
||||
PERSONAL: 'personal',
|
||||
MODERATOR: 'moderator',
|
||||
ADMIN: 'admin',
|
||||
};
|
||||
|
||||
const BLOCK = {
|
||||
PERMANENT: 'permanent',
|
||||
TIMEOUT: 'timeout',
|
||||
};
|
||||
|
||||
type Props = {
|
||||
contentUri: string,
|
||||
commenterUri: string,
|
||||
// --- select ---
|
||||
activeChannelClaim: ?ChannelClaim,
|
||||
contentClaim: ?Claim,
|
||||
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
|
||||
// --- perform ---
|
||||
closeModal: () => void,
|
||||
commentModBlock: (commenterUri: string, timeoutSec: ?number) => void,
|
||||
commentModBlockAsAdmin: (commenterUri: string, blockerId: string, timeoutSec: ?number) => void,
|
||||
commentModBlockAsModerator: (
|
||||
commenterUri: string,
|
||||
creatorUri: string,
|
||||
blockerId: string,
|
||||
timeoutSec: ?number
|
||||
) => void,
|
||||
};
|
||||
|
||||
export default function ModalBlockChannel(props: Props) {
|
||||
const {
|
||||
commenterUri,
|
||||
activeChannelClaim,
|
||||
contentClaim,
|
||||
moderationDelegatorsById,
|
||||
closeModal,
|
||||
commentModBlock,
|
||||
commentModBlockAsAdmin,
|
||||
commentModBlockAsModerator,
|
||||
} = props;
|
||||
|
||||
const contentChannelClaim = getChannelFromClaim(contentClaim);
|
||||
const activeModeratorInfo = activeChannelClaim && moderationDelegatorsById[activeChannelClaim.claim_id];
|
||||
const activeChannelIsAdmin = activeChannelClaim && activeModeratorInfo && activeModeratorInfo.global;
|
||||
const activeChannelIsModerator =
|
||||
activeChannelClaim &&
|
||||
contentChannelClaim &&
|
||||
activeModeratorInfo &&
|
||||
Object.values(activeModeratorInfo.delegators).includes(contentChannelClaim.claim_id);
|
||||
|
||||
const [tab, setTab] = usePersistedState('ModalBlockChannel:tab', TAB.PERSONAL);
|
||||
const [blockType, setBlockType] = usePersistedState('ModalBlockChannel:blockType', BLOCK.PERMANENT);
|
||||
const [timeoutInput, setTimeoutInput] = usePersistedState('ModalBlockChannel:timeoutInput', '10m');
|
||||
const [timeoutInputErr, setTimeoutInputErr] = React.useState('');
|
||||
const [timeoutSec, setTimeoutSec] = React.useState(-1);
|
||||
|
||||
const isPersonalTheOnlyTab = !activeChannelIsModerator && !activeChannelIsAdmin;
|
||||
const isTimeoutAvail = (contentClaim && contentClaim.is_my_output) || activeChannelIsModerator;
|
||||
const blockButtonDisabled = blockType === BLOCK.TIMEOUT && timeoutSec < 1;
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
// Check settings validity on mount.
|
||||
React.useEffect(() => {
|
||||
if (
|
||||
isPersonalTheOnlyTab ||
|
||||
(tab === TAB.MODERATOR && !activeChannelIsModerator) ||
|
||||
(tab === TAB.ADMIN && !activeChannelIsAdmin)
|
||||
) {
|
||||
setTab(TAB.PERSONAL);
|
||||
}
|
||||
|
||||
if (!isTimeoutAvail && blockType === BLOCK.TIMEOUT) {
|
||||
setBlockType(BLOCK.PERMANENT);
|
||||
}
|
||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// 'timeoutInput' to 'timeoutSec' conversion.
|
||||
React.useEffect(() => {
|
||||
const handleInvalidInput = (errMsg: string) => {
|
||||
if (timeoutSec !== -1) {
|
||||
setTimeoutSec(-1);
|
||||
}
|
||||
if (timeoutInputErr !== errMsg) {
|
||||
setTimeoutInputErr(errMsg);
|
||||
}
|
||||
};
|
||||
|
||||
const handleValidInput = (seconds) => {
|
||||
if (seconds !== timeoutSec) {
|
||||
setTimeoutSec(seconds);
|
||||
}
|
||||
if (timeoutInputErr) {
|
||||
setTimeoutInputErr('');
|
||||
}
|
||||
};
|
||||
|
||||
if (!timeoutInput) {
|
||||
handleValidInput(-1); // Reset
|
||||
return;
|
||||
}
|
||||
|
||||
const ONE_HUNDRED_YEARS_IN_SECONDS = 3154000000;
|
||||
const seconds = parseDuration(timeoutInput, 's');
|
||||
|
||||
if (Number.isInteger(seconds) && seconds > 0) {
|
||||
if (seconds > ONE_HUNDRED_YEARS_IN_SECONDS) {
|
||||
handleInvalidInput(__('Wow, banned for more than 100 years?'));
|
||||
} else {
|
||||
handleValidInput(seconds);
|
||||
}
|
||||
} else {
|
||||
handleInvalidInput(__('Invalid duration.'));
|
||||
}
|
||||
}, [timeoutInput, timeoutInputErr, timeoutSec]);
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
function getTabElem(value, label) {
|
||||
return (
|
||||
<Button
|
||||
key={value}
|
||||
label={__(label)}
|
||||
button="alt"
|
||||
onClick={() => setTab(value)}
|
||||
className={classnames('button-toggle', { 'button-toggle--active': tab === value })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function getTabHelperElem(tab) {
|
||||
switch (tab) {
|
||||
case TAB.PERSONAL:
|
||||
return null;
|
||||
case TAB.MODERATOR:
|
||||
return (
|
||||
<p className="help">
|
||||
{__('Block this channel on behalf of %creator%', {
|
||||
creator: contentChannelClaim ? contentChannelClaim.name : __('creator'),
|
||||
})}
|
||||
</p>
|
||||
);
|
||||
case TAB.ADMIN:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getBlockTypeElem(value, label, disabled = false, disabledLabel = '') {
|
||||
return (
|
||||
<FormField
|
||||
type="radio"
|
||||
name={value}
|
||||
key={value}
|
||||
label={disabled && disabledLabel ? __(disabledLabel) : __(label)}
|
||||
disabled={disabled}
|
||||
checked={blockType === value}
|
||||
onChange={() => setBlockType(value)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function getTimeoutDurationElem() {
|
||||
const examples = '\n- 30s\n- 10m\n- 1h\n- 2d\n- 3mo\n- 1y';
|
||||
return (
|
||||
<FormField
|
||||
name="time_out"
|
||||
label={
|
||||
<>
|
||||
{__('Duration')}
|
||||
<Icon
|
||||
customTooltipText={__('Enter the timeout duration. Examples: %examples%', { examples })}
|
||||
className="icon--help"
|
||||
icon={ICONS.HELP}
|
||||
tooltip
|
||||
size={16}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
type="text"
|
||||
placeholder="30s, 10m, 1h, 2d, 3mo, 1y"
|
||||
value={timeoutInput}
|
||||
onChange={(e) => setTimeoutInput(e.target.value)}
|
||||
error={timeoutInputErr}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function getCommenterPreview(uri) {
|
||||
return (
|
||||
<div className="content__non-clickable">
|
||||
<ClaimPreview uri={uri} hideMenu hideActions type="small" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function getActiveChannelElem() {
|
||||
return activeChannelClaim ? (
|
||||
<div className="block-modal--active-channel">
|
||||
<ChannelThumbnail xsmall noLazyLoad uri={activeChannelClaim.permanent_url} />
|
||||
<div className="block-modal--active-channel-label">
|
||||
{__('Interacting as %channelName%', { channelName: activeChannelClaim.name })}
|
||||
</div>
|
||||
</div>
|
||||
) : null;
|
||||
}
|
||||
|
||||
function handleBlock() {
|
||||
const duration = blockType === BLOCK.TIMEOUT && timeoutSec > 0 ? timeoutSec : undefined;
|
||||
|
||||
switch (tab) {
|
||||
case TAB.PERSONAL:
|
||||
commentModBlock(commenterUri, duration);
|
||||
break;
|
||||
|
||||
case TAB.MODERATOR:
|
||||
if (activeChannelClaim && contentChannelClaim) {
|
||||
commentModBlockAsModerator(
|
||||
commenterUri,
|
||||
contentChannelClaim.permanent_url,
|
||||
activeChannelClaim.claim_id,
|
||||
duration
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case TAB.ADMIN:
|
||||
if (activeChannelClaim) {
|
||||
commentModBlockAsAdmin(commenterUri, activeChannelClaim.claim_id, duration);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
closeModal();
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
if (isPersonalTheOnlyTab && !isTimeoutAvail) {
|
||||
// There's only 1 option. Just execute it and don't show the modal.
|
||||
commentModBlock(commenterUri);
|
||||
closeModal();
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal isOpen type="card" onAborted={closeModal}>
|
||||
<Card
|
||||
title={__('Block Channel')}
|
||||
subtitle={getCommenterPreview(commenterUri)}
|
||||
actions={
|
||||
<>
|
||||
{!isPersonalTheOnlyTab && (
|
||||
<div className="section__actions">
|
||||
<div className="section">
|
||||
<label>{__('Block list')}</label>
|
||||
<div className="block-modal--values">
|
||||
{getTabElem(TAB.PERSONAL, 'Personal')}
|
||||
{activeChannelIsModerator && getTabElem(TAB.MODERATOR, 'Moderator')}
|
||||
{activeChannelIsAdmin && getTabElem(TAB.ADMIN, 'Global Admin')}
|
||||
{getTabHelperElem(tab)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="section section--vertical-compact">
|
||||
<label>{__('Duration')}</label>
|
||||
<div className="block-modal--values">
|
||||
<fieldset>
|
||||
{getBlockTypeElem(BLOCK.PERMANENT, 'Permanent')}
|
||||
{getBlockTypeElem(
|
||||
BLOCK.TIMEOUT,
|
||||
'Timeout --[time-based ban instead of permanent]--',
|
||||
!isTimeoutAvail,
|
||||
'Timeout (only available on content that you own)'
|
||||
)}
|
||||
</fieldset>
|
||||
{blockType === BLOCK.TIMEOUT && getTimeoutDurationElem()}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="block-modal--finalize">
|
||||
<div className="section__actions">
|
||||
<Button button="primary" label={__('Block')} onClick={handleBlock} disabled={blockButtonDisabled} />
|
||||
<Button button="link" label={__('Cancel')} onClick={closeModal} />
|
||||
{getActiveChannelElem()}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -3,13 +3,10 @@ import { doHideModal } from 'redux/actions/app';
|
||||
import { doUploadThumbnail, doUpdatePublishForm } from 'lbry-redux';
|
||||
import ModalConfirmThumbnailUpload from './view';
|
||||
|
||||
const perform = dispatch => ({
|
||||
const perform = (dispatch) => ({
|
||||
closeModal: () => dispatch(doHideModal()),
|
||||
upload: file => dispatch(doUploadThumbnail(null, file, null, null, file.path)),
|
||||
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
||||
upload: (file, cb) => dispatch(doUploadThumbnail(null, file, null, null, file.path, cb)),
|
||||
updatePublishForm: (value) => dispatch(doUpdatePublishForm(value)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
null,
|
||||
perform
|
||||
)(ModalConfirmThumbnailUpload);
|
||||
export default connect(null, perform)(ModalConfirmThumbnailUpload);
|
||||
@@ -4,17 +4,18 @@ import { Modal } from 'modal/modal';
|
||||
import { DOMAIN } from 'config';
|
||||
|
||||
type Props = {
|
||||
upload: WebFile => void,
|
||||
file: WebFile,
|
||||
upload: (WebFile, (string) => void) => void,
|
||||
cb: (string) => void,
|
||||
closeModal: () => void,
|
||||
updatePublishForm: ({}) => void,
|
||||
};
|
||||
|
||||
class ModalConfirmThumbnailUpload extends React.PureComponent<Props> {
|
||||
upload() {
|
||||
const { upload, updatePublishForm, closeModal, file } = this.props;
|
||||
const { upload, updatePublishForm, cb, closeModal, file } = this.props;
|
||||
if (file) {
|
||||
upload(file);
|
||||
upload(file, cb);
|
||||
updatePublishForm({ thumbnailPath: file.path });
|
||||
closeModal();
|
||||
}
|
||||
|
||||
@@ -5,32 +5,71 @@ import { lazyImport } from 'util/lazyImport';
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
import LoadingBarOneOff from 'component/loadingBarOneOff';
|
||||
|
||||
const ModalAffirmPurchase = lazyImport(() => import('modal/modalAffirmPurchase' /* webpackChunkName: "modalAffirmPurchase" */));
|
||||
const ModalAutoGenerateThumbnail = lazyImport(() => import('modal/modalAutoGenerateThumbnail' /* webpackChunkName: "modalAutoGenerateThumbnail" */));
|
||||
const ModalAutoUpdateDownloaded = lazyImport(() => import('modal/modalAutoUpdateDownloaded' /* webpackChunkName: "modalAutoUpdateDownloaded" */));
|
||||
const ModalClaimCollectionAdd = lazyImport(() => import('modal/modalClaimCollectionAdd' /* webpackChunkName: "modalClaimCollectionAdd" */));
|
||||
const ModalCommentAcknowledgement = lazyImport(() => import('modal/modalCommentAcknowledgement' /* webpackChunkName: "modalCommentAcknowledgement" */));
|
||||
const ModalAffirmPurchase = lazyImport(() =>
|
||||
import('modal/modalAffirmPurchase' /* webpackChunkName: "modalAffirmPurchase" */)
|
||||
);
|
||||
const ModalAutoGenerateThumbnail = lazyImport(() =>
|
||||
import('modal/modalAutoGenerateThumbnail' /* webpackChunkName: "modalAutoGenerateThumbnail" */)
|
||||
);
|
||||
const ModalAutoUpdateDownloaded = lazyImport(() =>
|
||||
import('modal/modalAutoUpdateDownloaded' /* webpackChunkName: "modalAutoUpdateDownloaded" */)
|
||||
);
|
||||
const ModalBlockChannel = lazyImport(() =>
|
||||
import('modal/modalBlockChannel' /* webpackChunkName: "modalBlockChannel" */)
|
||||
);
|
||||
const ModalClaimCollectionAdd = lazyImport(() =>
|
||||
import('modal/modalClaimCollectionAdd' /* webpackChunkName: "modalClaimCollectionAdd" */)
|
||||
);
|
||||
const ModalCommentAcknowledgement = lazyImport(() =>
|
||||
import('modal/modalCommentAcknowledgement' /* webpackChunkName: "modalCommentAcknowledgement" */)
|
||||
);
|
||||
const ModalConfirmAge = lazyImport(() => import('modal/modalConfirmAge' /* webpackChunkName: "modalConfirmAge" */));
|
||||
const ModalConfirmThumbnailUpload = lazyImport(() => import('modal/modalConfirmThumbnailUpload' /* webpackChunkName: "modalConfirmThumbnailUpload" */));
|
||||
const ModalConfirmTransaction = lazyImport(() => import('modal/modalConfirmTransaction' /* webpackChunkName: "modalConfirmTransaction" */));
|
||||
const ModalDeleteCollection = lazyImport(() => import('modal/modalRemoveCollection' /* webpackChunkName: "modalRemoveCollection" */));
|
||||
const ModalConfirmThumbnailUpload = lazyImport(() =>
|
||||
import('modal/modalConfirmThumbnailUpload' /* webpackChunkName: "modalConfirmThumbnailUpload" */)
|
||||
);
|
||||
const ModalConfirmTransaction = lazyImport(() =>
|
||||
import('modal/modalConfirmTransaction' /* webpackChunkName: "modalConfirmTransaction" */)
|
||||
);
|
||||
const ModalDeleteCollection = lazyImport(() =>
|
||||
import('modal/modalRemoveCollection' /* webpackChunkName: "modalRemoveCollection" */)
|
||||
);
|
||||
const ModalDownloading = lazyImport(() => import('modal/modalDownloading' /* webpackChunkName: "modalDownloading" */));
|
||||
const ModalError = lazyImport(() => import('modal/modalError' /* webpackChunkName: "modalError" */));
|
||||
const ModalFileSelection = lazyImport(() => import('modal/modalFileSelection' /* webpackChunkName: "modalFileSelection" */));
|
||||
const ModalFileSelection = lazyImport(() =>
|
||||
import('modal/modalFileSelection' /* webpackChunkName: "modalFileSelection" */)
|
||||
);
|
||||
const ModalFileTimeout = lazyImport(() => import('modal/modalFileTimeout' /* webpackChunkName: "modalFileTimeout" */));
|
||||
const ModalFirstReward = lazyImport(() => import('modal/modalFirstReward' /* webpackChunkName: "modalFirstReward" */));
|
||||
const ModalFirstSubscription = lazyImport(() => import('modal/modalFirstSubscription' /* webpackChunkName: "modalFirstSubscription" */));
|
||||
const ModalFirstSubscription = lazyImport(() =>
|
||||
import('modal/modalFirstSubscription' /* webpackChunkName: "modalFirstSubscription" */)
|
||||
);
|
||||
const ModalImageUpload = lazyImport(() => import('modal/modalImageUpload' /* webpackChunkName: "modalImageUpload" */));
|
||||
const ModalMassTipsUnlock = lazyImport(() => import('modal/modalMassTipUnlock' /* webpackChunkName: "modalMassTipUnlock" */));
|
||||
const ModalMobileSearch = lazyImport(() => import('modal/modalMobileSearch' /* webpackChunkName: "modalMobileSearch" */));
|
||||
const ModalOpenExternalResource = lazyImport(() => import('modal/modalOpenExternalResource' /* webpackChunkName: "modalOpenExternalResource" */));
|
||||
const ModalPasswordUnsave = lazyImport(() => import('modal/modalPasswordUnsave' /* webpackChunkName: "modalPasswordUnsave" */));
|
||||
const ModalPhoneCollection = lazyImport(() => import('modal/modalPhoneCollection' /* webpackChunkName: "modalPhoneCollection" */));
|
||||
const ModalMassTipsUnlock = lazyImport(() =>
|
||||
import('modal/modalMassTipUnlock' /* webpackChunkName: "modalMassTipUnlock" */)
|
||||
);
|
||||
const ModalMobileSearch = lazyImport(() =>
|
||||
import('modal/modalMobileSearch' /* webpackChunkName: "modalMobileSearch" */)
|
||||
);
|
||||
const ModalOpenExternalResource = lazyImport(() =>
|
||||
import('modal/modalOpenExternalResource' /* webpackChunkName: "modalOpenExternalResource" */)
|
||||
);
|
||||
const ModalPasswordUnsave = lazyImport(() =>
|
||||
import('modal/modalPasswordUnsave' /* webpackChunkName: "modalPasswordUnsave" */)
|
||||
);
|
||||
const ModalPhoneCollection = lazyImport(() =>
|
||||
import('modal/modalPhoneCollection' /* webpackChunkName: "modalPhoneCollection" */)
|
||||
);
|
||||
const ModalPublish = lazyImport(() => import('modal/modalPublish' /* webpackChunkName: "modalPublish" */));
|
||||
const ModalPublishPreview = lazyImport(() => import('modal/modalPublishPreview' /* webpackChunkName: "modalPublishPreview" */));
|
||||
const ModalRemoveBtcSwapAddress = lazyImport(() => import('modal/modalRemoveBtcSwapAddress' /* webpackChunkName: "modalRemoveBtcSwapAddress" */));
|
||||
const ModalPublishPreview = lazyImport(() =>
|
||||
import('modal/modalPublishPreview' /* webpackChunkName: "modalPublishPreview" */)
|
||||
);
|
||||
const ModalRemoveBtcSwapAddress = lazyImport(() =>
|
||||
import('modal/modalRemoveBtcSwapAddress' /* webpackChunkName: "modalRemoveBtcSwapAddress" */)
|
||||
);
|
||||
const ModalRemoveCard = lazyImport(() => import('modal/modalRemoveCard' /* webpackChunkName: "modalRemoveCard" */));
|
||||
const ModalRemoveComment = lazyImport(() => import('modal/modalRemoveComment' /* webpackChunkName: "modalRemoveComment" */));
|
||||
const ModalRemoveComment = lazyImport(() =>
|
||||
import('modal/modalRemoveComment' /* webpackChunkName: "modalRemoveComment" */)
|
||||
);
|
||||
const ModalRemoveFile = lazyImport(() => import('modal/modalRemoveFile' /* webpackChunkName: "modalRemoveFile" */));
|
||||
const ModalRevokeClaim = lazyImport(() => import('modal/modalRevokeClaim' /* webpackChunkName: "modalRevokeClaim" */));
|
||||
const ModalRewardCode = lazyImport(() => import('modal/modalRewardCode' /* webpackChunkName: "modalRewardCode" */));
|
||||
@@ -38,15 +77,27 @@ const ModalSendTip = lazyImport(() => import('modal/modalSendTip' /* webpackChun
|
||||
const ModalSetReferrer = lazyImport(() => import('modal/modalSetReferrer' /* webpackChunkName: "modalSetReferrer" */));
|
||||
const ModalSignOut = lazyImport(() => import('modal/modalSignOut' /* webpackChunkName: "modalSignOut" */));
|
||||
const ModalSocialShare = lazyImport(() => import('modal/modalSocialShare' /* webpackChunkName: "modalSocialShare" */));
|
||||
const ModalSupportsLiquidate = lazyImport(() => import('modal/modalSupportsLiquidate' /* webpackChunkName: "modalSupportsLiquidate" */));
|
||||
const ModalSupportsLiquidate = lazyImport(() =>
|
||||
import('modal/modalSupportsLiquidate' /* webpackChunkName: "modalSupportsLiquidate" */)
|
||||
);
|
||||
const ModalSyncEnable = lazyImport(() => import('modal/modalSyncEnable' /* webpackChunkName: "modalSyncEnable" */));
|
||||
const ModalTransactionFailed = lazyImport(() => import('modal/modalTransactionFailed' /* webpackChunkName: "modalTransactionFailed" */));
|
||||
const ModalTransactionFailed = lazyImport(() =>
|
||||
import('modal/modalTransactionFailed' /* webpackChunkName: "modalTransactionFailed" */)
|
||||
);
|
||||
const ModalUpgrade = lazyImport(() => import('modal/modalUpgrade' /* webpackChunkName: "modalUpgrade" */));
|
||||
const ModalViewImage = lazyImport(() => import('modal/modalViewImage' /* webpackChunkName: "modalViewImage" */));
|
||||
const ModalWalletDecrypt = lazyImport(() => import('modal/modalWalletDecrypt' /* webpackChunkName: "modalWalletDecrypt" */));
|
||||
const ModalWalletEncrypt = lazyImport(() => import('modal/modalWalletEncrypt' /* webpackChunkName: "modalWalletEncrypt" */));
|
||||
const ModalWalletUnlock = lazyImport(() => import('modal/modalWalletUnlock' /* webpackChunkName: "modalWalletUnlock" */));
|
||||
const ModalYoutubeWelcome = lazyImport(() => import('modal/modalYoutubeWelcome' /* webpackChunkName: "modalYoutubeWelcome" */));
|
||||
const ModalWalletDecrypt = lazyImport(() =>
|
||||
import('modal/modalWalletDecrypt' /* webpackChunkName: "modalWalletDecrypt" */)
|
||||
);
|
||||
const ModalWalletEncrypt = lazyImport(() =>
|
||||
import('modal/modalWalletEncrypt' /* webpackChunkName: "modalWalletEncrypt" */)
|
||||
);
|
||||
const ModalWalletUnlock = lazyImport(() =>
|
||||
import('modal/modalWalletUnlock' /* webpackChunkName: "modalWalletUnlock" */)
|
||||
);
|
||||
const ModalYoutubeWelcome = lazyImport(() =>
|
||||
import('modal/modalYoutubeWelcome' /* webpackChunkName: "modalYoutubeWelcome" */)
|
||||
);
|
||||
|
||||
type Props = {
|
||||
modal: { id: string, modalProps: {} },
|
||||
@@ -149,6 +200,8 @@ function ModalRouter(props: Props) {
|
||||
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:
|
||||
|
||||
@@ -3,6 +3,8 @@ import React from 'react';
|
||||
import { Modal } from 'modal/modal';
|
||||
import LastReleaseChanges from 'component/lastReleaseChanges';
|
||||
|
||||
const IS_MAC = navigator.userAgent.indexOf('Mac OS X') !== -1;
|
||||
|
||||
type Props = {
|
||||
downloadUpgrade: () => void,
|
||||
skipUpgrade: () => void,
|
||||
@@ -14,6 +16,7 @@ class ModalUpgrade extends React.PureComponent<Props> {
|
||||
|
||||
return (
|
||||
<Modal
|
||||
className={IS_MAC ? '' : 'main-wrapper--scrollbar'}
|
||||
isOpen
|
||||
contentLabel={__('Upgrade available')}
|
||||
title={__('LBRY leveled up')}
|
||||
|
||||
@@ -8,6 +8,9 @@ import {
|
||||
selectModeratorBlockListDelegatorsMap,
|
||||
selectFetchingModerationBlockList,
|
||||
selectModerationDelegatorsById,
|
||||
selectAdminTimeoutMap,
|
||||
selectModeratorTimeoutMap,
|
||||
selectPersonalTimeoutMap,
|
||||
} from 'redux/selectors/comments';
|
||||
import { selectMyChannelClaims } from 'lbry-redux';
|
||||
import ListBlocked from './view';
|
||||
@@ -17,6 +20,9 @@ const select = (state) => ({
|
||||
personalBlockList: selectModerationBlockList(state),
|
||||
adminBlockList: selectAdminBlockList(state),
|
||||
moderatorBlockList: selectModeratorBlockList(state),
|
||||
personalTimeoutMap: selectPersonalTimeoutMap(state),
|
||||
adminTimeoutMap: selectAdminTimeoutMap(state),
|
||||
moderatorTimeoutMap: selectModeratorTimeoutMap(state),
|
||||
moderatorBlockListDelegatorsMap: selectModeratorBlockListDelegatorsMap(state),
|
||||
delegatorsById: selectModerationDelegatorsById(state),
|
||||
myChannelClaims: selectMyChannelClaims(state),
|
||||
|
||||
+118
-167
@@ -3,7 +3,9 @@ import * as ICONS from 'constants/icons';
|
||||
import { BLOCK_LEVEL } from 'constants/comment';
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import ClaimList from 'component/claimList';
|
||||
import moment from 'moment';
|
||||
import humanizeDuration from 'humanize-duration';
|
||||
import BlockList from 'component/blockList';
|
||||
import ClaimPreview from 'component/claimPreview';
|
||||
import Page from 'component/page';
|
||||
import Spinner from 'component/spinner';
|
||||
@@ -11,7 +13,6 @@ import Button from 'component/button';
|
||||
import usePersistedState from 'effects/use-persisted-state';
|
||||
import ChannelBlockButton from 'component/channelBlockButton';
|
||||
import ChannelMuteButton from 'component/channelMuteButton';
|
||||
import Yrbl from 'component/yrbl';
|
||||
|
||||
const VIEW = {
|
||||
BLOCKED: 'blocked',
|
||||
@@ -25,6 +26,9 @@ type Props = {
|
||||
personalBlockList: ?Array<string>,
|
||||
adminBlockList: ?Array<string>,
|
||||
moderatorBlockList: ?Array<string>,
|
||||
personalTimeoutMap: { [uri: string]: { blockedAt: string, bannedFor: number, banRemaining: number } },
|
||||
adminTimeoutMap: { [uri: string]: { blockedAt: string, bannedFor: number, banRemaining: number } },
|
||||
moderatorTimeoutMap: { [uri: string]: { blockedAt: string, bannedFor: number, banRemaining: number } },
|
||||
moderatorBlockListDelegatorsMap: { [string]: Array<string> },
|
||||
fetchingModerationBlockList: boolean,
|
||||
fetchModBlockedList: () => void,
|
||||
@@ -39,7 +43,10 @@ function ListBlocked(props: Props) {
|
||||
personalBlockList,
|
||||
adminBlockList,
|
||||
moderatorBlockList,
|
||||
moderatorBlockListDelegatorsMap,
|
||||
personalTimeoutMap,
|
||||
adminTimeoutMap,
|
||||
moderatorTimeoutMap,
|
||||
moderatorBlockListDelegatorsMap: delegatorsMap,
|
||||
fetchingModerationBlockList,
|
||||
fetchModBlockedList,
|
||||
fetchModAmIList,
|
||||
@@ -48,79 +55,92 @@ function ListBlocked(props: Props) {
|
||||
} = props;
|
||||
const [viewMode, setViewMode] = usePersistedState('blocked-muted:display', VIEW.BLOCKED);
|
||||
|
||||
// Keep a local list to allow for undoing actions in this component
|
||||
const [localPersonalList, setLocalPersonalList] = React.useState(undefined);
|
||||
const [localAdminList, setLocalAdminList] = React.useState(undefined);
|
||||
const [localModeratorList, setLocalModeratorList] = React.useState(undefined);
|
||||
const [localModeratorListDelegatorsMap, setLocalModeratorListDelegatorsMap] = React.useState(undefined);
|
||||
const [localMutedList, setLocalMutedList] = React.useState(undefined);
|
||||
const [localDelegatorsMap, setLocalDelegatorsMap] = React.useState(undefined);
|
||||
|
||||
const hasLocalMuteList = localMutedList && localMutedList.length > 0;
|
||||
const hasLocalPersonalList = localPersonalList && localPersonalList.length > 0;
|
||||
|
||||
const stringifiedMutedList = JSON.stringify(mutedUris);
|
||||
const stringifiedPersonalList = JSON.stringify(personalBlockList);
|
||||
const stringifiedAdminList = JSON.stringify(adminBlockList);
|
||||
const stringifiedModeratorList = JSON.stringify(moderatorBlockList);
|
||||
const stringifiedModeratorListDelegatorsMap = JSON.stringify(moderatorBlockListDelegatorsMap);
|
||||
|
||||
const stringifiedLocalAdminList = JSON.stringify(localAdminList);
|
||||
const stringifiedLocalModeratorList = JSON.stringify(localModeratorList);
|
||||
const stringifiedLocalModeratorListDelegatorsMap = JSON.stringify(localModeratorListDelegatorsMap);
|
||||
|
||||
const justMuted = localMutedList && mutedUris && localMutedList.length < mutedUris.length;
|
||||
const justPersonalBlocked =
|
||||
localPersonalList && personalBlockList && localPersonalList.length < personalBlockList.length;
|
||||
const stringifiedDelegatorsMap = JSON.stringify(delegatorsMap);
|
||||
const stringifiedLocalDelegatorsMap = JSON.stringify(localDelegatorsMap);
|
||||
|
||||
const isAdmin =
|
||||
myChannelClaims && myChannelClaims.some((c) => delegatorsById[c.claim_id] && delegatorsById[c.claim_id].global);
|
||||
|
||||
const isModerator =
|
||||
myChannelClaims &&
|
||||
myChannelClaims.some(
|
||||
(c) => delegatorsById[c.claim_id] && Object.keys(delegatorsById[c.claim_id].delegators).length > 0
|
||||
);
|
||||
|
||||
const listForView = getLocalList(viewMode);
|
||||
const showUris = listForView && listForView.length > 0;
|
||||
// **************************************************************************
|
||||
|
||||
function getLocalList(view) {
|
||||
function getList(view) {
|
||||
switch (view) {
|
||||
case VIEW.BLOCKED:
|
||||
return localPersonalList;
|
||||
return personalBlockList;
|
||||
case VIEW.ADMIN:
|
||||
return localAdminList;
|
||||
return adminBlockList;
|
||||
case VIEW.MODERATOR:
|
||||
return localModeratorList;
|
||||
return moderatorBlockList;
|
||||
case VIEW.MUTED:
|
||||
return localMutedList;
|
||||
return mutedUris;
|
||||
}
|
||||
}
|
||||
|
||||
function getButtons(view, uri) {
|
||||
switch (view) {
|
||||
function getActionButtons(uri) {
|
||||
const getDurationStr = (durationNs) => {
|
||||
const NANO_TO_MS = 1000000;
|
||||
return humanizeDuration(durationNs / NANO_TO_MS, { round: true });
|
||||
};
|
||||
|
||||
const getBanInfoElem = (timeoutInfo) => {
|
||||
return (
|
||||
<div>
|
||||
<div className="help">
|
||||
<blockquote>
|
||||
{moment(timeoutInfo.blockedAt).format('MMMM Do, YYYY @ HH:mm')}
|
||||
<br />
|
||||
{getDurationStr(timeoutInfo.bannedFor)}{' '}
|
||||
{__('(Remaining: %duration%) --[timeout ban duration]--', {
|
||||
duration: getDurationStr(timeoutInfo.banRemaining),
|
||||
})}
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
switch (viewMode) {
|
||||
case VIEW.BLOCKED:
|
||||
return (
|
||||
<>
|
||||
<ChannelBlockButton uri={uri} />
|
||||
<ChannelMuteButton uri={uri} />
|
||||
{personalTimeoutMap[uri] && getBanInfoElem(personalTimeoutMap[uri])}
|
||||
</>
|
||||
);
|
||||
|
||||
case VIEW.ADMIN:
|
||||
return <ChannelBlockButton uri={uri} blockLevel={BLOCK_LEVEL.ADMIN} />;
|
||||
return (
|
||||
<>
|
||||
<ChannelBlockButton uri={uri} blockLevel={BLOCK_LEVEL.ADMIN} />
|
||||
{adminTimeoutMap[uri] && getBanInfoElem(adminTimeoutMap[uri])}
|
||||
</>
|
||||
);
|
||||
|
||||
case VIEW.MODERATOR:
|
||||
const delegatorUrisForBlockedUri = localModeratorListDelegatorsMap && localModeratorListDelegatorsMap[uri];
|
||||
const delegatorUrisForBlockedUri = localDelegatorsMap && localDelegatorsMap[uri];
|
||||
if (!delegatorUrisForBlockedUri) return null;
|
||||
return (
|
||||
<>
|
||||
{delegatorUrisForBlockedUri.map((delegatorUri) => {
|
||||
return (
|
||||
<div className="block-list--delegator" key={delegatorUri}>
|
||||
<ul className="section content__non-clickable">
|
||||
<ClaimPreview uri={delegatorUri} hideMenu hideActions type="small" />
|
||||
<label>{__('Blocked on behalf of:')}</label>
|
||||
<ul className="section">
|
||||
<div className="content__non-clickable">
|
||||
<ClaimPreview uri={delegatorUri} hideMenu hideActions type="inline" properties={false} />
|
||||
{moderatorTimeoutMap[uri] && getBanInfoElem(moderatorTimeoutMap[uri])}
|
||||
</div>
|
||||
<ChannelBlockButton uri={uri} blockLevel={BLOCK_LEVEL.MODERATOR} creatorUri={delegatorUri} />
|
||||
</ul>
|
||||
<ChannelBlockButton uri={uri} blockLevel={BLOCK_LEVEL.MODERATOR} creatorUri={delegatorUri} />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
@@ -140,26 +160,30 @@ function ListBlocked(props: Props) {
|
||||
function getHelpText(view) {
|
||||
switch (view) {
|
||||
case VIEW.BLOCKED:
|
||||
return "Blocked channels will be invisible to you in the app. They will not be able to comment on your content, nor reply to your comments left on other channels' content.";
|
||||
return __(
|
||||
"Blocked channels will be invisible to you in the app. They will not be able to comment on your content, nor reply to your comments left on other channels' content."
|
||||
);
|
||||
case VIEW.ADMIN:
|
||||
return 'This is the global block list.';
|
||||
return __('This is the global block list.');
|
||||
case VIEW.MODERATOR:
|
||||
return 'List of channels that you have blocked as a moderator, along with the list of delegators.';
|
||||
return __('List of channels that you have blocked as a moderator, along with the list of delegators.');
|
||||
case VIEW.MUTED:
|
||||
return 'Muted channels will be invisible to you in the app. They will not know they are muted and can still interact with you and your content.';
|
||||
return __(
|
||||
'Muted channels will be invisible to you in the app. They will not know they are muted and can still interact with you and your content.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getEmptyListTitle(view) {
|
||||
switch (view) {
|
||||
case VIEW.BLOCKED:
|
||||
return 'You do not have any blocked channels';
|
||||
return __('You do not have any blocked channels');
|
||||
case VIEW.MUTED:
|
||||
return 'You do not have any muted channels';
|
||||
return __('You do not have any muted channels');
|
||||
case VIEW.ADMIN:
|
||||
return 'You do not have any globally-blocked channels';
|
||||
return __('You do not have any globally-blocked channels');
|
||||
case VIEW.MODERATOR:
|
||||
return 'You do not have any blocked channels as a moderator';
|
||||
return __('You do not have any blocked channels as a moderator');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,52 +205,43 @@ function ListBlocked(props: Props) {
|
||||
return source && (!local || local.length < source.length);
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
const jsonMutedChannels = stringifiedMutedList && JSON.parse(stringifiedMutedList);
|
||||
if (!hasLocalMuteList && jsonMutedChannels && jsonMutedChannels.length > 0) {
|
||||
setLocalMutedList(jsonMutedChannels);
|
||||
}
|
||||
}, [stringifiedMutedList, hasLocalMuteList]);
|
||||
function getViewElem(view, label, icon) {
|
||||
return (
|
||||
<Button
|
||||
icon={icon}
|
||||
button="alt"
|
||||
label={__(label)}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': viewMode === view,
|
||||
})}
|
||||
onClick={() => setViewMode(view)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function getRefreshElem() {
|
||||
return (
|
||||
<Button
|
||||
icon={ICONS.REFRESH}
|
||||
button="alt"
|
||||
label={__('Refresh')}
|
||||
onClick={() => {
|
||||
fetchModBlockedList();
|
||||
fetchModAmIList();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
|
||||
React.useEffect(() => {
|
||||
const jsonBlockedChannels = stringifiedPersonalList && JSON.parse(stringifiedPersonalList);
|
||||
if (!hasLocalPersonalList && jsonBlockedChannels && jsonBlockedChannels.length > 0) {
|
||||
setLocalPersonalList(jsonBlockedChannels);
|
||||
if (stringifiedDelegatorsMap && isSourceListLarger(stringifiedDelegatorsMap, stringifiedLocalDelegatorsMap)) {
|
||||
setLocalDelegatorsMap(JSON.parse(stringifiedDelegatorsMap));
|
||||
}
|
||||
}, [stringifiedPersonalList, hasLocalPersonalList]);
|
||||
}, [stringifiedDelegatorsMap, stringifiedLocalDelegatorsMap]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (stringifiedAdminList && isSourceListLarger(stringifiedAdminList, stringifiedLocalAdminList)) {
|
||||
setLocalAdminList(JSON.parse(stringifiedAdminList));
|
||||
}
|
||||
}, [stringifiedAdminList, stringifiedLocalAdminList]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (stringifiedModeratorList && isSourceListLarger(stringifiedModeratorList, stringifiedLocalModeratorList)) {
|
||||
setLocalModeratorList(JSON.parse(stringifiedModeratorList));
|
||||
}
|
||||
}, [stringifiedModeratorList, stringifiedLocalModeratorList]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (
|
||||
stringifiedModeratorListDelegatorsMap &&
|
||||
isSourceListLarger(stringifiedModeratorListDelegatorsMap, stringifiedLocalModeratorListDelegatorsMap)
|
||||
) {
|
||||
setLocalModeratorListDelegatorsMap(JSON.parse(stringifiedModeratorListDelegatorsMap));
|
||||
}
|
||||
}, [stringifiedModeratorListDelegatorsMap, stringifiedLocalModeratorListDelegatorsMap]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (justMuted && stringifiedMutedList) {
|
||||
setLocalMutedList(JSON.parse(stringifiedMutedList));
|
||||
}
|
||||
}, [stringifiedMutedList, justMuted, setLocalMutedList]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (justPersonalBlocked && stringifiedPersonalList) {
|
||||
setLocalPersonalList(JSON.parse(stringifiedPersonalList));
|
||||
}
|
||||
}, [stringifiedPersonalList, justPersonalBlocked, setLocalPersonalList]);
|
||||
// **************************************************************************
|
||||
|
||||
return (
|
||||
<Page
|
||||
@@ -245,87 +260,23 @@ function ListBlocked(props: Props) {
|
||||
<>
|
||||
<div className="section__header--actions">
|
||||
<div className="section__actions--inline">
|
||||
<Button
|
||||
icon={ICONS.BLOCK}
|
||||
button="alt"
|
||||
label={__('Blocked')}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': viewMode === VIEW.BLOCKED,
|
||||
})}
|
||||
onClick={() => setViewMode(VIEW.BLOCKED)}
|
||||
/>
|
||||
{isAdmin && (
|
||||
<Button
|
||||
icon={ICONS.BLOCK}
|
||||
button="alt"
|
||||
label={__('Global')}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': viewMode === VIEW.ADMIN,
|
||||
})}
|
||||
onClick={() => setViewMode(VIEW.ADMIN)}
|
||||
/>
|
||||
)}
|
||||
{isModerator && (
|
||||
<Button
|
||||
icon={ICONS.BLOCK}
|
||||
button="alt"
|
||||
label={__('Moderator')}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': viewMode === VIEW.MODERATOR,
|
||||
})}
|
||||
onClick={() => setViewMode(VIEW.MODERATOR)}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
icon={ICONS.MUTE}
|
||||
button="alt"
|
||||
label={__('Muted')}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': viewMode === VIEW.MUTED,
|
||||
})}
|
||||
onClick={() => setViewMode(VIEW.MUTED)}
|
||||
/>
|
||||
</div>
|
||||
<div className="section__actions--inline">
|
||||
<Button
|
||||
icon={ICONS.REFRESH}
|
||||
button="alt"
|
||||
label={__('Refresh')}
|
||||
onClick={() => {
|
||||
fetchModBlockedList();
|
||||
fetchModAmIList();
|
||||
}}
|
||||
/>
|
||||
{getViewElem(VIEW.BLOCKED, 'Blocked', ICONS.BLOCK)}
|
||||
{isAdmin && getViewElem(VIEW.ADMIN, 'Global', ICONS.BLOCK)}
|
||||
{isModerator && getViewElem(VIEW.MODERATOR, 'Moderator', ICONS.BLOCK)}
|
||||
{getViewElem(VIEW.MUTED, 'Muted', ICONS.MUTE)}
|
||||
</div>
|
||||
<div className="section__actions--inline">{getRefreshElem()}</div>
|
||||
</div>
|
||||
|
||||
{showUris && <div className="help--notice">{getHelpText(viewMode)}</div>}
|
||||
|
||||
{showUris ? (
|
||||
<div className={viewMode === VIEW.MODERATOR ? 'block-list--moderator' : 'block-list'}>
|
||||
<ClaimList
|
||||
uris={getLocalList(viewMode)}
|
||||
showUnresolvedClaims
|
||||
showHiddenByUser
|
||||
hideMenu
|
||||
renderActions={(claim) => {
|
||||
return <div className="section__actions">{getButtons(viewMode, claim.permanent_url)}</div>;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="main--empty">
|
||||
<Yrbl
|
||||
title={getEmptyListTitle(viewMode)}
|
||||
subtitle={getEmptyListSubtitle(viewMode)}
|
||||
actions={
|
||||
<div className="section__actions">
|
||||
<Button button="primary" label={__('Go Home')} navigate="/" />
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<BlockList
|
||||
key={viewMode}
|
||||
uris={getList(viewMode)}
|
||||
help={getHelpText(viewMode)}
|
||||
titleEmptyList={getEmptyListTitle(viewMode)}
|
||||
subtitle={getEmptyListSubtitle(viewMode)}
|
||||
getActionButtons={getActionButtons}
|
||||
className={viewMode === VIEW.MODERATOR ? 'block-list--moderator' : undefined}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Page>
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
selectFetchingBlockedWords,
|
||||
selectModerationDelegatesById,
|
||||
} from 'redux/selectors/comments';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
|
||||
const select = (state) => ({
|
||||
activeChannelClaim: selectActiveChannelClaim(state),
|
||||
@@ -36,7 +35,6 @@ const perform = (dispatch) => ({
|
||||
commentModRemoveDelegate: (modChanId, modChanName, creatorChannelClaim) =>
|
||||
dispatch(doCommentModRemoveDelegate(modChanId, modChanName, creatorChannelClaim)),
|
||||
commentModListDelegates: (creatorChannelClaim) => dispatch(doCommentModListDelegates(creatorChannelClaim)),
|
||||
doToast: (options) => dispatch(doToast(options)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(SettingsCreatorPage);
|
||||
@@ -1,21 +1,17 @@
|
||||
// @flow
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as React from 'react';
|
||||
import Card from 'component/common/card';
|
||||
import TagsSearch from 'component/tagsSearch';
|
||||
import Page from 'component/page';
|
||||
import Button from 'component/button';
|
||||
import ChannelSelector from 'component/channelSelector';
|
||||
import SearchChannelField from 'component/searchChannelField';
|
||||
import SettingsRow from 'component/settingsRow';
|
||||
import Spinner from 'component/spinner';
|
||||
import { FormField } from 'component/common/form-components/form-field';
|
||||
import Icon from 'component/common/icon';
|
||||
import LbcSymbol from 'component/common/lbc-symbol';
|
||||
import I18nMessage from 'component/i18nMessage';
|
||||
import { isNameValid, parseURI } from 'lbry-redux';
|
||||
import ClaimPreview from 'component/claimPreview';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
import debounce from 'util/debounce';
|
||||
import { getUriForSearchTerm } from 'util/search';
|
||||
|
||||
const DEBOUNCE_REFRESH_MS = 1000;
|
||||
|
||||
@@ -54,23 +50,19 @@ export default function SettingsCreatorPage(props: Props) {
|
||||
commentModListDelegates,
|
||||
fetchCreatorSettings,
|
||||
updateCreatorSettings,
|
||||
doToast,
|
||||
} = props;
|
||||
|
||||
const [commentsEnabled, setCommentsEnabled] = React.useState(true);
|
||||
const [mutedWordTags, setMutedWordTags] = React.useState([]);
|
||||
const [moderatorTags, setModeratorTags] = React.useState([]);
|
||||
const [moderatorSearchTerm, setModeratorSearchTerm] = React.useState('');
|
||||
const [moderatorSearchError, setModeratorSearchError] = React.useState('');
|
||||
const [moderatorSearchClaimUri, setModeratorSearchClaimUri] = React.useState('');
|
||||
const [moderatorUris, setModeratorUris] = React.useState([]);
|
||||
const [minTip, setMinTip] = React.useState(0);
|
||||
const [minSuper, setMinSuper] = React.useState(0);
|
||||
const [slowModeMin, setSlowModeMin] = React.useState(0);
|
||||
const [lastUpdated, setLastUpdated] = React.useState(1);
|
||||
|
||||
const pushSlowModeMinDebounced = React.useMemo(() => debounce(pushSlowModeMin, 1000), []);
|
||||
const pushMinTipDebounced = React.useMemo(() => debounce(pushMinTip, 1000), []);
|
||||
const pushMinSuperDebounced = React.useMemo(() => debounce(pushMinSuper, 1000), []);
|
||||
const pushSlowModeMinDebounced = React.useMemo(() => debounce(pushSlowModeMin, 1000), []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
const pushMinTipDebounced = React.useMemo(() => debounce(pushMinTip, 1000), []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
const pushMinSuperDebounced = React.useMemo(() => debounce(pushMinSuper, 1000), []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
@@ -79,8 +71,8 @@ export default function SettingsCreatorPage(props: Props) {
|
||||
* Updates corresponding GUI states with the given PerChannelSettings values.
|
||||
*
|
||||
* @param settings
|
||||
* @param fullSync If true, update all states and consider 'undefined' settings as "cleared/false";
|
||||
* if false, only update defined settings.
|
||||
* @param fullSync If true, update all states and consider 'undefined'
|
||||
* settings as "cleared/false"; if false, only update defined settings.
|
||||
*/
|
||||
function settingsToStates(settings: PerChannelSettings, fullSync: boolean) {
|
||||
const doSetMutedWordTags = (words: Array<string>) => {
|
||||
@@ -137,6 +129,31 @@ export default function SettingsCreatorPage(props: Props) {
|
||||
updateCreatorSettings(activeChannelClaim, { min_tip_amount_super_chat: value });
|
||||
}
|
||||
|
||||
function parseModUri(uri) {
|
||||
try {
|
||||
return parseURI(uri);
|
||||
} catch (e) {}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function handleModeratorAdded(channelUri: string) {
|
||||
setModeratorUris([...moderatorUris, channelUri]);
|
||||
const parsedUri = parseModUri(channelUri);
|
||||
if (parsedUri && parsedUri.claimId && parsedUri.claimName) {
|
||||
commentModAddDelegate(parsedUri.claimId, parsedUri.claimName, activeChannelClaim);
|
||||
setLastUpdated(Date.now());
|
||||
}
|
||||
}
|
||||
|
||||
function handleModeratorRemoved(channelUri: string) {
|
||||
setModeratorUris(moderatorUris.filter((x) => x !== channelUri));
|
||||
const parsedUri = parseModUri(channelUri);
|
||||
if (parsedUri && parsedUri.claimId && parsedUri.claimName) {
|
||||
commentModRemoveDelegate(parsedUri.claimId, parsedUri.claimName, activeChannelClaim);
|
||||
setLastUpdated(Date.now());
|
||||
}
|
||||
}
|
||||
|
||||
function addMutedWords(newTags: Array<Tag>) {
|
||||
const validatedNewTags = [];
|
||||
newTags.forEach((newTag) => {
|
||||
@@ -162,74 +179,9 @@ export default function SettingsCreatorPage(props: Props) {
|
||||
setLastUpdated(Date.now());
|
||||
}
|
||||
|
||||
function addModerator(newTags: Array<Tag>) {
|
||||
// Ignoring multiple entries for now, although <TagsSearch> supports it.
|
||||
let modUri;
|
||||
try {
|
||||
modUri = parseURI(newTags[0].name);
|
||||
} catch (e) {}
|
||||
|
||||
if (modUri && modUri.isChannel && modUri.claimName && modUri.claimId) {
|
||||
if (!moderatorTags.some((modTag) => modTag.name === newTags[0].name)) {
|
||||
setModeratorTags([...moderatorTags, newTags[0]]);
|
||||
commentModAddDelegate(modUri.claimId, modUri.claimName, activeChannelClaim);
|
||||
setLastUpdated(Date.now());
|
||||
}
|
||||
} else {
|
||||
doToast({ message: __('Invalid channel URL "%url%"', { url: newTags[0].name }), isError: true });
|
||||
}
|
||||
}
|
||||
|
||||
function removeModerator(tagToRemove: Tag) {
|
||||
let modUri;
|
||||
try {
|
||||
modUri = parseURI(tagToRemove.name);
|
||||
} catch (e) {}
|
||||
|
||||
if (modUri && modUri.isChannel && modUri.claimName && modUri.claimId) {
|
||||
const newModeratorTags = moderatorTags.slice().filter((t) => t.name !== tagToRemove.name);
|
||||
setModeratorTags(newModeratorTags);
|
||||
commentModRemoveDelegate(modUri.claimId, modUri.claimName, activeChannelClaim);
|
||||
setLastUpdated(Date.now());
|
||||
}
|
||||
}
|
||||
|
||||
function handleChannelSearchSelect(claim) {
|
||||
if (claim && claim.name && claim.claim_id) {
|
||||
addModerator([{ name: claim.name + '#' + claim.claim_id }]);
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// **************************************************************************
|
||||
|
||||
// 'moderatorSearchTerm' to 'moderatorSearchClaimUri'
|
||||
React.useEffect(() => {
|
||||
if (!moderatorSearchTerm) {
|
||||
setModeratorSearchError('');
|
||||
setModeratorSearchClaimUri('');
|
||||
} else {
|
||||
const [searchUri, error] = getUriForSearchTerm(moderatorSearchTerm);
|
||||
setModeratorSearchError(error ? __('Something not quite right..') : '');
|
||||
|
||||
try {
|
||||
const { streamName, channelName, isChannel } = parseURI(searchUri);
|
||||
|
||||
if (!isChannel && streamName && isNameValid(streamName)) {
|
||||
setModeratorSearchError(__('Not a channel (prefix with "@", or enter the channel URL)'));
|
||||
setModeratorSearchClaimUri('');
|
||||
} else if (isChannel && channelName && isNameValid(channelName)) {
|
||||
setModeratorSearchClaimUri(searchUri);
|
||||
}
|
||||
} catch (e) {
|
||||
if (moderatorSearchTerm !== '@') {
|
||||
setModeratorSearchError('');
|
||||
}
|
||||
setModeratorSearchClaimUri('');
|
||||
}
|
||||
}
|
||||
}, [moderatorSearchTerm, setModeratorSearchError]);
|
||||
|
||||
// Update local moderator states with data from API.
|
||||
React.useEffect(() => {
|
||||
commentModListDelegates(activeChannelClaim);
|
||||
@@ -239,15 +191,9 @@ export default function SettingsCreatorPage(props: Props) {
|
||||
if (activeChannelClaim) {
|
||||
const delegates = moderationDelegatesById[activeChannelClaim.claim_id];
|
||||
if (delegates) {
|
||||
setModeratorTags(
|
||||
delegates.map((d) => {
|
||||
return {
|
||||
name: d.channelName + '#' + d.channelId,
|
||||
};
|
||||
})
|
||||
);
|
||||
setModeratorUris(delegates.map((d) => `${d.channelName}#${d.channelId}`));
|
||||
} else {
|
||||
setModeratorTags([]);
|
||||
setModeratorUris([]);
|
||||
}
|
||||
}
|
||||
}, [activeChannelClaim, moderationDelegatesById]);
|
||||
@@ -400,6 +346,17 @@ export default function SettingsCreatorPage(props: Props) {
|
||||
/>
|
||||
</SettingsRow>
|
||||
|
||||
<SettingsRow title={__('Moderators')} subtitle={__(HELP.MODERATORS)} multirow>
|
||||
<SearchChannelField
|
||||
label={__('Moderators')}
|
||||
labelAddNew={__('Add moderator')}
|
||||
labelFoundAction={__('Add')}
|
||||
values={moderatorUris}
|
||||
onAdd={handleModeratorAdded}
|
||||
onRemove={handleModeratorRemoved}
|
||||
/>
|
||||
</SettingsRow>
|
||||
|
||||
<SettingsRow title={__('Filter')} subtitle={__(HELP.BLOCKED_WORDS)} multirow>
|
||||
<div className="tag--blocked-words">
|
||||
<TagsSearch
|
||||
@@ -416,67 +373,6 @@ export default function SettingsCreatorPage(props: Props) {
|
||||
/>
|
||||
</div>
|
||||
</SettingsRow>
|
||||
|
||||
<SettingsRow title={__('Moderators')} subtitle={__(HELP.MODERATORS)} multirow>
|
||||
<div className="tag--blocked-words">
|
||||
<TagsSearch
|
||||
label={__('Moderators')}
|
||||
labelAddNew={__('Add moderator')}
|
||||
onRemove={removeModerator}
|
||||
onSelect={addModerator}
|
||||
tagsPassedIn={moderatorTags}
|
||||
disableAutoFocus
|
||||
hideInputField
|
||||
hideSuggestions
|
||||
disableControlTags
|
||||
/>
|
||||
<FormField
|
||||
type="text"
|
||||
name="moderator_search"
|
||||
className="form-field--address"
|
||||
label={
|
||||
<>
|
||||
{__('Search channel')}
|
||||
<Icon
|
||||
customTooltipText={__(HELP.MODERATOR_SEARCH)}
|
||||
className="icon--help"
|
||||
icon={ICONS.HELP}
|
||||
tooltip
|
||||
size={16}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
placeholder={__('Enter a @username or URL')}
|
||||
value={moderatorSearchTerm}
|
||||
onChange={(e) => setModeratorSearchTerm(e.target.value)}
|
||||
error={moderatorSearchError}
|
||||
/>
|
||||
{moderatorSearchClaimUri && (
|
||||
<div className="section">
|
||||
<ClaimPreview
|
||||
key={moderatorSearchClaimUri}
|
||||
uri={moderatorSearchClaimUri}
|
||||
// type={'small'}
|
||||
// showNullPlaceholder
|
||||
hideMenu
|
||||
hideRepostLabel
|
||||
disableNavigation
|
||||
properties={''}
|
||||
renderActions={(claim) => {
|
||||
return (
|
||||
<Button
|
||||
requiresAuth
|
||||
button="primary"
|
||||
label={__('Add as moderator')}
|
||||
onClick={() => handleChannelSearchSelect(claim)}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</SettingsRow>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
Loaded 100 of 132 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user