Compare commits

..
Author SHA1 Message Date
zeppi 52800e8fd6 test api 2021-06-18 10:29:18 -04:00
80 changed files with 452 additions and 2638 deletions

No files matched your search

+1 -42
View File
@@ -37,19 +37,10 @@ declare type CommentsState = {
myReactsByCommentId: any,
othersReactsByCommentId: any,
pendingCommentReactions: Array<string>,
moderationBlockList: ?Array<string>, // @KP rename to "personalBlockList"?
adminBlockList: ?Array<string>,
moderatorBlockList: ?Array<string>,
moderatorBlockListDelegatorsMap: {[string]: Array<string>}, // {"blockedUri": ["delegatorUri1", ""delegatorUri2", ...]}
moderationBlockList: ?Array<string>,
fetchingModerationBlockList: boolean,
moderationDelegatesById: { [string]: Array<{ channelId: string, channelName: string }> },
fetchingModerationDelegates: boolean,
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } }},
fetchingModerationDelegators: boolean,
blockingByUri: {},
unBlockingByUri: {},
togglingForDelegatorMap: {[string]: Array<string>}, // {"blockedUri": ["delegatorUri1", ""delegatorUri2", ...]}
commentsDisabledChannelIds: Array<string>,
settingsByChannelId: { [string]: PerChannelSettings }, // ChannelID -> settings
fetchingSettings: boolean,
fetchingBlockedWords: boolean,
@@ -96,38 +87,6 @@ declare type SuperListParams = {};
declare type ModerationBlockParams = {};
declare type ModerationAddDelegateParams = {
mod_channel_id: string,
mod_channel_name: string,
creator_channel_id: string,
creator_channel_name: string,
signature: string,
signing_ts: string,
};
declare type ModerationRemoveDelegateParams = {
mod_channel_id: string,
mod_channel_name: string,
creator_channel_id: string,
creator_channel_name: string,
signature: string,
signing_ts: string,
};
declare type ModerationListDelegatesParams = {
creator_channel_id: string,
creator_channel_name: string,
signature: string,
signing_ts: string,
};
declare type ModerationAmIParams = {
channel_name: string,
channel_id: string,
signature: string,
signing_ts: string
};
declare type SettingsParams = {
channel_name: string,
channel_id: string,
-1
View File
@@ -23,5 +23,4 @@ declare type LivestreamReplayData = Array<LivestreamReplayItem>;
declare type LivestreamState = {
fetchingById: {},
viewersById: {},
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lbry",
"version": "0.50.3-rc.3",
"version": "0.50.3-rc.1",
"description": "A browser for the LBRY network, a digital marketplace controlled by its users.",
"keywords": [
"lbry"
+17 -61
View File
@@ -852,7 +852,6 @@
"Last Updated": "Last Updated",
"Are you sure? Type %name% to confirm that you wish to delete the channel.": "Are you sure? Type %name% to confirm that you wish to delete the channel.",
"You're about to permanently delete a channel. Content published under this channel will be orphaned and their signing channel invalid. Content sync programs using this channel will fail.": "You're about to permanently delete a channel. Content published under this channel will be orphaned and their signing channel invalid. Content sync programs using this channel will fail.",
"Are you sure you'd like to remove \"%title%\"?": "Are you sure you'd like to remove \"%title%\"?",
"You are signed into lbry.tv which automatically shares data with LBRY inc. %signout_button%.": "You are signed into lbry.tv which automatically shares data with LBRY inc. %signout_button%.",
"LBRY works better if you find and follow a couple creators you like. You can also block channels you never want to see.": "LBRY works better if you find and follow a couple creators you like. You can also block channels you never want to see.",
"Nice! You are currently following %followingCount% creator": "Nice! You are currently following %followingCount% creator",
@@ -1201,7 +1200,6 @@
"Channel to show support as": "Channel to show support as",
"Buy more LBRY Credits": "Buy more LBRY Credits",
"Buy or swap more LBRY Credits": "Buy or swap more LBRY Credits",
"Buy or Swap": "Buy or Swap",
"Support this content": "Support this content",
"Custom support amount": "Custom support amount",
"(%lbc_balance% Credits available)": "(%lbc_balance% Credits available)",
@@ -1291,7 +1289,6 @@
"Check the status of various LBRY services.": "Check the status of various LBRY services.",
"Check Status": "Check Status",
"Upload your thumbnail to %domain%. Recommended size is 16:9.": "Upload your thumbnail to %domain%. Recommended size is 16:9.",
"(16:9)": "(16:9)",
"Are you sure you want to upload this thumbnail to %domain%": "Are you sure you want to upload this thumbnail to %domain%",
"View thumbnail": "View thumbnail",
"These changes will appear shortly.": "These changes will appear shortly.",
@@ -1301,7 +1298,7 @@
"Blocked": "Blocked",
"Unblock": "Unblock",
"Unblocking...": "Unblocking...",
"Channel \"%channel%\" blocked.": "Channel \"%channel%\" blocked.",
"Channel blocked. You will not see them again.": "Channel blocked. You will not see them again.",
"Mute Channel": "Mute Channel",
"Unmute Channel": "Unmute Channel",
"Muted": "Muted",
@@ -1587,9 +1584,6 @@
"This link leads to an external website.": "This link leads to an external website.",
"No Content Found": "No Content Found",
"No Lists Found": "No Lists Found",
"You have no lists! Create one from any playable content.": "You have no lists! Create one from any playable content.",
"Pick": "Pick",
"You have unpublished lists! %pick% one and publish it!": "You have unpublished lists! %pick% one and publish it!",
"No Reposts Found": "No Reposts Found",
"Publish Something": "Publish Something",
"Repost Something": "Repost Something",
@@ -1677,8 +1671,7 @@
"%balance% available.": "%balance% available.",
"Unlock all tips": "Unlock all tips",
"Unlock All": "Unlock All",
"Working...": "Working...",
"this cave is not a natural formation": "this cave is not a natural formation",
"just like the simulations": "just like the simulations",
"Moon cheese is an acquired taste": "Moon cheese is an acquired taste",
"Nothing found here. Like big tech ethics.": "Nothing found here. Like big tech ethics.",
"Level %current_level%": "Level %current_level%",
@@ -1690,32 +1683,13 @@
"Transaction limit reached. Try reducing the Description length.": "Transaction limit reached. Try reducing the Description length.",
"You do not have any muted channels": "You do not have any muted channels",
"You do not have any blocked channels": "You do not have any blocked channels",
"You do not have any globally-blocked channels": "You do not have any globally-blocked channels",
"You do not have any blocked channels as a moderator": "You do not have any blocked channels as a moderator",
"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.": "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.",
"Blocked channels will be invisible to you in the app. They will not be able to comment on your content, or reply to you comments left on other channels' content.": "Blocked channels will be invisible to you in the app. They will not be able to comment on your content, or reply to you comments left on other channels' content.",
"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.": "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.",
"List of channels that you have blocked as a moderator. To unblock a channel, notify the content creator.": "List of channels that you have blocked as a moderator. To unblock a channel, notify the content creator.",
"This is the global block list.": "This is the global block list.",
"This channel is blocked": "This channel is blocked",
"This channel is muted": "This channel is muted",
"Are you sure you want to view this content? Viewing will not unblock @%channel%": "Are you sure you want to view this content? Viewing will not unblock @%channel%",
"Are you sure you want to view this content? Viewing will not unmute @%channel%": "Are you sure you want to view this content? Viewing will not unmute @%channel%",
"View Content": "View Content",
"Global": "Global",
"Moderator": "Moderator",
"Global Unblock Channel": "Global Unblock Channel",
"Global Block Channel": "Global Block Channel",
"Moderator tools": "Moderator tools",
"Global Block": "Global Block",
"Block this channel as global admin": "Block this channel as global admin",
"Moderator Block": "Moderator Block",
"Block this channel on behalf of %creator%": "Block this channel on behalf of %creator%",
"creator": "creator",
"Invalid channel URL \"%url%\"": "Invalid channel URL \"%url%\"",
"Delegation": "Delegation",
"Add moderator": "Add moderator",
"Add moderators": "Add moderators",
"Add moderator channel URL (e.g. \"@lbry#3f\")": "Add moderator channel URL (e.g. \"@lbry#3f\")",
"Mute (m)": "Mute (m)",
"Playback Rate (<, >)": "Playback Rate (<, >)",
"Fullscreen (f)": "Fullscreen (f)",
@@ -1739,7 +1713,6 @@
"Stay up to date on the latest content from your favorite creators.": "Stay up to date on the latest content from your favorite creators.",
"Receive tutorial emails related to LBRY ": "Receive tutorial emails related to LBRY ",
"Create A LiveStream": "Create A LiveStream",
"This channel": "This channel",
"%channel% has disabled chat for this stream. Enjoy the stream!": "%channel% has disabled chat for this stream. Enjoy the stream!",
"%channel% isn't live right now, but the chat is! Check back later to watch the stream.": "%channel% isn't live right now, but the chat is! Check back later to watch the stream.",
"Right now": "Right now",
@@ -1759,8 +1732,8 @@
"Check again...": "Check again...",
"You need to upload your livestream details before you can go live. If you already created one in this channel, it should appear soon.": "You need to upload your livestream details before you can go live. If you already created one in this channel, it should appear soon.",
"Create A Livestream": "Create A Livestream",
"Create a Livestream by first submitting your livestream details and waiting for approval confirmation. This can be done well in advance and will take a few minutes.": "Create a Livestream by first submitting your livestream details and waiting for approval confirmation. This can be done well in advance and will take a few minutes.",
"The livestream will not be visible on your channel page until you are live, but you can share the URL in advance.": "The livestream will not be visible on your channel page until you are live, but you can share the URL in advance.",
"Create a Livestream by first submitting your Livestream details and waiting for approval confirmation.": "Create a Livestream by first submitting your Livestream details and waiting for approval confirmation.",
"The livestream will not be visible on your channel until you are live, but you can share the URL in advance.": "The livestream will not be visible on your channel until you are live, but you can share the URL in advance.",
"Once the your livestream is confirmed, configure your streaming software (OBS, Restream, etc) and input the server URL along with the stream key in it.": "Once the your livestream is confirmed, configure your streaming software (OBS, Restream, etc) and input the server URL along with the stream key in it.",
"To ensure the best streaming experience with OBS, open settings -> output": "To ensure the best streaming experience with OBS, open settings -> output",
"Select advanced mode from the dropdown at the top.": "Select advanced mode from the dropdown at the top.",
@@ -1769,13 +1742,12 @@
"Keyframes: 1": "Keyframes: 1",
"Profile: High": "Profile: High",
"Tune: Zerolatency": "Tune: Zerolatency",
"If using other streaming software, make sure the bitrate is below 4500 kbps or the stream will not work.": "If using other streaming software, make sure the bitrate is below 4500 kbps or the stream will not work.",
"After your stream:\nClick the Update button on the content page. This will allow you to select a replay or upload your own edited MP4. Replays are limited to 4 hours and may take a few minutes to show (use the Check For Replays button).": "After your stream:\nClick the Update button on the content page. This will allow you to select a replay or upload your own edited MP4. Replays are limited to 4 hours and may take a few minutes to show (use the Check For Replays button).",
"Click Save, then confirm, and you are done!": "Click Save, then confirm, and you are done!",
"Note: If you don't plan on publishing your replay, you'll want to delete your livestream and then start with a fresh one next time.": "Note: If you don't plan on publishing your replay, you'll want to delete your livestream and then start with a fresh one next time.",
"If using other livestreaming software, make sure the bitrate is below 5000 kbps or the stream will not work.": "If using other livestreaming software, make sure the bitrate is below 5000 kbps or the stream will not work.",
"Please note: You'll need to record your own stream through your software if you plan to share it afterward. You can also delete it if you prefer not to upload the copy.": "Please note: You'll need to record your own stream through your software if you plan to share it afterward. You can also delete it if you prefer not to upload the copy.",
"In the near future, this manual step will be removed and you will be able to share the stream right after its finished without needing to record it yourself.": "In the near future, this manual step will be removed and you will be able to share the stream right after its finished without needing to record it yourself.",
"After your livestream:\nClick the Publish Replay button. This will allow you to edit details before sharing on Odysee. Be sure to select the saved mp4 file you recorded.": "After your livestream:\nClick the Publish Replay button. This will allow you to edit details before sharing on Odysee. Be sure to select the saved mp4 file you recorded.",
"Click Save and you are done!": "Click Save and you are done!",
"How does this work?": "How does this work?",
"Introducing Lists": "Introducing Lists",
"You have no lists yet. Better start hoarding!": "You have no lists yet. Better start hoarding!",
"Update your livestream": "Update your livestream",
"Prepare an upcoming livestream": "Prepare an upcoming livestream",
"Edit your post": "Edit your post",
@@ -1911,13 +1883,13 @@
"Enabling a minimum amount to hyperchat will force all TIPPED comments to have this value in order to be shown. This still allows regular comments to be posted.": "Enabling a minimum amount to hyperchat will force all TIPPED comments to have this value in order to be shown. This still allows regular comments to be posted.",
"Settings unavailable for this channel": "Settings unavailable for this channel",
"This channel isn't staking enough LBRY Credits to enable Creator Settings.": "This channel isn't staking enough LBRY Credits to enable Creator Settings.",
"Not a channel (prefix with \"@\", or enter the channel URL)": "Not a channel (prefix with \"@\", or enter the channel URL)",
"We apologize for this inconvenience, but have added this additional step to prevent abuse. Users on VPN or shared connections will continue to see this message and are not eligible for Rewards.": "We apologize for this inconvenience, but have added this additional step to prevent abuse. Users on VPN or shared connections will continue to see this message and are not eligible for Rewards.",
"Help LBRY Save Crypto": "Help LBRY Save Crypto",
"The US government is attempting to destroy the cryptocurrency industry. Can you help?": "The US government is attempting to destroy the cryptocurrency industry. Can you help?",
"Learn more and sign petition": "Learn more and sign petition",
"View claim details": "View claim details",
"Publishing...": "Publishing...",
"Collection": "Collection",
"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",
@@ -1952,16 +1924,14 @@
"%SITE_NAME% login": "%SITE_NAME% login",
"Lists": "Lists",
"Watch Later": "Watch Later",
"Favorites": "Favorites",
"New List": "New List",
"New List Title": "New List Title",
"Add to Lists": "Add to Lists",
"Nothing in %collection_name%": "Nothing in %collection_name%",
"Playlists": "Playlists",
"Edit List": "Edit List",
"Delete List": "Delete List",
"Private": "Private",
"View List": "View List",
"Publish List": "Publish List",
"Delete Collection": "Delete Collection",
"Info": "Info",
"Publishes": "Publishes",
"Add To...": "Add To...",
@@ -1970,10 +1940,9 @@
"List": "List",
"Items": "Items",
"Credits": "Credits",
"Cannot publish empty list": "Cannot publish empty list",
"MyAwesomeList": "MyAwesomeList",
"My Awesome List": "My Awesome List",
"This list has no items.": "This list has no items.",
"MyAwesomeCollection": "MyAwesomeCollection",
"My Awesome Collection": "My Awesome Collection",
"This collection has no items.": "This collection has no items.",
"Select File": "Select File",
"File Selected": "File Selected",
"Url": "Url",
@@ -1981,20 +1950,7 @@
"Keep": "Keep",
"Add this claim to a list": "Add this claim to a list",
"List is Empty": "List is Empty",
"Confirm List Unpublish": "Confirm List Unpublish",
"Confirm Collection Unpublish": "Confirm Collection Unpublish",
"This will permanently delete the list.": "This will permanently delete the list.",
"Everyone starts with 2 private lists - Watch Later and Favorites.": "Everyone starts with 2 private lists - Watch Later and Favorites.",
"Add content to existing lists or new lists from content pages or content previews.": "Add content to existing lists or new lists from content pages or content previews.",
"By default, lists are private. You can edit them and later publish them from the Lists page or the Publish context menu on this page. Similar to uploads, small blockchain fees apply.": "By default, lists are private. You can edit them and later publish them from the Lists page or the Publish context menu on this page. Similar to uploads, small blockchain fees apply.",
"Chat": "Chat",
"Tipped": "Tipped",
"Fromage": "Fromage",
"added to": "added to",
"Item %action% Watch Later": "Item %action% Watch Later",
"In Watch Later": "In Watch Later",
"Item added to Watch Later": "Item added to Watch Later",
"Your publish is being confirmed and will be live soon": "Your publish is being confirmed and will be live soon",
"Clear Edits": "Clear Edits",
"Something not quite right..": "Something not quite right..",
"--end--": "--end--"
}
-6
View File
@@ -8,12 +8,6 @@ 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_add_delegate: (params: ModerationAddDelegateParams) => fetchCommentsApi('moderation.AddDelegate', params),
moderation_remove_delegate: (params: ModerationRemoveDelegateParams) =>
fetchCommentsApi('moderation.RemoveDelegate', params),
moderation_list_delegates: (params: ModerationListDelegatesParams) =>
fetchCommentsApi('moderation.ListDelegates', params),
moderation_am_i: (params: ModerationAmIParams) => fetchCommentsApi('moderation.AmI', params),
comment_list: (params: CommentListParams) => fetchCommentsApi('comment.List', params),
comment_abandon: (params: CommentAbandonParams) => fetchCommentsApi('comment.Abandon', params),
comment_create: (params: CommentCreateParams) => fetchCommentsApi('comment.Create', params),
+2 -12
View File
@@ -5,14 +5,7 @@ import { selectGetSyncErrorMessage, selectSyncFatalError } from 'redux/selectors
import { doFetchAccessToken, doUserSetReferrer } from 'redux/actions/user';
import { selectUser, selectAccessToken, selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
import {
doFetchChannelListMine,
doFetchCollectionListMine,
SETTINGS,
selectMyChannelUrls,
doResolveUris,
} from 'lbry-redux';
import { selectSubscriptions } from 'redux/selectors/subscriptions';
import { doFetchChannelListMine, doFetchCollectionListMine, SETTINGS, selectMyChannelUrls } from 'lbry-redux';
import {
makeSelectClientSetting,
selectLanguage,
@@ -34,7 +27,7 @@ import {
doSetActiveChannel,
doSetIncognito,
} from 'redux/actions/app';
import { doFetchModBlockedList, doFetchCommentModAmIList } from 'redux/actions/comments';
import { doFetchModBlockedList } from 'redux/actions/comments';
import App from './view';
const select = (state) => ({
@@ -54,7 +47,6 @@ const select = (state) => ({
syncFatalError: selectSyncFatalError(state),
activeChannelClaim: selectActiveChannelClaim(state),
myChannelUrls: selectMyChannelUrls(state),
subscriptions: selectSubscriptions(state),
});
const perform = (dispatch) => ({
@@ -71,8 +63,6 @@ const perform = (dispatch) => ({
setActiveChannelIfNotSet: () => dispatch(doSetActiveChannel()),
setIncognito: () => dispatch(doSetIncognito()),
fetchModBlockedList: () => dispatch(doFetchModBlockedList()),
resolveUris: (uris) => dispatch(doResolveUris(uris)),
fetchModAmIList: () => dispatch(doFetchCommentModAmIList()),
});
export default hot(connect(select, perform)(App));
+3 -24
View File
@@ -1,6 +1,6 @@
// @flow
import * as PAGES from 'constants/pages';
import React, { useEffect, useRef, useState, useLayoutEffect } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import classnames from 'classnames';
import analytics from 'analytics';
import { buildURI, parseURI } from 'lbry-redux';
@@ -30,7 +30,6 @@ import OpenInAppLink from 'web/component/openInAppLink';
import YoutubeWelcome from 'web/component/youtubeReferralWelcome';
import NagDegradedPerformance from 'web/component/nag-degraded-performance';
import NagDataCollection from 'web/component/nag-data-collection';
import NagNoUser from 'web/component/nag-no-user';
import {
useDegradedPerformance,
STATUS_OK,
@@ -80,16 +79,14 @@ type Props = {
isAuthenticated: boolean,
socketConnect: () => void,
syncLoop: (?boolean) => void,
syncEnabled: boolean,
currentModal: any,
syncFatalError: boolean,
activeChannelClaim: ?ChannelClaim,
myChannelUrls: ?Array<string>,
subscriptions: Array<Subscription>,
setActiveChannelIfNotSet: () => void,
setIncognito: (boolean) => void,
fetchModBlockedList: () => void,
resolveUris: (Array<string>) => void,
fetchModAmIList: () => void,
};
function App(props: Props) {
@@ -122,9 +119,6 @@ function App(props: Props) {
setActiveChannelIfNotSet,
setIncognito,
fetchModBlockedList,
resolveUris,
subscriptions,
fetchModAmIList,
} = props;
const appRef = useRef();
@@ -142,8 +136,6 @@ function App(props: Props) {
// @endif
const { pathname, hash, search } = props.location;
const [upgradeNagClosed, setUpgradeNagClosed] = useState(false);
const [resolvedSubscriptions, setResolvedSubscriptions] = useState(false);
const [sidebarOpen] = usePersistedState('sidebar', true);
const showUpgradeButton =
(autoUpdateDownloaded || (process.platform === 'linux' && isUpgradeAvailable)) && !upgradeNagClosed;
// referral claiming
@@ -158,7 +150,6 @@ function App(props: Props) {
const hasNoChannels = myChannelUrls && myChannelUrls.length === 0;
const shouldMigrateLanguage = LANGUAGE_MIGRATIONS[language];
const hasActiveChannelClaim = activeChannelClaim !== undefined;
const isPersonalized = !IS_WEB || hasVerifiedEmail;
let uri;
try {
@@ -262,7 +253,6 @@ function App(props: Props) {
if (hasMyChannels) {
fetchModBlockedList();
fetchModAmIList();
}
}, [hasMyChannels, hasNoChannels, hasActiveChannelClaim, setActiveChannelIfNotSet, setIncognito]);
@@ -348,16 +338,6 @@ function App(props: Props) {
}
}, [hasVerifiedEmail, signIn, hasSignedIn]);
// batch resolve subscriptions to be used by the sideNavigation component.
// add it here so that it only resolves the first time, despite route changes.
// useLayoutEffect because it has to be executed before the sideNavigation component requests them
useLayoutEffect(() => {
if (sidebarOpen && isPersonalized && subscriptions && !resolvedSubscriptions) {
setResolvedSubscriptions(true);
resolveUris(subscriptions.map((sub) => sub.uri));
}
}, [sidebarOpen, isPersonalized, resolvedSubscriptions, subscriptions, resolveUris, setResolvedSubscriptions]);
// @if TARGET='web'
useDegradedPerformance(setLbryTvApiStatus, user);
// @endif
@@ -366,7 +346,7 @@ function App(props: Props) {
// Require an internal-api user on lbry.tv
// This also prevents the site from loading in the un-authed state while we wait for internal-apis to return for the first time
// It's not needed on desktop since there is no un-authed state
if (user === undefined) {
if (!user) {
return (
<div className="main--empty">
<Spinner delayed />
@@ -431,7 +411,6 @@ function App(props: Props) {
{!SIMPLE_SITE && lbryTvApiStatus === STATUS_OK && showAnalyticsNag && !shouldHideNag && (
<NagDataCollection onClose={handleAnalyticsDismiss} />
)}
{user === null && <NagNoUser />}
{/* @endif */}
</React.Fragment>
)}
+2 -3
View File
@@ -1,12 +1,11 @@
import Button from './view';
import React, { forwardRef } from 'react';
import { connect } from 'react-redux';
import { selectUser, selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
const mapStateToProps = (state) => ({
const mapStateToProps = state => ({
pathname: state.router.location.pathname,
emailVerified: selectUserVerifiedEmail(state),
user: selectUser(state),
});
const ConnectedButton = connect(mapStateToProps)(Button);
+7 -11
View File
@@ -38,7 +38,6 @@ type Props = {
myref: any,
dispatch: any,
'aria-label'?: string,
user: ?User,
};
// use forwardRef to allow consumers to pass refs to the button content if they want to
@@ -70,13 +69,10 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
myref,
dispatch, // <button> doesn't know what to do with dispatch
pathname,
user,
authSrc,
...otherProps
} = props;
const disable = disabled || (user === null && requiresAuth);
const combinedClassName = classnames(
'button',
button
@@ -86,7 +82,7 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
'button--alt': button === 'alt',
'button--inverse': button === 'inverse',
'button--close': button === 'close',
'button--disabled': disable,
'button--disabled': disabled,
'button--link': button === 'link',
}
: 'button--no-style',
@@ -188,12 +184,12 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
return (
<NavLink
exact
onClick={(e) => {
onClick={e => {
e.stopPropagation();
}}
to={redirectUrl}
title={title || defaultTooltip}
disabled={disable}
disabled={disabled}
className={combinedClassName}
activeClassName={activeClass}
>
@@ -207,8 +203,8 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
exact
to={path}
title={title || defaultTooltip}
disabled={disable}
onClick={(e) => {
disabled={disabled}
onClick={e => {
e.stopPropagation();
if (onClick) {
onClick();
@@ -226,13 +222,13 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
title={title || defaultTooltip}
aria-label={description || label || title}
className={combinedClassName}
onClick={(e) => {
onClick={e => {
if (onClick) {
e.stopPropagation();
onClick(e);
}
}}
disabled={disable}
disabled={disabled}
type={type}
{...otherProps}
>
+6 -49
View File
@@ -1,57 +1,14 @@
import { connect } from 'react-redux';
import { makeSelectClaimIdForUri } from 'lbry-redux';
import {
doCommentModUnBlock,
doCommentModBlock,
doCommentModBlockAsAdmin,
doCommentModUnBlockAsAdmin,
doCommentModUnBlockAsModerator,
doCommentModBlockAsModerator,
} from 'redux/actions/comments';
import {
makeSelectChannelIsBlocked,
makeSelectChannelIsAdminBlocked,
makeSelectChannelIsModeratorBlockedForCreator,
makeSelectUriIsBlockingOrUnBlocking,
makeSelectIsTogglingForDelegator,
} from 'redux/selectors/comments';
import { BLOCK_LEVEL } from 'constants/comment';
import { doCommentModUnBlock, doCommentModBlock } from 'redux/actions/comments';
import { makeSelectChannelIsBlocked, makeSelectUriIsBlockingOrUnBlocking } from 'redux/selectors/comments';
import ChannelBlockButton from './view';
const select = (state, props) => {
let isBlocked;
let isToggling;
switch (props.blockLevel) {
default:
case BLOCK_LEVEL.SELF:
isBlocked = makeSelectChannelIsBlocked(props.uri)(state);
break;
case BLOCK_LEVEL.MODERATOR:
isBlocked = makeSelectChannelIsModeratorBlockedForCreator(props.uri, props.creatorUri)(state);
isToggling = makeSelectIsTogglingForDelegator(props.uri, props.creatorUri)(state);
break;
case BLOCK_LEVEL.ADMIN:
isBlocked = makeSelectChannelIsAdminBlocked(props.uri)(state);
break;
}
return {
isBlocked,
isToggling,
isBlockingOrUnBlocking: makeSelectUriIsBlockingOrUnBlocking(props.uri)(state),
creatorId: makeSelectClaimIdForUri(props.creatorUri)(state),
};
};
const select = (state, props) => ({
isBlocked: makeSelectChannelIsBlocked(props.uri)(state),
isBlockingOrUnBlocking: makeSelectUriIsBlockingOrUnBlocking(props.uri)(state),
});
export default connect(select, {
doCommentModUnBlock,
doCommentModBlock,
doCommentModUnBlockAsAdmin,
doCommentModBlockAsAdmin,
doCommentModUnBlockAsModerator,
doCommentModBlockAsModerator,
})(ChannelBlockButton);
+16 -70
View File
@@ -1,95 +1,41 @@
// @flow
import React from 'react';
import Button from 'component/button';
import { BLOCK_LEVEL } from 'constants/comment';
import { parseURI } from 'lbry-redux';
type Props = {
uri: string,
blockLevel?: string,
creatorUri?: string,
isBlocked: boolean,
isBlockingOrUnBlocking: boolean,
isToggling: boolean,
doCommentModUnBlock: (string, boolean) => void,
doCommentModBlock: (string, boolean) => void,
doCommentModUnBlockAsAdmin: (string, string) => void,
doCommentModBlockAsAdmin: (string, string) => void,
doCommentModUnBlockAsModerator: (string, string, string) => void,
doCommentModBlockAsModerator: (string, string, string) => void,
};
function ChannelBlockButton(props: Props) {
const {
uri,
blockLevel,
creatorUri,
doCommentModUnBlock,
doCommentModBlock,
doCommentModUnBlockAsAdmin,
doCommentModBlockAsAdmin,
doCommentModUnBlockAsModerator,
doCommentModBlockAsModerator,
isBlocked,
isBlockingOrUnBlocking,
isToggling,
} = props;
const { uri, doCommentModUnBlock, doCommentModBlock, isBlocked, isBlockingOrUnBlocking } = props;
function handleClick() {
switch (blockLevel) {
default:
case BLOCK_LEVEL.SELF:
if (isBlocked) {
doCommentModUnBlock(uri, false);
} else {
doCommentModBlock(uri, false);
}
break;
case BLOCK_LEVEL.MODERATOR:
if (creatorUri) {
const { channelClaimId } = parseURI(creatorUri);
if (isBlocked) {
doCommentModUnBlockAsModerator(uri, channelClaimId, '');
} else {
doCommentModBlockAsModerator(uri, channelClaimId, '');
}
}
break;
case BLOCK_LEVEL.ADMIN:
if (isBlocked) {
doCommentModUnBlockAsAdmin(uri, '');
} else {
doCommentModBlockAsAdmin(uri, '');
}
break;
if (isBlocked) {
doCommentModUnBlock(uri, false);
} else {
doCommentModBlock(uri, false);
}
}
function getButtonText(blockLevel) {
switch (blockLevel) {
default:
case BLOCK_LEVEL.SELF:
case BLOCK_LEVEL.ADMIN:
return isBlocked
return (
<Button
button={isBlocked ? 'alt' : 'secondary'}
label={
isBlocked
? isBlockingOrUnBlocking
? __('Unblocking...')
: __('Unblock')
: isBlockingOrUnBlocking
? __('Blocking...')
: __('Block');
case BLOCK_LEVEL.MODERATOR:
if (isToggling) {
return isBlocked ? __('Unblocking...') : __('Blocking...');
} else {
return isBlocked ? __('Unblock') : __('Block');
}
}
}
return <Button button={isBlocked ? 'alt' : 'secondary'} label={getButtonText(blockLevel)} onClick={handleClick} />;
? __('Blocking...')
: __('Block')
}
onClick={handleClick}
/>
);
}
export default ChannelBlockButton;
+1 -1
View File
@@ -144,7 +144,7 @@ function ChannelContent(props: Props) {
tileLayout={tileLayout}
uris={searchResults}
streamType={CS.CONTENT_ALL}
channelIds={[claimId]}
channelIds={[claim.claim_id]}
claimType={claimType}
feeAmount={CS.FEE_AMOUNT_ANY}
defaultOrderBy={CS.ORDER_BY_NEW}
+5 -25
View File
@@ -79,15 +79,7 @@ const ClaimCollectionAdd = (props: Props) => {
.filter((list) => (isChannel ? list.type === 'collection' : list.type === 'playlist'))
.map((l) => {
const { id } = l;
return (
<CollectionSelectItem
claim={claim}
collectionId={id}
uri={permanentUrl}
key={id}
category={'builtin'}
/>
);
return <CollectionSelectItem claim={claim} collectionId={id} uri={permanentUrl} key={id} category={'builtin'} />;
})}
{unpublished &&
(Object.values(unpublished): any)
@@ -96,13 +88,7 @@ const ClaimCollectionAdd = (props: Props) => {
.map((l) => {
const { id } = l;
return (
<CollectionSelectItem
claim={claim}
collectionId={id}
uri={permanentUrl}
key={id}
category={'unpublished'}
/>
<CollectionSelectItem claim={claim} collectionId={id} uri={permanentUrl} key={id} category={'unpublished'} />
);
})}
{published &&
@@ -110,13 +96,7 @@ const ClaimCollectionAdd = (props: Props) => {
// $FlowFixMe
const { id } = l;
return (
<CollectionSelectItem
claim={claim}
collectionId={id}
uri={permanentUrl}
key={id}
category={'published'}
/>
<CollectionSelectItem claim={claim} collectionId={id} uri={permanentUrl} key={id} category={'published'} />
);
})}
</div>
@@ -129,7 +109,7 @@ const ClaimCollectionAdd = (props: Props) => {
type="text"
name="new_collection"
value={newCollectionName}
label={__('New List Title')}
label={'New List Title'}
onFocus={onTextareaFocus}
onBlur={onTextareaBlur}
inputButton={
@@ -154,7 +134,7 @@ const ClaimCollectionAdd = (props: Props) => {
/>
)}
{!addNewCollection && (
<Button button={'link'} label={__('New List')} onClick={() => setAddNewCollection(true)} />
<Button button={'link'} label={'New List'} onClick={() => setAddNewCollection(true)} />
)}
</fieldset-section>
<div className="card__actions">
@@ -27,7 +27,7 @@ export default function CollectionAddButton(props: Props) {
className={classnames({ 'button--file-action': fileAction })}
icon={fileAction ? ICONS.ADD : ICONS.LIBRARY}
iconSize={fileAction ? 22 : undefined}
label={uri ? __('Save') : __('New List')}
label={uri ? __('Save') : 'New List'}
requiresAuth={IS_WEB}
title={__('Add this claim to a list')}
onClick={(e) => {
+2 -16
View File
@@ -13,17 +13,8 @@ import {
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
import { doChannelMute, doChannelUnmute } from 'redux/actions/blocked';
import { doSetActiveChannel, doSetIncognito, doOpenModal } from 'redux/actions/app';
import {
doCommentModBlock,
doCommentModUnBlock,
doCommentModBlockAsAdmin,
doCommentModUnBlockAsAdmin,
} from 'redux/actions/comments';
import {
selectHasAdminChannel,
makeSelectChannelIsBlocked,
makeSelectChannelIsAdminBlocked,
} from 'redux/selectors/comments';
import { doCommentModBlock, doCommentModUnBlock } from 'redux/actions/comments';
import { makeSelectChannelIsBlocked } from 'redux/selectors/comments';
import { doToast } from 'redux/actions/notifications';
import { makeSelectSigningIsMine } from 'redux/selectors/content';
import { doChannelSubscribe, doChannelUnsubscribe } from 'redux/actions/subscriptions';
@@ -42,8 +33,6 @@ const select = (state, props) => {
channelIsBlocked: makeSelectChannelIsBlocked(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
isSubscribed: makeSelectIsSubscribed(props.channelUri, true)(state),
channelIsAdminBlocked: makeSelectChannelIsAdminBlocked(props.uri)(state),
isAdmin: selectHasAdminChannel(state),
claimInCollection: makeSelectCollectionForIdHasClaimUrl(props.collectionId, permanentUri)(state),
collectionName: makeSelectNameForCollectionId(props.collectionId)(state),
isMyCollection: makeSelectCollectionIsMine(props.collectionId)(state),
@@ -68,9 +57,6 @@ const perform = (dispatch) => ({
doChannelUnmute: (channelUri) => dispatch(doChannelUnmute(channelUri)),
doCommentModBlock: (channelUri) => dispatch(doCommentModBlock(channelUri)),
doCommentModUnBlock: (channelUri) => dispatch(doCommentModUnBlock(channelUri)),
doCommentModBlockAsAdmin: (commenterUri, blockerId) => dispatch(doCommentModBlockAsAdmin(commenterUri, blockerId)),
doCommentModUnBlockAsAdmin: (commenterUri, blockerId) =>
dispatch(doCommentModUnBlockAsAdmin(commenterUri, blockerId)),
doChannelSubscribe: (subscription) => dispatch(doChannelSubscribe(subscription)),
doChannelUnsubscribe: (subscription) => dispatch(doChannelUnsubscribe(subscription)),
doCollectionEdit: (collection, props) => dispatch(doCollectionEdit(collection, props)),
-25
View File
@@ -29,14 +29,10 @@ type Props = {
inline?: boolean,
channelIsMuted: boolean,
channelIsBlocked: boolean,
channelIsAdminBlocked: boolean,
isAdmin: boolean,
doChannelMute: (string) => void,
doChannelUnmute: (string) => void,
doCommentModBlock: (string) => void,
doCommentModUnBlock: (string) => void,
doCommentModBlockAsAdmin: (string, string) => void,
doCommentModUnBlockAsAdmin: (string, string) => void,
isRepost: boolean,
doCollectionEdit: (string, any) => void,
hasClaimInWatchLater: boolean,
@@ -66,13 +62,9 @@ function ClaimMenuList(props: Props) {
doChannelUnmute,
channelIsMuted,
channelIsBlocked,
channelIsAdminBlocked,
isAdmin,
doCommentModBlock,
doCommentModUnBlock,
isRepost,
doCommentModBlockAsAdmin,
doCommentModUnBlockAsAdmin,
doCollectionEdit,
hasClaimInWatchLater,
collectionId,
@@ -174,14 +166,6 @@ function ClaimMenuList(props: Props) {
openModal(MODALS.SEND_TIP, { uri, isSupport: true });
}
function handleToggleAdminBlock() {
if (channelIsAdminBlocked) {
doCommentModUnBlockAsAdmin(channelUri, '');
} else {
doCommentModBlockAsAdmin(channelUri, '');
}
}
function handleCopyLink() {
navigator.clipboard.writeText(shareUrl);
}
@@ -308,15 +292,6 @@ function ClaimMenuList(props: Props) {
</div>
</MenuItem>
{isAdmin && (
<MenuItem className="comment__menu-option" onSelect={handleToggleAdminBlock}>
<div className="menu__link">
<Icon aria-hidden icon={ICONS.GLOBE} />
{channelIsAdminBlocked ? __('Global Unblock Channel') : __('Global Block Channel')}
</div>
</MenuItem>
)}
<MenuItem className="comment__menu-option" onSelect={handleToggleMute}>
<div className="menu__link">
<Icon aria-hidden icon={ICONS.MUTE} />
+2 -6
View File
@@ -78,7 +78,6 @@ type Props = {
isCollectionMine: boolean,
collectionUris: Array<Collection>,
collectionIndex?: number,
disableNavigation?: boolean,
};
const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
@@ -135,7 +134,6 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
editCollection,
isCollectionMine,
collectionUris,
disableNavigation,
} = props;
const isRepost = claim && claim.repost_channel_url;
const WrapperElement = wrapperElement || 'li';
@@ -216,7 +214,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
onClick(e);
}
if (claim && !pending && !disableNavigation) {
if (claim && !pending) {
history.push(navigateUrl);
}
}
@@ -425,9 +423,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
)}
</div>
</div>
{!hideMenu && (
<ClaimMenuList uri={uri} collectionId={collectionId} channelUri={channelUri} isRepost={isRepost} />
)}
{!hideMenu && <ClaimMenuList uri={uri} collectionId={collectionId} channelUri={channelUri} isRepost={isRepost} />}
</>
</WrapperElement>
);
+1 -2
View File
@@ -286,8 +286,7 @@ function ClaimTilesDiscover(props: Props) {
const modifiedUris = uris ? uris.slice() : [];
const fixUris = [
'lbry://@JungleSurvival#f/incredible-secret-millionaire#a',
'lbry://@JamesJulierArt#0/ipad-painting-tutorial-lava-flow-art-in#8',
'lbry://@AdrianLogan#5/why-i-talk-to-myself#3',
];
if (pin && modifiedUris && modifiedUris.length > 2 && window.location.pathname === '/') {
+2 -2
View File
@@ -11,11 +11,11 @@ import {
selectUpdatingCollection,
selectCreateCollectionError,
selectBalance,
doClearCollectionErrors,
selectCreatingCollection,
makeSelectCollectionForId,
makeSelectUrlsForCollectionId,
makeSelectClaimIdsForCollectionId,
ACTIONS as LBRY_REDUX_ACTIONS,
} from 'lbry-redux';
import { doOpenModal } from 'redux/actions/app';
@@ -47,7 +47,7 @@ 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 }),
clearCollectionErrors: () => dispatch(doClearCollectionErrors()),
});
export default connect(select, perform)(CollectionPage);
+8 -11
View File
@@ -21,7 +21,6 @@ import { INVALID_NAME_ERROR } from 'constants/claim';
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
import * as PAGES from 'constants/pages';
import analytics from 'analytics';
import * as ICONS from '../../constants/icons';
const LANG_NONE = 'none';
const MAX_TAG_SELECT = 5;
@@ -87,7 +86,6 @@ function CollectionForm(props: Props) {
collection,
collectionUrls,
collectionClaimIds,
clearCollectionErrors,
} = props;
const activeChannelName = activeChannelClaim && activeChannelClaim.name;
let prefix = IS_WEB ? `${DOMAIN}/` : 'lbry://';
@@ -165,7 +163,6 @@ function CollectionForm(props: Props) {
React.useEffect(() => {
const collectionClaimIds = JSON.parse(collectionClaimIdsString);
setParams({ ...params, claims: collectionClaimIds });
clearCollectionErrors();
}, [collectionClaimIdsString, setParams]);
function handleLanguageChange(index, code) {
@@ -231,16 +228,12 @@ function CollectionForm(props: Props) {
setParams({ ...params, channel_id: activeChannelId });
}
}, [activeChannelId, incognito, setParams]);
const itemError = !params.claims.length ? __('Cannot publish empty list') : '';
const itemError = !params.claims.length ? __('Cannot publish empty collection') : '';
const submitError = nameError || bidError || itemError || updateError || createError;
return (
<>
<div className={classnames('main--contained', { 'card--disabled': disabled })}>
<div>
<Button button="close" label={__('New')} icon={ICONS.REFRESH} onClick={() => alert()} />
</div>
<Tabs>
<TabList className="tabs__list--collection-edit-page">
<Tab>{__('General')}</Tab>
@@ -271,7 +264,7 @@ function CollectionForm(props: Props) {
autoFocus={isNewCollection}
type="text"
name="channel_name"
placeholder={__('MyAwesomeList')}
placeholder={__('MyAwesomeCollection')}
value={params.name}
error={nameError}
disabled={!isNewCollection}
@@ -286,7 +279,7 @@ function CollectionForm(props: Props) {
type="text"
name="channel_title2"
label={__('Title')}
placeholder={__('My Awesome List')}
placeholder={__('My Awesome Collection')}
value={params.title}
onChange={(e) => setParams({ ...params, title: e.target.value })}
/>
@@ -310,7 +303,11 @@ function CollectionForm(props: Props) {
</div>
</TabPanel>
<TabPanel>
<ClaimList uris={collectionUrls} collectionId={collectionId} empty={__('This list has no items.')} />
<ClaimList
uris={collectionUrls}
collectionId={collectionId}
empty={__('This collection has no items.')}
/>
</TabPanel>
<TabPanel>
<Card
+2 -2
View File
@@ -66,7 +66,7 @@ export default function CollectionsListMine(props: Props) {
navigate={`/$/${PAGES.LIST}/${list.id}`}
label={
<span className="claim-grid__title-span">
{__(`${list.name}`)}
{list.name}
<div className="claim-grid__title--empty">
<Icon className="icon--margin-right" icon={ICONS.STACK} />
{itemUrls.length}
@@ -80,7 +80,7 @@ export default function CollectionsListMine(props: Props) {
)}
{!(itemUrls && itemUrls.length) && (
<h1 className="claim-grid__header claim-grid__title">
{__(`${list.name}`)}
{__('%collection_name%', { collection_name: list.name })}{' '}
<div className="claim-grid__title--empty">(Empty)</div>
</h1>
)}
-2
View File
@@ -10,13 +10,11 @@ import { doOpenModal, doSetActiveChannel } from 'redux/actions/app';
import { doCommentCreate } from 'redux/actions/comments';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import { makeSelectCommentsDisabledForUri } from 'redux/selectors/comments';
import { doToast } from 'redux/actions/notifications';
import { CommentCreate } from './view';
const select = (state, props) => ({
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
commentsDisabledBySettings: makeSelectCommentsDisabledForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
channels: selectMyChannelClaims(state),
isFetchingChannels: selectFetchingMyChannels(state),
+3 -8
View File
@@ -15,7 +15,6 @@ import WalletTipAmountSelector from 'component/walletTipAmountSelector';
import CreditAmount from 'component/common/credit-amount';
import ChannelThumbnail from 'component/channelThumbnail';
import UriIndicator from 'component/uriIndicator';
import Empty from 'component/common/empty';
const COMMENT_SLOW_MODE_SECONDS = 5;
@@ -23,7 +22,6 @@ type Props = {
uri: string,
claim: StreamClaim,
createComment: (string, string, string, ?string) => Promise<any>,
commentsDisabledBySettings: boolean,
channels: ?Array<ChannelClaim>,
onDoneReplying?: () => void,
onCancelReplying?: () => void,
@@ -41,12 +39,12 @@ type Props = {
claimIsMine: boolean,
sendTip: ({}, (any) => void, (any) => void) => void,
justCommented: Array<string>,
commentingEnabled: boolean,
};
export function CommentCreate(props: Props) {
const {
createComment,
commentsDisabledBySettings,
claim,
channels,
onDoneReplying,
@@ -63,6 +61,7 @@ export function CommentCreate(props: Props) {
toast,
claimIsMine,
sendTip,
commentingEnabled,
justCommented,
} = props;
const buttonref: ElementRef<any> = React.useRef();
@@ -194,11 +193,7 @@ export function CommentCreate(props: Props) {
setAdvancedEditor(!advancedEditor);
}
if (commentsDisabledBySettings) {
return <Empty padded text={__('This channel has disabled comments on their page.')} />;
}
if (!hasChannels) {
if (!commentingEnabled || !hasChannels) {
return (
<div
role="button"
+2 -17
View File
@@ -1,20 +1,11 @@
import { connect } from 'react-redux';
import { makeSelectChannelPermUrlForClaimUri, makeSelectClaimIsMine, makeSelectClaimForUri } from 'lbry-redux';
import {
doCommentAbandon,
doCommentPin,
doCommentList,
doCommentModBlock,
doCommentModBlockAsAdmin,
doCommentModBlockAsModerator,
doCommentModAddDelegate,
} from 'redux/actions/comments';
import { doCommentAbandon, doCommentPin, doCommentList, doCommentModBlock } from 'redux/actions/comments';
import { doChannelMute } from 'redux/actions/blocked';
// import { doSetActiveChannel } from 'redux/actions/app';
import { doSetPlayingUri } from 'redux/actions/content';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectPlayingUri } from 'redux/selectors/content';
import { selectModerationDelegatorsById } from 'redux/selectors/comments';
import CommentMenuList from './view';
const select = (state, props) => ({
@@ -23,7 +14,6 @@ const select = (state, props) => ({
contentChannelPermanentUrl: makeSelectChannelPermUrlForClaimUri(props.uri)(state),
activeChannelClaim: selectActiveChannelClaim(state),
playingUri: selectPlayingUri(state),
moderationDelegatorsById: selectModerationDelegatorsById(state),
});
const perform = (dispatch) => ({
@@ -33,12 +23,7 @@ const perform = (dispatch) => ({
pinComment: (commentId, remove) => dispatch(doCommentPin(commentId, remove)),
fetchComments: (uri) => dispatch(doCommentList(uri)),
// 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)),
commentModBlock: (commentAuthor) => dispatch(doCommentModBlock(commentAuthor)),
});
export default connect(select, perform)(CommentMenuList);
-88
View File
@@ -4,11 +4,9 @@ import React from 'react';
import { MenuList, MenuItem } from '@reach/menu-button';
import ChannelThumbnail from 'component/channelThumbnail';
import Icon from 'component/common/icon';
import { parseURI } from 'lbry-redux';
type Props = {
uri: string,
claim: ?Claim,
clearPlayingUri: () => void,
authorUri: string, // full LBRY Channel URI: lbry://@channel#123...
commentId: string, // sha256 digest identifying the comment
@@ -24,19 +22,14 @@ type Props = {
activeChannelClaim: ?ChannelClaim,
isTopLevel: boolean,
commentModBlock: (string) => void,
commentModBlockAsAdmin: (string, string) => void,
commentModBlockAsModerator: (string, string, string) => void,
commentModAddDelegate: (string, string, ChannelClaim) => void,
playingUri: ?PlayingUri,
disableEdit?: boolean,
disableRemove?: boolean,
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
};
function CommentMenuList(props: Props) {
const {
uri,
claim,
authorUri,
commentIsMine,
commentId,
@@ -51,31 +44,11 @@ function CommentMenuList(props: Props) {
handleEditComment,
fetchComments,
commentModBlock,
commentModBlockAsAdmin,
commentModBlockAsModerator,
commentModAddDelegate,
playingUri,
disableEdit,
disableRemove,
moderationDelegatorsById,
} = props;
const contentChannelClaim = !claim
? null
: claim.value_type === 'channel'
? claim
: claim.signing_channel && claim.is_channel_signature_valid
? claim.signing_channel
: null;
const activeModeratorInfo = activeChannelClaim && moderationDelegatorsById[activeChannelClaim.claim_id];
const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl;
const activeChannelIsAdmin = activeChannelClaim && activeModeratorInfo && activeModeratorInfo.global;
const activeChannelIsModerator =
activeChannelClaim &&
contentChannelClaim &&
activeModeratorInfo &&
Object.values(activeModeratorInfo.delegators).includes(contentChannelClaim.claim_id);
function handlePinComment(commentId, remove) {
pinComment(commentId, remove).then(() => fetchComments(uri));
@@ -96,25 +69,6 @@ function CommentMenuList(props: Props) {
muteChannel(authorUri);
}
function assignAsModerator() {
if (activeChannelClaim && authorUri) {
const { channelName, channelClaimId } = parseURI(authorUri);
commentModAddDelegate(channelClaimId, channelName, activeChannelClaim);
}
}
function blockCommentAsModerator() {
if (activeChannelClaim && contentChannelClaim) {
commentModBlockAsModerator(authorUri, contentChannelClaim.claim_id, activeChannelClaim.claim_id);
}
}
function blockCommentAsAdmin() {
if (activeChannelClaim) {
commentModBlockAsAdmin(authorUri, activeChannelClaim.claim_id);
}
}
return (
<MenuList className="menu__list">
{activeChannelIsCreator && <div className="comment__menu-title">{__('Creator tools')}</div>}
@@ -131,20 +85,6 @@ function CommentMenuList(props: Props) {
</MenuItem>
)}
{activeChannelIsCreator && (
<MenuItem className="comment__menu-option" onSelect={assignAsModerator}>
<div className="menu__link">
<Icon aria-hidden icon={ICONS.ADD} />
{__('Add as moderator')}
</div>
<span className="comment__menu-help">
{__('Assign this user to moderate %channel%', {
channel: activeChannelClaim ? activeChannelClaim.name : __('your channel'),
})}
</span>
</MenuItem>
)}
{!disableRemove &&
activeChannelClaim &&
(activeChannelClaim.permanent_url === authorUri ||
@@ -188,34 +128,6 @@ function CommentMenuList(props: Props) {
</MenuItem>
)}
{(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 uri={activeChannelClaim.permanent_url} />
+3 -5
View File
@@ -5,7 +5,6 @@ import {
selectIsFetchingComments,
makeSelectTotalCommentsCountForUri,
selectOthersReactsById,
makeSelectCommentsDisabledForUri,
} from 'redux/selectors/comments';
import { doCommentList, doCommentReactList } from 'redux/actions/comments';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
@@ -19,15 +18,14 @@ const select = (state, props) => ({
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
isFetchingComments: selectIsFetchingComments(state),
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
commentsDisabledBySettings: makeSelectCommentsDisabledForUri(props.uri)(state),
fetchingChannels: selectFetchingMyChannels(state),
reactionsById: selectOthersReactsById(state),
activeChannelId: selectActiveChannelId(state),
});
const perform = (dispatch) => ({
fetchComments: (uri) => dispatch(doCommentList(uri)),
fetchReacts: (uri) => dispatch(doCommentReactList(uri)),
const perform = dispatch => ({
fetchComments: uri => dispatch(doCommentList(uri)),
fetchReacts: uri => dispatch(doCommentReactList(uri)),
});
export default connect(select, perform)(CommentsList);
+2 -6
View File
@@ -16,7 +16,6 @@ import Empty from 'component/common/empty';
type Props = {
comments: Array<Comment>,
commentsDisabledBySettings: boolean,
fetchComments: (string) => void,
fetchReacts: (string) => Promise<any>,
uri: string,
@@ -36,7 +35,6 @@ function CommentList(props: Props) {
fetchReacts,
uri,
comments,
commentsDisabledBySettings,
claimIsMine,
myChannels,
isFetchingComments,
@@ -149,9 +147,7 @@ function CommentList(props: Props) {
}
// Default to newest first for apps that don't have comment reactions
const sortedComments = reactionsById
? sortComments({ comments, reactionsById, sort, isMyComment, justCommented })
: [];
const sortedComments = reactionsById ? sortComments({ comments, reactionsById, sort, isMyComment, justCommented }) : [];
const displayedComments = readyToDisplayComments
? prepareComments(sortedComments, linkedComment).slice(start, end)
: [];
@@ -216,7 +212,7 @@ function CommentList(props: Props) {
<>
<CommentCreate uri={uri} justCommented={justCommented} />
{!commentsDisabledBySettings && !isFetchingComments && hasNoComments && (
{!isFetchingComments && hasNoComments && (
<Empty padded text={__('That was pretty deep. What do you think?')} />
)}
-7
View File
@@ -392,13 +392,6 @@ export const icons = {
<line x1="12" y1="12" x2="12" y2="16" />
</g>
),
[ICONS.GLOBE]: buildIcon(
<g>
<circle cx="12" cy="12" r="10" />
<line x1="2" y1="12" x2="22" y2="12" />
<path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
</g>
),
[ICONS.UNLOCK]: buildIcon(
<g>
<rect x="3" y="11" width="18" height="11" rx="2" ry="2" />
+2 -5
View File
@@ -7,13 +7,12 @@ import {
selectMyChannelClaims,
makeSelectClaimIsStreamPlaceholder,
makeSelectTagInClaimOrChannelForUri,
makeSelectStreamingUrlForUri,
} from 'lbry-redux';
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
import { makeSelectCostInfoForUri } from 'lbryinc';
import { doSetPlayingUri, doPlayUri } from 'redux/actions/content';
import { doSetPlayingUri } from 'redux/actions/content';
import { doToast } from 'redux/actions/notifications';
import { doOpenModal, doSetActiveChannel, doSetIncognito, doAnalyticsView } from 'redux/actions/app';
import { doOpenModal, doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
import fs from 'fs';
import FileActions from './view';
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
@@ -27,7 +26,6 @@ const select = (state, props) => ({
myChannels: selectMyChannelClaims(state),
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
reactionsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
});
const perform = (dispatch) => ({
@@ -44,7 +42,6 @@ const perform = (dispatch) => ({
},
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
doToast: (options) => dispatch(doToast(options)),
download: (uri) => dispatch(doPlayUri(uri, false, true, () => dispatch(doAnalyticsView(uri)))),
});
export default connect(select, perform)(FileActions);
+10 -60
View File
@@ -1,5 +1,5 @@
// @flow
import { SITE_NAME, ENABLE_FILE_REACTIONS } from 'config';
import { SIMPLE_SITE, SITE_NAME, ENABLE_FILE_REACTIONS } from 'config';
import * as PAGES from 'constants/pages';
import * as MODALS from 'constants/modal_types';
import * as ICONS from 'constants/icons';
@@ -13,9 +13,6 @@ import ClaimSupportButton from 'component/claimSupportButton';
import ClaimCollectionAddButton from 'component/claimCollectionAddButton';
import { useHistory } from 'react-router';
import FileReactions from 'component/fileReactions';
import { Menu, MenuButton, MenuList, MenuItem } from '@reach/menu-button';
import Icon from 'component/common/icon';
import { webDownloadClaim } from 'util/downloadClaim';
type Props = {
uri: string,
@@ -32,8 +29,6 @@ type Props = {
hideRepost?: boolean,
isLivestreamClaim: boolean,
reactionsDisabled: boolean,
download: (string) => void,
streamingUrl: ?string,
};
function FileActions(props: Props) {
@@ -52,8 +47,6 @@ function FileActions(props: Props) {
hideRepost,
isLivestreamClaim,
reactionsDisabled,
download,
streamingUrl,
} = props;
const {
push,
@@ -66,8 +59,6 @@ function FileActions(props: Props) {
const claimId = claim && claim.claim_id;
const { signing_channel: signingChannel } = claim;
const channelName = signingChannel && signingChannel.name;
const fileName = claim && claim.value && claim.value.source && claim.value.source.name;
// We want to use the short form uri for editing
// This is what the user is used to seeing, they don't care about the claim id
// We will select the claim id before they publish
@@ -87,22 +78,6 @@ function FileActions(props: Props) {
const urlParams = new URLSearchParams(search);
const collectionId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID);
// @if TARGET='web'
const [downloadClicked, setDownloadClicked] = React.useState(false);
function handleWebDownload() {
// download() causes 'streamingUrl' to be populated.
download(uri);
setDownloadClicked(true);
}
React.useEffect(() => {
if (downloadClicked && streamingUrl) {
webDownloadClaim(streamingUrl, fileName);
}
}, [downloadClicked, streamingUrl, fileName]);
// @endif
function handleRepostClick() {
if (!hasChannels) {
clearPlayingUri();
@@ -143,9 +118,8 @@ function FileActions(props: Props) {
const rhsSection = (
<>
{/* @if TARGET='app' */}
<FileDownloadLink uri={uri} />
{/* @endif */}
{!SIMPLE_SITE && <FileDownloadLink uri={uri} />}
{claimIsMine && (
<Button
className="button--file-action"
@@ -166,38 +140,14 @@ function FileActions(props: Props) {
onClick={() => openModal(MODALS.CONFIRM_FILE_REMOVE, { uri })}
/>
)}
<Menu>
<MenuButton
{!claimIsMine && (
<Button
title={__('Report content')}
className="button--file-action"
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
}}
>
<Icon size={20} icon={ICONS.MORE} />
</MenuButton>
<MenuList className="menu__list">
{/* @if TARGET='web' */}
<MenuItem className="comment__menu-option" onSelect={handleWebDownload}>
<div className="menu__link">
<Icon aria-hidden icon={ICONS.DOWNLOAD} />
{__('Download')}
</div>
</MenuItem>
{/* @endif */}
{!claimIsMine && (
<MenuItem
className="comment__menu-option"
onSelect={() => push(`/$/${PAGES.REPORT_CONTENT}?claimId=${claimId}`)}
>
<div className="menu__link">
<Icon aria-hidden icon={ICONS.REPORT} />
{__('Report content')}
</div>
</MenuItem>
)}
</MenuList>
</Menu>
icon={ICONS.REPORT}
navigate={`/$/${PAGES.REPORT_CONTENT}?claimId=${claimId}`}
/>
)}
</>
);
+10 -2
View File
@@ -3,7 +3,6 @@ import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
import React, { useState } from 'react';
import Button from 'component/button';
import { webDownloadClaim } from 'util/downloadClaim';
type Props = {
uri: string,
@@ -47,7 +46,16 @@ function FileDownloadLink(props: Props) {
// @if TARGET='web'
React.useEffect(() => {
if (didClickDownloadButton && streamingUrl) {
webDownloadClaim(streamingUrl, fileName);
let element = document.createElement('a');
element.setAttribute('href', `${streamingUrl}?download=true`);
element.setAttribute('download', fileName);
element.style.display = 'none';
// $FlowFixMe
document.body.appendChild(element);
element.click();
// $FlowFixMe
document.body.removeChild(element);
setDidClickDownloadButton(false);
}
}, [streamingUrl, didClickDownloadButton, fileName]);
+5 -11
View File
@@ -1,17 +1,11 @@
import { connect } from 'react-redux';
import { makeSelectTitleForUri, makeSelectClaimForUri } from 'lbry-redux';
import { makeSelectTitleForUri } from 'lbry-redux';
import { makeSelectInsufficientCreditsForUri } from 'redux/selectors/content';
import { makeSelectViewersForId } from 'redux/selectors/livestream';
import FileTitleSection from './view';
const select = (state, props) => {
const claim = makeSelectClaimForUri(props.uri)(state);
const viewers = claim && makeSelectViewersForId(claim.claim_id)(state);
return {
viewers,
isInsufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
};
};
const select = (state, props) => ({
isInsufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
});
export default connect(select)(FileTitleSection);
+3 -3
View File
@@ -20,11 +20,11 @@ type Props = {
isNsfwBlocked: boolean,
livestream?: boolean,
isLive?: boolean,
viewers?: number,
activeViewers?: number,
};
function FileTitleSection(props: Props) {
const { title, uri, nsfw, isNsfwBlocked, livestream = false, isLive = false, viewers } = props;
const { title, uri, nsfw, isNsfwBlocked, livestream = false, isLive = false, activeViewers } = props;
const [hasAcknowledgedSec, setHasAcknowledgedSec] = usePersistedState('sec-nag', false);
return (
@@ -56,7 +56,7 @@ function FileTitleSection(props: Props) {
body={
<React.Fragment>
<ClaimInsufficientCredits uri={uri} />
<FileSubtitle uri={uri} isLive={isLive} livestream={livestream} activeViewers={viewers} />
<FileSubtitle uri={uri} isLive={isLive} livestream={livestream} activeViewers={activeViewers} />
</React.Fragment>
}
actions={
+8 -9
View File
@@ -6,7 +6,6 @@ import HelpLink from 'component/common/help-link';
type Props = {
claim: ?StreamClaim,
fetchViewCount: (string) => void,
fetchingViewCount: boolean,
uri: string,
viewCount: string,
livestream?: boolean,
@@ -37,14 +36,14 @@ function FileViewCount(props: Props) {
return (
<span className="media__subtitle--centered">
{livestream &&
__('%viewer_count% currently %viewer_state%', {
viewer_count: activeViewers === undefined ? '...' : activeViewers,
viewer_state: isLive ? __('watching') : __('waiting'),
})}
{!livestream &&
activeViewers === undefined &&
(viewCount !== 1 ? __('%view_count% views', { view_count: formattedViewCount }) : __('1 view'))}
{activeViewers !== undefined
? __('%viewer_count% currently %viewer_state%', {
viewer_count: activeViewers,
viewer_state: isLive ? __('watching') : __('waiting'),
})
: viewCount !== 1
? __('%view_count% views', { view_count: formattedViewCount })
: __('1 view')}
{!SIMPLE_SITE && <HelpLink href="https://lbry.com/faq/views" />}
</span>
);
+2 -8
View File
@@ -172,14 +172,8 @@ const Header = (props: Props) => {
const loginButtons = (
<div className="header__auth-buttons">
<Button
navigate={`/$/${PAGES.AUTH_SIGNIN}`}
button="link"
label={__('Log In')}
className="mobile-hidden"
disabled={user === null}
/>
<Button navigate={`/$/${PAGES.AUTH}`} button="primary" label={__('Sign Up')} disabled={user === null} />
<Button navigate={`/$/${PAGES.AUTH_SIGNIN}`} button="link" label={__('Log In')} className="mobile-hidden" />
<Button navigate={`/$/${PAGES.AUTH}`} button="primary" label={__('Sign Up')} />
</div>
);
+1 -1
View File
@@ -156,7 +156,7 @@ export default function LivestreamComments(props: Props) {
</div>
)}
<div ref={commentsRef} className="livestream__comments-wrapper">
{viewMode === VIEW_MODE_CHAT && superChatsTotalAmount > 0 && superChats && (
{viewMode === VIEW_MODE_CHAT && superChatsTotalAmount > 0 && (
<div className="livestream-superchats__wrapper">
<div className="livestream-superchats__inner">
{superChats.map((superChat: Comment) => (
+3 -2
View File
@@ -9,11 +9,12 @@ type Props = {
uri: string,
claim: ?StreamClaim,
isLive: boolean,
activeViewers: number,
chatDisabled: boolean,
};
export default function LivestreamLayout(props: Props) {
const { claim, uri, isLive, chatDisabled } = props;
const { claim, uri, isLive, activeViewers, chatDisabled } = props;
const isMobile = useIsMobile();
if (!claim || !claim.signing_channel) {
@@ -54,7 +55,7 @@ export default function LivestreamLayout(props: Props) {
{isMobile && <LivestreamComments uri={uri} />}
<FileTitleSection uri={uri} livestream isLive={isLive} />
<FileTitleSection uri={uri} livestream isLive={isLive} activeViewers={activeViewers} />
</div>
</>
);
+6 -3
View File
@@ -80,7 +80,7 @@ function SelectAsset(props: Props) {
}
// Note for translators: e.g. "Thumbnail (1:1)"
const label = `${__(assetName)} ${__(recommended)}`;
const label = __('%image_type% %recommended_ratio%', { image_type: assetName, recommended_ratio: recommended });
const selectFileLabel = __('Select File');
const selectedLabel = pathSelected ? __('URL Selected') : __('File Selected');
@@ -89,7 +89,10 @@ function SelectAsset(props: Props) {
fileSelectorLabel = __('Uploading...');
} else {
// Include the same label/recommendation for both 'URL' and 'UPLOAD'.
fileSelectorLabel = `${label} ${fileSelected || pathSelected ? __(selectedLabel) : __(selectFileLabel)}`;
fileSelectorLabel = __('%label% • %status%', {
label: label,
status: fileSelected || pathSelected ? selectedLabel : selectFileLabel,
});
}
const formBody = (
<>
@@ -100,7 +103,7 @@ function SelectAsset(props: Props) {
className={classnames('button-toggle', {
'button-toggle--active': useUrl, // disable on upload status
})}
label={__('URL')}
label={__('Url')}
onClick={() => {
handleToggleMode(true);
}}
+19 -29
View File
@@ -8,7 +8,6 @@ import classnames from 'classnames';
import Icon from 'component/common/icon';
import NotificationBubble from 'component/notificationBubble';
import I18nMessage from 'component/i18nMessage';
import ChannelThumbnail from 'component/channelThumbnail';
import { PINNED_LABEL_1, PINNED_URI_1, PINNED_URI_2, PINNED_LABEL_2, SIMPLE_SITE, DOMAIN } from 'config';
// @if TARGET='app'
import { IS_MAC } from 'component/app/view';
@@ -295,12 +294,7 @@ function SideNavigation(props: Props) {
Sign up to earn %lbc% for you and your favorite creators.
</I18nMessage>
</span>
<Button
button="secondary"
label={__('Sign Up')}
navigate={`/$/${PAGES.AUTH}?src=sidenav_nudge`}
disabled={user === null}
/>{' '}
<Button button="secondary" label={__('Sign Up')} navigate={`/$/${PAGES.AUTH}?src=sidenav_nudge`} />
</div>
);
@@ -373,8 +367,15 @@ function SideNavigation(props: Props) {
{sidebarOpen && isPersonalized && subscriptions && subscriptions.length > 0 && (
<ul className="navigation__secondary navigation-links">
{subscriptions.map((subscription) => (
<SubscriptionListItem key={subscription.uri} subscription={subscription} />
{subscriptions.map(({ uri, channelName }, index) => (
<li key={uri} className="navigation-link__wrapper">
<Button
navigate={uri}
label={channelName}
className="navigation-link"
activeClass="navigation-link--active"
/>
</li>
))}
</ul>
)}
@@ -449,8 +450,15 @@ function SideNavigation(props: Props) {
</ul>
{sidebarOpen && isPersonalized && subscriptions && subscriptions.length > 0 && (
<ul className="navigation__secondary navigation-links">
{subscriptions.map((subscription) => (
<SubscriptionListItem key={subscription.uri} subscription={subscription} />
{subscriptions.map(({ uri, channelName }, index) => (
<li key={uri} className="navigation-link__wrapper">
<Button
navigate={uri}
label={channelName}
className="navigation-link"
activeClass="navigation-link--active"
/>
</li>
))}
</ul>
)}
@@ -481,22 +489,4 @@ function SideNavigation(props: Props) {
);
}
function SubscriptionListItem({ subscription }: { subscription: Subscription }) {
const { uri, channelName } = subscription;
return (
<li className="navigation-link__wrapper">
<Button
navigate={uri}
className="navigation-link navigation-link--with-thumbnail"
activeClass="navigation-link--active"
>
<ChannelThumbnail uri={uri} hideStakedIndicator />
<span dir="auto" className="button__label">
{channelName}
</span>
</Button>
</li>
);
}
export default SideNavigation;
+1 -2
View File
@@ -41,7 +41,6 @@ function SocialShare(props: Props) {
const { canonical_url: canonicalUrl, permanent_url: permanentUrl, name, claim_id: claimId } = claim;
const isChannel = claim.value_type === 'channel';
const isCollection = claim.value_type === 'collection';
const isStream = claim.value_type === 'stream';
const isVideo = isStream && claim.value.stream_type === 'video';
const isAudio = isStream && claim.value.stream_type === 'audio';
@@ -148,7 +147,7 @@ function SocialShare(props: Props) {
title={__('Share on Facebook')}
href={`https://facebook.com/sharer/sharer.php?u=${encodedLbryURL}`}
/>
{webShareable && !isCollection && !isChannel && (
{webShareable && !isChannel && (
<Button
className="share"
iconSize={24}
+10 -14
View File
@@ -15,7 +15,6 @@ type Props = {
doAddTag: (string) => void,
onSelect?: (Tag) => void,
hideSuggestions?: boolean,
hideInputField?: boolean,
suggestMature?: boolean,
disableAutoFocus?: boolean,
onRemove: (Tag) => void,
@@ -50,7 +49,6 @@ export default function TagsSearch(props: Props) {
onSelect,
onRemove,
hideSuggestions,
hideInputField,
suggestMature,
disableAutoFocus,
placeholder,
@@ -191,18 +189,16 @@ export default function TagsSearch(props: Props) {
/>
))}
</ul>
{!hideInputField && (
<FormField
autoFocus={!disableAutoFocus}
className="tag__input"
onChange={onChange}
placeholder={placeholder || __('gaming, crypto')}
type="text"
value={newTag}
disabled={disabled}
label={labelAddNew || __('Add Tags')}
/>
)}
<FormField
autoFocus={!disableAutoFocus}
className="tag__input"
onChange={onChange}
placeholder={placeholder || __('gaming, crypto')}
type="text"
value={newTag}
disabled={disabled}
label={labelAddNew || __('Add Tags')}
/>
{!hideSuggestions && (
<section>
<label>{labelSuggestions || (newTag.length ? __('Matching') : __('Known Tags'))}</label>
+2 -2
View File
@@ -60,7 +60,7 @@ const ThumbnailPicker = (props: Props) => {
onUpdate={updateThumb}
currentValue={thumbnailParam}
assetName={'Image'}
recommended={__('(16:9)')}
recommended={'(16:9)'}
/>
</div>
</div>
@@ -103,7 +103,7 @@ const ThumbnailPicker = (props: Props) => {
onUpdate={updateThumb}
currentValue={thumbnailParam}
assetName={'Thumbnail'}
recommended={__('(16:9)')}
recommended={'(16:9)'}
/>
</div>
</div>
+1 -3
View File
@@ -9,14 +9,13 @@ import { withRouter } from 'react-router';
import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards';
import { makeSelectClientSetting, selectHomepageData } from 'redux/selectors/settings';
import { toggleVideoTheaterMode, doSetClientSetting } from 'redux/actions/settings';
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
const select = (state, props) => {
const { search } = props.location;
const urlParams = new URLSearchParams(search);
const autoplay = urlParams.get('autoplay');
const position = urlParams.get('t') !== null ? urlParams.get('t') : makeSelectContentPositionForUri(props.uri)(state);
const userId = selectUser(state) && selectUser(state).id;
return {
autoplayIfEmbedded: Boolean(autoplay),
@@ -30,7 +29,6 @@ const select = (state, props) => {
claim: makeSelectClaimForUri(props.uri)(state),
homepageData: selectHomepageData(state),
authenticated: selectUserVerifiedEmail(state),
userId: userId,
};
};
@@ -1,284 +0,0 @@
// Created by xander on 6/21/2021
import videojs from 'video.js/dist/video.min.js';
import { v4 as uuidV4 } from 'uuid';
const VERSION = '0.0.1';
const recsysEndpoint = 'https://clickstream.odysee.com/log/video/view';
const recsysId = 'lighthouse-v0';
/* RecSys */
const RecsysData = {
event: {
start: 0,
stop: 1,
scrub: 2,
speed: 3,
},
};
function createRecsys(claimId, userId, events, loadedAt, isEmbed) {
// TODO: use a UUID generator
const uuid = uuidV4();
const pageLoadedAt = loadedAt;
const pageExitedAt = Date.now();
return {
uuid: uuid,
parentUuid: null,
uid: userId,
claimId: claimId,
pageLoadedAt: pageLoadedAt,
pageExitedAt: pageExitedAt,
recsysId: recsysId,
recClaimIds: null,
recClickedVideoIdx: null,
events: events,
isEmbed: isEmbed,
};
}
function newRecsysEvent(eventType, offset, arg) {
if (arg) {
return {
event: eventType,
offset: offset,
arg: arg,
};
} else {
return {
event: eventType,
offset: offset,
};
}
}
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,
};
const Component = videojs.getComponent('Component');
const registerPlugin = videojs.registerPlugin || videojs.plugin;
class RecsysPlugin extends Component {
constructor(player, options) {
super(player, options);
// Plugin started
if (options.debug) {
this.log(`Created recsys plugin for: videoId:${options.videoId}, userId:${options.userId}`);
}
// 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.lastTimeUpdate = null;
this.currentTimeUpdate = null;
this.loadedAt = Date.now();
this.playInitiated = false;
// Plugin event listeners
player.on('playing', (event) => this.onPlay(event));
player.on('pause', (event) => this.onPause(event));
player.on('ended', (event) => this.onEnded(event));
player.on('ratechange', (event) => this.onRateChange(event));
player.on('timeupdate', (event) => this.onTimeUpdate(event));
player.on('seeked', (event) => this.onSeeked(event));
// Event trigger to send recsys event
player.on('dispose', (event) => this.onDispose(event));
}
addRecsysEvent(recsysEvent) {
if (!this.playInitiated) {
switch (recsysEvent.event) {
case RecsysData.event.start:
this.playInitiated = true;
break;
case RecsysData.event.scrub:
// If playback hasn't started, swallow scrub events. They offer some
// information, but if there isn't a subsequent play event, it's
// mostly nonsensical.
return undefined;
case RecsysData.event.stop:
// If playback hasn't started, swallow stop events. This means
// you're going to start from an offset but the start event
// captures that information. (With the ambiguity that you can't
// tell if they scrubbed, landed at the offset, or restarted. But
// I don't think that matters much.)
return undefined;
case RecsysData.event.speed:
if (this.recsysEvents.length > 0 && this.recsysEvents[0].event === RecsysData.event.speed) {
// video.js will sometimes fire the default play speed followed by the
// user preference. This is not useful information so we can keep the latter.
this.recsysEvents.pop();
}
}
} else {
const lastEvent = this.recsysEvents[this.recsysEvents.length - 1];
switch (recsysEvent.event) {
case RecsysData.event.scrub:
if (lastEvent.event === RecsysData.event.stop) {
// Video.js fires a stop before the seek. This extra information isn't
// useful to log though, so this code prunes the stop event if it was
// within 0.25 seconds.
if (Math.abs(lastEvent.offset - recsysEvent.offset) < 0.25) {
this.recsysEvents.pop();
recsysEvent.offset = lastEvent.arg;
}
} else if (lastEvent.event === RecsysData.event.start) {
// If the last event was a play and this event is a scrub close to
// that play position, I think it's just a weird emit order for
// video.js and we don't need to log the scrub.
if (Math.abs(lastEvent.offset - recsysEvent.arg) < 0.25) {
return undefined;
}
}
break;
case RecsysData.event.start:
if (lastEvent.event === RecsysData.event.scrub) {
// If the last event was a seek and this is a play,
// it's reasonable to just implicitly assume the play occurred,
// no need to create the play event.
return undefined;
} else if (lastEvent.event === RecsysData.event.start) {
// A start followed by a start is a buffering event.
// It may make sense to keep these. A user may abandon
// a page *not because it's bad content but because
// there are network troubles right now*.
}
break;
}
}
this.recsysEvents.push(recsysEvent);
}
getRecsysEvents() {
return this.recsysEvents.map((event) => {
if (event !== RecsysData.event.stop) {
return event;
}
// I used the arg in stop events to smuggle the seek time into
// the scrub events. But the backend doesn't expect it.
const dup = { ...event };
delete dup.arg;
return dup;
});
}
sendRecsysEvents() {
const event = createRecsys(
this.options_.videoId,
this.options_.userId,
this.getRecsysEvents(),
this.loadedAt,
false
);
sendRecsysEvents(event);
}
onPlay(event) {
const recsysEvent = newRecsysEvent(RecsysData.event.start, this.player.currentTime());
this.log('onPlay', recsysEvent);
this.addRecsysEvent(recsysEvent);
}
onPause(event) {
// The API doesn't want an `arg` for `STOP` events. However, video.js
// emits these before the seek events, and that seems to be the easiest
// way to lift time you are seeking from into the scrub record (via lastTimeUpdate).
// Hacky, but works.
const recsysEvent = newRecsysEvent(RecsysData.event.stop, this.player.currentTime(), this.lastTimeUpdate);
this.log('onPause', recsysEvent);
this.addRecsysEvent(recsysEvent);
}
onEnded(event) {
const recsysEvent = newRecsysEvent(RecsysData.event.stop, this.player.currentTime());
this.log('onEnded', recsysEvent);
this.addRecsysEvent(recsysEvent);
}
onRateChange(event) {
// This is actually a bug. The offset should be the offset. The change speed should be change speed.
// Otherise, you don't know where it changed and the time calc is wrong.
const recsysEvent = newRecsysEvent(RecsysData.event.speed, this.player.currentTime(), this.player.playbackRate());
this.log('onRateChange', recsysEvent);
this.addRecsysEvent(recsysEvent);
}
onTimeUpdate(event) {
this.lastTimeUpdate = this.currentTimeUpdate;
this.currentTimeUpdate = this.player.currentTime();
}
onSeeked(event) {
// The problem? `lastTimeUpdate` is wrong.
// So every seeks l
// If the immediately prior event is a pause?
const recsysEvent = newRecsysEvent(RecsysData.event.scrub, this.lastTimeUpdate, this.player.currentTime());
this.log('onSeeked', recsysEvent);
this.addRecsysEvent(recsysEvent);
}
onDispose(event) {
this.sendRecsysEvents();
}
log(...args) {
if (this.options_.debug) {
console.log(`Recsys Debug:`, JSON.stringify(args));
}
}
}
videojs.registerComponent('recsys', RecsysPlugin);
const onPlayerReady = (player, options) => {
player.recsys = new RecsysPlugin(player, options);
};
/**
* Initialize the plugin.
*
* @function plugin
* @param {Object} [options={}]
*/
const plugin = function (options) {
this.ready(() => {
onPlayerReady(this, videojs.mergeOptions(defaults, options));
});
};
plugin.VERSION = VERSION;
registerPlugin('recsys', plugin);
export default plugin;
@@ -9,7 +9,6 @@ import eventTracking from 'videojs-event-tracking';
import * as OVERLAY from './overlays';
import './plugins/videojs-mobile-ui/plugin';
import hlsQualitySelector from './plugins/videojs-hls-quality-selector/plugin';
import recsys from './plugins/videojs-recsys/plugin';
import qualityLevels from 'videojs-contrib-quality-levels';
import isUserTyping from 'util/detect-typing';
@@ -51,8 +50,6 @@ type Props = {
autoplay: boolean,
toggleVideoTheaterMode: () => void,
adUrl: ?string,
claimId: ?string,
userId: ?number,
};
// type VideoJSOptions = {
@@ -124,10 +121,6 @@ if (!Object.keys(videojs.getPlugins()).includes('qualityLevels')) {
videojs.registerPlugin('qualityLevels', qualityLevels);
}
if (!Object.keys(videojs.getPlugins()).includes('recsys')) {
videojs.registerPlugin('recsys', recsys);
}
// ****************************************************************************
// LbryVolumeBarClass
// ****************************************************************************
@@ -187,8 +180,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
onPlayerReady,
toggleVideoTheaterMode,
adUrl,
claimId,
userId,
} = props;
const [reload, setReload] = useState('initial');
@@ -573,12 +564,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
// note: the poster prop seems to return null usually.
if (poster) player.poster(poster);
// Update player source
player.src({
src: finalSource,
type: type,
});
// set playsinline for mobile
player.children_[0].setAttribute('playsinline', '');
@@ -587,13 +572,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
displayCurrentQuality: true,
});
// Add recsys plugin
// TODO: Add an if(odysee.com) around this function to only use recsys on odysee
player.recsys({
videoId: claimId,
userId: userId,
});
// Update player source
player.src({
src: finalSource,
+17 -23
View File
@@ -47,7 +47,6 @@ type Props = {
toggleVideoTheaterMode: () => void,
setVideoPlaybackRate: (number) => void,
authenticated: boolean,
userId: number,
homepageData: {
PRIMARY_CONTENT_CHANNEL_IDS?: Array<string>,
ENLIGHTENMENT_CHANNEL_IDS?: Array<string>,
@@ -89,7 +88,6 @@ function VideoViewer(props: Props) {
setVideoPlaybackRate,
homepageData,
authenticated,
userId,
} = props;
const {
PRIMARY_CONTENT_CHANNEL_IDS = [],
@@ -180,22 +178,13 @@ function VideoViewer(props: Props) {
}
}, [embedded, setIsEndededEmbed, autoplaySetting, setShowAutoplayCountdown, adUrl, setAdUrl]);
function onPlay(player) {
function onPlay() {
setIsLoading(false);
setIsPlaying(true);
setShowAutoplayCountdown(false);
setIsEndededEmbed(false);
}
function onPause(player) {
setIsPlaying(false);
handlePosition(player);
}
function onDispose(player) {
handlePosition(player);
}
function handlePosition(player) {
if (player.ended()) {
clearPosition(uri);
@@ -233,14 +222,17 @@ function VideoViewer(props: Props) {
Promise.race([playPromise, timeoutPromise]).catch((error) => {
if (typeof error === 'object' && error.name && error.name === 'NotAllowedError') {
// Autoplay disallowed by browser
player.play();
if (player.autoplay() && !player.muted()) {
player.muted(true);
}
}
// Autoplay failed
if (PLAY_TIMEOUT_ERROR) {
setIsLoading(false);
setIsPlaying(false);
const retryPlayPromise = player.play();
Promise.race([retryPlayPromise, timeoutPromise]).catch((error) => {
setIsLoading(false);
setIsPlaying(false);
});
} else {
setIsLoading(false);
setIsPlaying(false);
@@ -259,10 +251,11 @@ function VideoViewer(props: Props) {
player.on('tracking:buffered', doTrackingBuffered);
player.on('tracking:firstplay', doTrackingFirstPlay);
player.on('ended', onEnded);
player.on('play', () => onPlay(player));
player.on('pause', () => onPause(player));
player.on('dispose', () => onDispose(player));
player.on('play', onPlay);
player.on('pause', () => {
setIsPlaying(false);
handlePosition(player);
});
player.on('error', () => {
const error = player.error();
if (error) {
@@ -289,6 +282,9 @@ function VideoViewer(props: Props) {
if (position) {
player.currentTime(position);
}
player.on('dispose', () => {
handlePosition(player);
});
}, playerReadyDependencyList);
return (
@@ -346,8 +342,6 @@ function VideoViewer(props: Props) {
startMuted={autoplayIfEmbedded}
toggleVideoTheaterMode={toggleVideoTheaterMode}
autoplay={!embedded || autoplayIfEmbedded}
claimId={claimId}
userId={userId}
/>
)}
</div>
+1 -1
View File
@@ -4,7 +4,7 @@ import { doOpenModal } from 'redux/actions/app';
import Wunderbar from './view';
const perform = (dispatch, ownProps) => ({
doOpenMobileSearch: (props) => dispatch(doOpenModal(MODALS.MOBILE_SEARCH, props)),
doOpenMobileSearch: () => dispatch(doOpenModal(MODALS.MOBILE_SEARCH)),
});
export default connect(null, perform)(Wunderbar);
+4 -13
View File
@@ -6,25 +6,16 @@ import { useIsMobile } from 'effects/use-screensize';
import WunderbarSuggestions from 'component/wunderbarSuggestions';
type Props = {
doOpenMobileSearch: (any) => void,
channelsOnly?: boolean,
noTopSuggestion?: boolean,
noBottomLinks?: boolean,
customSelectAction?: (string) => void,
doOpenMobileSearch: () => void,
};
export default function WunderBar(props: Props) {
const { doOpenMobileSearch, channelsOnly, noTopSuggestion, noBottomLinks, customSelectAction } = props;
const { doOpenMobileSearch } = props;
const isMobile = useIsMobile();
return isMobile ? (
<Button icon={ICONS.SEARCH} className="wunderbar__mobile-search" onClick={() => doOpenMobileSearch({ ...props })} />
<Button icon={ICONS.SEARCH} className="wunderbar__mobile-search" onClick={() => doOpenMobileSearch()} />
) : (
<WunderbarSuggestions
channelsOnly={channelsOnly}
noTopSuggestion={noTopSuggestion}
noBottomLinks={noBottomLinks}
customSelectAction={customSelectAction}
/>
<WunderbarSuggestions />
);
}
+1 -2
View File
@@ -1,10 +1,9 @@
import { connect } from 'react-redux';
import { makeSelectClaimForUri, makeSelectIsUriResolving } from 'lbry-redux';
import { makeSelectClaimForUri } from 'lbry-redux';
import WunderbarSuggestion from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
});
export default connect(select)(WunderbarSuggestion);
+1 -12
View File
@@ -10,21 +10,10 @@ import ClaimProperties from 'component/claimProperties';
type Props = {
claim: ?Claim,
uri: string,
isResolvingUri: boolean,
};
export default function WunderbarSuggestion(props: Props) {
const { claim, uri, isResolvingUri } = props;
if (isResolvingUri) {
return (
<ComboboxOption value={uri}>
<div className="wunderbar__suggestion">
<div className="media__thumb media__thumb--resolving" />
</div>
</ComboboxOption>
);
}
const { claim, uri } = props;
if (!claim) {
return null;
+23 -68
View File
@@ -16,9 +16,8 @@ import WunderbarTopSuggestion from 'component/wunderbarTopSuggestion';
import WunderbarSuggestion from 'component/wunderbarSuggestion';
import { useHistory } from 'react-router';
import { formatLbryUrlForWeb } from 'util/url';
import useThrottle from 'effects/use-throttle';
import Yrbl from 'component/yrbl';
import { SEARCH_OPTIONS } from 'constants/search';
import Spinner from 'component/spinner';
const LBRY_PROTOCOL = 'lbry://';
const WEB_DEV_PREFIX = `${URL_DEV}/`;
@@ -31,9 +30,6 @@ const TAG_SEARCH_PREFIX = 'tag:';
const L_KEY_CODE = 76;
const ESC_KEY_CODE = 27;
const WUNDERBAR_INPUT_DEBOUNCE_MS = 1000;
const LIGHTHOUSE_MIN_CHARACTERS = 3;
type Props = {
searchQuery: ?string,
onSearch: (string) => void,
@@ -43,28 +39,14 @@ type Props = {
showMature: boolean,
isMobile: boolean,
doCloseMobileSearch: () => void,
channelsOnly?: boolean,
noTopSuggestion?: boolean,
noBottomLinks?: boolean,
customSelectAction?: (string) => void,
};
export default function WunderBarSuggestions(props: Props) {
const {
navigateToSearchPage,
doShowSnackBar,
doResolveUris,
showMature,
isMobile,
doCloseMobileSearch,
channelsOnly,
noTopSuggestion,
noBottomLinks,
customSelectAction,
} = props;
const { navigateToSearchPage, doShowSnackBar, doResolveUris, showMature, isMobile, doCloseMobileSearch } = props;
const inputRef: ElementRef<any> = React.useRef();
const isFocused = inputRef && inputRef.current && inputRef.current === document.activeElement;
const THROTTLE_MS = 1000;
const {
push,
location: { search },
@@ -72,14 +54,11 @@ export default function WunderBarSuggestions(props: Props) {
const urlParams = new URLSearchParams(search);
const queryFromUrl = urlParams.get('q') || '';
const [term, setTerm] = React.useState(queryFromUrl);
const [debouncedTerm, setDebouncedTerm] = React.useState('');
const throttledTerm = useThrottle(term, THROTTLE_MS) || '';
const searchSize = isMobile ? 20 : 5;
const additionalOptions = channelsOnly
? { isBackgroundSearch: false, [SEARCH_OPTIONS.CLAIM_TYPE]: SEARCH_OPTIONS.INCLUDE_CHANNELS }
: {};
const { results, loading } = useLighthouse(debouncedTerm, showMature, searchSize, additionalOptions, 0);
const noResults = debouncedTerm && !loading && results && results.length === 0;
const nameFromQuery = debouncedTerm.trim().replace(/\s+/g, '').replace(/:/g, '#');
const { results, loading } = useLighthouse(throttledTerm, showMature, searchSize);
const noResults = throttledTerm && !loading && results && results.length === 0;
const nameFromQuery = throttledTerm.trim().replace(/\s+/g, '').replace(/:/g, '#');
const uriFromQuery = `lbry://${nameFromQuery}`;
let uriFromQueryIsValid = false;
let channelUrlForTopTest;
@@ -96,9 +75,6 @@ export default function WunderBarSuggestions(props: Props) {
topUrisToTest.push(uriFromQuery);
}
const isTyping = debouncedTerm !== term;
const showPlaceholder = isTyping || loading;
function handleSelect(value) {
if (!value) {
return;
@@ -116,12 +92,6 @@ export default function WunderBarSuggestions(props: Props) {
inputRef.current.blur();
}
if (customSelectAction) {
// Give them full results, as our resolved one might truncate the claimId.
customSelectAction(results ? results.find((r) => r.startsWith(value)) : '');
return;
}
if (wasCopiedFromWeb) {
const prefix = webDomainList[webDomainIndex];
let query = value.slice(prefix.length).replace(/:/g, '#');
@@ -162,16 +132,6 @@ export default function WunderBarSuggestions(props: Props) {
}
}
React.useEffect(() => {
const timer = setTimeout(() => {
if (debouncedTerm !== term) {
setDebouncedTerm(term.length < LIGHTHOUSE_MIN_CHARACTERS ? '' : term);
}
}, WUNDERBAR_INPUT_DEBOUNCE_MS);
return () => clearTimeout(timer);
}, [term, debouncedTerm]);
React.useEffect(() => {
function handleHomeEndCaretPos(elem, shiftKey, isHome) {
if (elem) {
@@ -301,35 +261,30 @@ export default function WunderBarSuggestions(props: Props) {
value={term}
/>
{isFocused && (
{isFocused && results && results.length > 0 && (
<ComboboxPopover
portal={false}
className={classnames('wunderbar__suggestions', { 'wunderbar__suggestions--mobile': isMobile })}
>
<ComboboxList>
{uriFromQueryIsValid && !noTopSuggestion ? <WunderbarTopSuggestion query={nameFromQuery} /> : null}
{uriFromQueryIsValid ? <WunderbarTopSuggestion query={nameFromQuery} /> : null}
<div className="wunderbar__label">{__('Search Results')}</div>
{results.slice(0, isMobile ? 20 : 5).map((uri) => (
<WunderbarSuggestion key={uri} uri={uri} />
))}
{showPlaceholder && term.length > LIGHTHOUSE_MIN_CHARACTERS ? <Spinner type="small" /> : null}
{!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>
)}
<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>
)}
-7
View File
@@ -278,12 +278,6 @@ export const COMMENT_MODERATION_BLOCK_FAILED = 'COMMENT_MODERATION_BLOCK_FAILED'
export const COMMENT_MODERATION_UN_BLOCK_STARTED = 'COMMENT_MODERATION_UN_BLOCK_STARTED';
export const COMMENT_MODERATION_UN_BLOCK_COMPLETE = 'COMMENT_MODERATION_UN_BLOCK_COMPLETE';
export const COMMENT_MODERATION_UN_BLOCK_FAILED = 'COMMENT_MODERATION_UN_BLOCK_FAILED';
export const COMMENT_FETCH_MODERATION_DELEGATES_STARTED = 'COMMENT_FETCH_MODERATION_DELEGATES_STARTED';
export const COMMENT_FETCH_MODERATION_DELEGATES_FAILED = 'COMMENT_FETCH_MODERATION_DELEGATES_FAILED';
export const COMMENT_FETCH_MODERATION_DELEGATES_COMPLETED = 'COMMENT_FETCH_MODERATION_DELEGATES_COMPLETED';
export const COMMENT_MODERATION_AM_I_LIST_STARTED = 'COMMENT_MODERATION_AM_I_LIST_STARTED';
export const COMMENT_MODERATION_AM_I_LIST_FAILED = 'COMMENT_MODERATION_AM_I_LIST_FAILED';
export const COMMENT_MODERATION_AM_I_LIST_COMPLETED = 'COMMENT_MODERATION_AM_I_LIST_COMPLETED';
export const COMMENT_FETCH_SETTINGS_STARTED = 'COMMENT_FETCH_SETTINGS_STARTED';
export const COMMENT_FETCH_SETTINGS_FAILED = 'COMMENT_FETCH_SETTINGS_FAILED';
export const COMMENT_FETCH_SETTINGS_COMPLETED = 'COMMENT_FETCH_SETTINGS_COMPLETED';
@@ -345,4 +339,3 @@ export const REPORT_CONTENT_FAILED = 'REPORT_CONTENT_FAILED';
export const FETCH_NO_SOURCE_CLAIMS_STARTED = 'FETCH_NO_SOURCE_CLAIMS_STARTED';
export const FETCH_NO_SOURCE_CLAIMS_COMPLETED = 'FETCH_NO_SOURCE_CLAIMS_COMPLETED';
export const FETCH_NO_SOURCE_CLAIMS_FAILED = 'FETCH_NO_SOURCE_CLAIMS_FAILED';
export const VIEWERS_RECEIVED = 'VIEWERS_RECEIVED';
+18 -5
View File
@@ -4,8 +4,21 @@ export const SORT_COMMENTS_NEW = 'new';
export const SORT_COMMENTS_BEST = 'best';
export const SORT_COMMENTS_CONTROVERSIAL = 'controversial';
export const BLOCK_LEVEL = {
SELF: 'self',
MODERATOR: 'moderator',
ADMIN: 'admin',
};
export const BANNED_LIVESTREAM_WORDS = [
'n1gga',
'f4ggot',
'faggot',
'nigga',
'nigger',
'F4G',
'fag',
'n1gger',
'faget',
'niggah',
'n1ggah',
'jew',
'j3w',
'goy',
'goyim',
'fagot',
];
-1
View File
@@ -160,4 +160,3 @@ export const LIVESTREAM_SOLID = 'LivestreamSolid';
export const LIVESTREAM_MONOCHROME = 'LivestreamMono';
export const STACK = 'stack';
export const TIME = 'time';
export const GLOBE = 'globe';
+1 -1
View File
@@ -1,3 +1,3 @@
export const BITWAVE_EMBED_URL = 'https://bitwave.tv/odysee';
export const BITWAVE_LIVE_API = 'https://api.bitwave.tv/v1/odysee/live';
export const BITWAVE_LIVE_API = 'https://api.live.odysee.com/v1/odysee/live';
export const BITWAVE_REPLAY_API = 'https://api.bitwave.tv/v1/replays/odysee';
+4 -9
View File
@@ -5,17 +5,12 @@ import { getSearchQueryString } from 'util/query-params';
import { isURIValid } from 'lbry-redux';
import useThrottle from './use-throttle';
export default function useLighthouse(
query: string,
showMature: boolean,
size: number = 5,
additionalOptions: any = {},
throttleMs: number = 500
) {
export default function useLighthouse(query: string, showMature?: boolean, size?: number = 5) {
const THROTTLE_MS = 1000;
const [results, setResults] = React.useState();
const [loading, setLoading] = React.useState();
const queryString = query ? getSearchQueryString(query, { nsfw: showMature, size, ...additionalOptions }) : '';
const throttledQuery = useThrottle(queryString, throttleMs);
const queryString = query ? getSearchQueryString(query, { nsfw: showMature, size }) : '';
const throttledQuery = useThrottle(queryString, THROTTLE_MS);
React.useEffect(() => {
if (throttledQuery) {
+2 -12
View File
@@ -5,24 +5,14 @@ import WunderbarSuggestions from 'component/wunderbarSuggestions';
type Props = {
closeModal: () => void,
channelsOnly?: boolean,
noTopSuggestion?: boolean,
noBottomLinks?: boolean,
customSelectAction?: (string) => void,
};
export default function ModalMobileSearch(props: Props) {
const { closeModal, channelsOnly, noTopSuggestion, noBottomLinks, customSelectAction } = props;
const { closeModal } = props;
return (
<Modal onAborted={closeModal} isOpen type="card">
<WunderbarSuggestions
isMobile
channelsOnly={channelsOnly}
noTopSuggestion={noTopSuggestion}
noBottomLinks={noBottomLinks}
customSelectAction={customSelectAction}
/>
<WunderbarSuggestions isMobile />
</Modal>
);
}
+2 -2
View File
@@ -24,7 +24,7 @@ function ModalRemoveCollection(props: Props) {
const [confirmName, setConfirmName] = useState('');
return (
<Modal isOpen contentLabel={__('Confirm List Unpublish')} type="card" onAborted={closeModal}>
<Modal isOpen contentLabel={__('Confirm Collection Unpublish')} type="card" onAborted={closeModal}>
<Card
title={__('Delete List')}
body={
@@ -36,7 +36,7 @@ function ModalRemoveCollection(props: Props) {
</React.Fragment>
) : (
<I18nMessage tokens={{ title: <cite>{uri && title ? `"${title}"` : `"${collectionName}"`}</cite> }}>
Are you sure you'd like to remove "%title%"?
Are you sure you'd like to remove collection %title%?
</I18nMessage>
)
}
+1 -1
View File
@@ -84,7 +84,7 @@ function HomePage(props: Props) {
<h1 className="home__meme">
<Button button="link" href="https://odysee.com/@Odysee:8?view=discussion">
{__("question, what kind of bear is best?")}
{__("this cave is not a natural formation")}
</Button>
</h1>
+3 -22
View File
@@ -1,31 +1,12 @@
import { connect } from 'react-redux';
import { doFetchModBlockedList, doFetchCommentModAmIList } from 'redux/actions/comments';
import { selectMutedChannels } from 'redux/selectors/blocked';
import {
selectModerationBlockList,
selectAdminBlockList,
selectModeratorBlockList,
selectModeratorBlockListDelegatorsMap,
selectFetchingModerationBlockList,
selectModerationDelegatorsById,
} from 'redux/selectors/comments';
import { selectMyChannelClaims } from 'lbry-redux';
import { selectModerationBlockList, selectFetchingModerationBlockList } from 'redux/selectors/comments';
import ListBlocked from './view';
const select = (state) => ({
mutedUris: selectMutedChannels(state),
personalBlockList: selectModerationBlockList(state),
adminBlockList: selectAdminBlockList(state),
moderatorBlockList: selectModeratorBlockList(state),
moderatorBlockListDelegatorsMap: selectModeratorBlockListDelegatorsMap(state),
delegatorsById: selectModerationDelegatorsById(state),
myChannelClaims: selectMyChannelClaims(state),
blockedUris: selectModerationBlockList(state),
fetchingModerationBlockList: selectFetchingModerationBlockList(state),
});
const perform = (dispatch) => ({
fetchModBlockedList: () => dispatch(doFetchModBlockedList()),
fetchModAmIList: () => dispatch(doFetchCommentModAmIList()),
});
export default connect(select, perform)(ListBlocked);
export default connect(select)(ListBlocked);
+64 -240
View File
@@ -1,10 +1,8 @@
// @flow
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 ClaimPreview from 'component/claimPreview';
import Page from 'component/page';
import Spinner from 'component/spinner';
import Button from 'component/button';
@@ -13,220 +11,63 @@ import ChannelBlockButton from 'component/channelBlockButton';
import ChannelMuteButton from 'component/channelMuteButton';
import Yrbl from 'component/yrbl';
const VIEW = {
BLOCKED: 'blocked',
ADMIN: 'admin',
MODERATOR: 'moderator',
MUTED: 'muted',
};
type Props = {
mutedUris: ?Array<string>,
personalBlockList: ?Array<string>,
adminBlockList: ?Array<string>,
moderatorBlockList: ?Array<string>,
moderatorBlockListDelegatorsMap: { [string]: Array<string> },
blockedUris: ?Array<string>,
fetchingModerationBlockList: boolean,
fetchModBlockedList: () => void,
fetchModAmIList: () => void,
delegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
myChannelClaims: ?Array<ChannelClaim>,
};
const VIEW_BLOCKED = 'blocked';
const VIEW_MUTED = 'muted';
function ListBlocked(props: Props) {
const {
mutedUris,
personalBlockList,
adminBlockList,
moderatorBlockList,
moderatorBlockListDelegatorsMap,
fetchingModerationBlockList,
fetchModBlockedList,
fetchModAmIList,
delegatorsById,
myChannelClaims,
} = props;
const [viewMode, setViewMode] = usePersistedState('blocked-muted:display', VIEW.BLOCKED);
const { mutedUris, blockedUris, fetchingModerationBlockList } = 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 [localBlockedList, setLocalBlockedList] = React.useState(undefined);
const [localMutedList, setLocalMutedList] = 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 hasLocalBlockList = localBlockedList && localBlockedList.length > 0;
const stringifiedMutedChannels = JSON.stringify(mutedUris);
const justMuted = localMutedList && mutedUris && localMutedList.length < mutedUris.length;
const justPersonalBlocked =
localPersonalList && personalBlockList && localPersonalList.length < personalBlockList.length;
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) {
switch (view) {
case VIEW.BLOCKED:
return localPersonalList;
case VIEW.ADMIN:
return localAdminList;
case VIEW.MODERATOR:
return localModeratorList;
case VIEW.MUTED:
return localMutedList;
}
}
function getButtons(view, uri) {
switch (view) {
case VIEW.BLOCKED:
return (
<>
<ChannelBlockButton uri={uri} />
<ChannelMuteButton uri={uri} />
</>
);
case VIEW.ADMIN:
return <ChannelBlockButton uri={uri} blockLevel={BLOCK_LEVEL.ADMIN} />;
case VIEW.MODERATOR:
const delegatorUrisForBlockedUri = localModeratorListDelegatorsMap && localModeratorListDelegatorsMap[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" />
</ul>
<ChannelBlockButton uri={uri} blockLevel={BLOCK_LEVEL.MODERATOR} creatorUri={delegatorUri} />
</div>
);
})}
</>
);
case VIEW.MUTED:
return (
<>
<ChannelMuteButton uri={uri} />
<ChannelBlockButton uri={uri} />
</>
);
}
}
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.";
case VIEW.ADMIN:
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.';
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.';
}
}
function getEmptyListTitle(view) {
switch (view) {
case VIEW.BLOCKED:
return 'You do not have any blocked channels';
case VIEW.MUTED:
return 'You do not have any muted channels';
case VIEW.ADMIN:
return 'You do not have any globally-blocked channels';
case VIEW.MODERATOR:
return 'You do not have any blocked channels as a moderator';
}
}
function getEmptyListSubtitle(view) {
switch (view) {
case VIEW.BLOCKED:
case VIEW.MUTED:
return getHelpText(view);
case VIEW.ADMIN:
case VIEW.MODERATOR:
return null;
}
}
function isSourceListLarger(source, local) {
// Comparing the length of stringified is not perfect, but what are the
// chances of having different lists with the exact same length?
return source && (!local || local.length < source.length);
}
const justBlocked = localBlockedList && blockedUris && localBlockedList.length < blockedUris.length;
const stringifiedBlockedChannels = JSON.stringify(blockedUris);
const showUris = (viewMode === VIEW_MUTED && hasLocalMuteList) || (viewMode === VIEW_BLOCKED && hasLocalBlockList);
React.useEffect(() => {
const jsonMutedChannels = stringifiedMutedList && JSON.parse(stringifiedMutedList);
const jsonMutedChannels = stringifiedMutedChannels && JSON.parse(stringifiedMutedChannels);
if (!hasLocalMuteList && jsonMutedChannels && jsonMutedChannels.length > 0) {
setLocalMutedList(jsonMutedChannels);
}
}, [stringifiedMutedList, hasLocalMuteList]);
}, [stringifiedMutedChannels, hasLocalMuteList]);
React.useEffect(() => {
const jsonBlockedChannels = stringifiedPersonalList && JSON.parse(stringifiedPersonalList);
if (!hasLocalPersonalList && jsonBlockedChannels && jsonBlockedChannels.length > 0) {
setLocalPersonalList(jsonBlockedChannels);
const jsonBlockedChannels = stringifiedBlockedChannels && JSON.parse(stringifiedBlockedChannels);
if (!hasLocalBlockList && jsonBlockedChannels && jsonBlockedChannels.length > 0) {
setLocalBlockedList(jsonBlockedChannels);
}
}, [stringifiedPersonalList, hasLocalPersonalList]);
}, [stringifiedBlockedChannels, hasLocalBlockList]);
React.useEffect(() => {
if (stringifiedAdminList && isSourceListLarger(stringifiedAdminList, stringifiedLocalAdminList)) {
setLocalAdminList(JSON.parse(stringifiedAdminList));
if (justMuted && stringifiedMutedChannels) {
setLocalMutedList(JSON.parse(stringifiedMutedChannels));
}
}, [stringifiedAdminList, stringifiedLocalAdminList]);
}, [stringifiedMutedChannels, justMuted, setLocalMutedList]);
React.useEffect(() => {
if (stringifiedModeratorList && isSourceListLarger(stringifiedModeratorList, stringifiedLocalModeratorList)) {
setLocalModeratorList(JSON.parse(stringifiedModeratorList));
if (justBlocked && stringifiedBlockedChannels) {
setLocalBlockedList(JSON.parse(stringifiedBlockedChannels));
}
}, [stringifiedModeratorList, stringifiedLocalModeratorList]);
}, [stringifiedBlockedChannels, justBlocked, setLocalBlockedList]);
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]);
const mutedHelpText = __(
'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.'
);
const blockedHelpText = __(
"Blocked channels will be invisible to you in the app. They will not be able to comment on your content, or reply to you comments left on other channels' content."
);
return (
<Page>
@@ -245,74 +86,57 @@ function ListBlocked(props: Props) {
button="alt"
label={__('Blocked')}
className={classnames(`button-toggle`, {
'button-toggle--active': viewMode === VIEW.BLOCKED,
'button-toggle--active': viewMode === VIEW_BLOCKED,
})}
onClick={() => setViewMode(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,
'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();
}}
onClick={() => setViewMode(VIEW_MUTED)}
/>
</div>
</div>
{showUris && <div className="help--notice">{getHelpText(viewMode)}</div>}
{showUris && <div className="help--notice">{viewMode === VIEW_MUTED ? mutedHelpText : blockedHelpText}</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>
<ClaimList
uris={viewMode === VIEW_MUTED ? localMutedList : localBlockedList}
showUnresolvedClaims
showHiddenByUser
hideMenu
renderActions={(claim) => {
return (
<div className="section__actions">
{viewMode === VIEW_MUTED ? (
<>
<ChannelMuteButton uri={claim.permanent_url} />
<ChannelBlockButton uri={claim.permanent_url} />
</>
) : (
<>
<ChannelBlockButton uri={claim.permanent_url} />
<ChannelMuteButton uri={claim.permanent_url} />
</>
)}
</div>
);
}}
/>
) : (
<div className="main--empty">
<Yrbl
title={getEmptyListTitle(viewMode)}
subtitle={getEmptyListSubtitle(viewMode)}
title={
viewMode === VIEW_MUTED
? __('You do not have any muted channels')
: __('You do not have any blocked channels')
}
subtitle={viewMode === VIEW_MUTED ? mutedHelpText : blockedHelpText}
actions={
<div className="section__actions">
<Button button="primary" label={__('Go Home')} navigate="/" />
+4 -1
View File
@@ -19,6 +19,7 @@ type Props = {
export default function LivestreamPage(props: Props) {
const { uri, claim, doSetPlayingUri, isAuthenticated, doUserSetReferrer, channelClaim, chatDisabled } = props;
const [activeViewers, setActiveViewers] = React.useState(0);
const [isLive, setIsLive] = React.useState(false);
const livestreamChannelId = channelClaim && channelClaim.signing_channel && channelClaim.signing_channel.claim_id;
const [hasLivestreamClaim, setHasLivestreamClaim] = React.useState(false);
@@ -65,6 +66,8 @@ export default function LivestreamPage(props: Props) {
return;
}
setActiveViewers(res.data.viewCount);
if (res.data.hasOwnProperty('live')) {
setIsLive(res.data.live);
}
@@ -117,7 +120,7 @@ export default function LivestreamPage(props: Props) {
chatDisabled={chatDisabled}
rightSide={!chatDisabled && <LivestreamComments uri={uri} />}
>
<LivestreamLayout uri={uri} isLive={isLive} />
<LivestreamLayout uri={uri} activeViewers={activeViewers} isLive={isLive} />
</Page>
);
}
-12
View File
@@ -3,9 +3,6 @@ import SettingsCreatorPage from './view';
import {
doCommentBlockWords,
doCommentUnblockWords,
doCommentModAddDelegate,
doCommentModRemoveDelegate,
doCommentModListDelegates,
doFetchCreatorSettings,
doUpdateCreatorSettings,
} from 'redux/actions/comments';
@@ -14,16 +11,13 @@ import {
selectSettingsByChannelId,
selectFetchingCreatorSettings,
selectFetchingBlockedWords,
selectModerationDelegatesById,
} from 'redux/selectors/comments';
import { doToast } from 'redux/actions/notifications';
const select = (state) => ({
activeChannelClaim: selectActiveChannelClaim(state),
settingsByChannelId: selectSettingsByChannelId(state),
fetchingCreatorSettings: selectFetchingCreatorSettings(state),
fetchingBlockedWords: selectFetchingBlockedWords(state),
moderationDelegatesById: selectModerationDelegatesById(state),
});
const perform = (dispatch) => ({
@@ -31,12 +25,6 @@ const perform = (dispatch) => ({
commentUnblockWords: (channelClaim, words) => dispatch(doCommentUnblockWords(channelClaim, words)),
fetchCreatorSettings: (channelClaimIds) => dispatch(doFetchCreatorSettings(channelClaimIds)),
updateCreatorSettings: (channelClaim, settings) => dispatch(doUpdateCreatorSettings(channelClaim, settings)),
commentModAddDelegate: (modChanId, modChanName, creatorChannelClaim) =>
dispatch(doCommentModAddDelegate(modChanId, modChanName, creatorChannelClaim)),
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);
+16 -175
View File
@@ -3,15 +3,11 @@ 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 Spinner from 'component/spinner';
import { FormField } from 'component/common/form-components/form-field';
import LbcSymbol from 'component/common/lbc-symbol';
import I18nMessage from 'component/i18nMessage';
import { isNameValid, parseURI } from 'lbry-redux';
import ClaimPreview from 'component/claimPreview';
import { getUriForSearchTerm } from 'util/search';
const DEBOUNCE_REFRESH_MS = 1000;
@@ -22,38 +18,24 @@ type Props = {
settingsByChannelId: { [string]: PerChannelSettings },
fetchingCreatorSettings: boolean,
fetchingBlockedWords: boolean,
moderationDelegatesById: { [string]: Array<{ channelId: string, channelName: string }> },
commentBlockWords: (ChannelClaim, Array<string>) => void,
commentUnblockWords: (ChannelClaim, Array<string>) => void,
commentModAddDelegate: (string, string, ChannelClaim) => void,
commentModRemoveDelegate: (string, string, ChannelClaim) => void,
commentModListDelegates: (ChannelClaim) => void,
fetchCreatorSettings: (Array<string>) => void,
updateCreatorSettings: (ChannelClaim, PerChannelSettings) => void,
doToast: ({ message: string }) => void,
};
export default function SettingsCreatorPage(props: Props) {
const {
activeChannelClaim,
settingsByChannelId,
moderationDelegatesById,
commentBlockWords,
commentUnblockWords,
commentModAddDelegate,
commentModRemoveDelegate,
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 [minTipAmountComment, setMinTipAmountComment] = React.useState(0);
const [minTipAmountSuperChat, setMinTipAmountSuperChat] = React.useState(0);
const [slowModeMinGap, setSlowModeMinGap] = React.useState(0);
@@ -115,93 +97,6 @@ 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);
}, [activeChannelClaim, commentModListDelegates]);
React.useEffect(() => {
if (activeChannelClaim) {
const delegates = moderationDelegatesById[activeChannelClaim.claim_id];
if (delegates) {
setModeratorTags(
delegates.map((d) => {
return {
name: d.channelName + '#' + d.channelId,
};
})
);
} else {
setModeratorTags([]);
}
}
}, [activeChannelClaim, moderationDelegatesById]);
// Update local states with data from API.
React.useEffect(() => {
if (lastUpdated !== 0 && Date.now() - lastUpdated < DEBOUNCE_REFRESH_MS) {
@@ -254,18 +149,18 @@ export default function SettingsCreatorPage(props: Props) {
)}
{!isBusy && !isDisabled && (
<>
<Card
title={__('General')}
actions={
<>
<FormField
type="checkbox"
name="comments_enabled"
label={__('Enable comments for channel.')}
checked={commentsEnabled}
onChange={() => setSettings({ comments_enabled: !commentsEnabled })}
/>
{FEATURE_IS_READY && (
{FEATURE_IS_READY && (
<Card
title={__('General')}
actions={
<>
<FormField
type="checkbox"
name="comments_enabled"
label={__('Enable comments for channel.')}
checked={commentsEnabled}
onChange={() => setSettings({ comments_enabled: !commentsEnabled })}
/>
<FormField
name="slow_mode_min_gap"
label={__('Minimum time gap in seconds for Slow Mode in livestream chat.')}
@@ -276,10 +171,10 @@ export default function SettingsCreatorPage(props: Props) {
value={slowModeMinGap}
onChange={(e) => setSettings({ slow_mode_min_gap: e.target.value })}
/>
)}
</>
}
/>
</>
}
/>
)}
<Card
title={__('Filter')}
actions={
@@ -340,60 +235,6 @@ export default function SettingsCreatorPage(props: Props) {
}
/>
)}
<Card
title={__('Delegation')}
className="card--enable-overflow"
actions={
<div className="tag--blocked-words">
<FormField
type="text"
name="moderator_search"
className="form-field--address"
label={__('Add moderator')}
placeholder={__('Enter a @username or URL')}
helper={__('examples: @channel, @channel#3, https://odysee.com/@Odysee:8, lbry://@Odysee#8')}
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>
)}
<TagsSearch
label={__('Moderators')}
labelAddNew={__('Add moderators')}
onRemove={removeModerator}
onSelect={addModerator}
tagsPassedIn={moderatorTags}
disableAutoFocus
hideInputField
hideSuggestions
disableControlTags
/>
</div>
}
/>
</>
)}
</Page>
+11 -12
View File
@@ -503,18 +503,17 @@ export function doAnalyticsBuffer(uri, bufferData) {
const fileSize = source.size; // size in bytes
const fileSizeInBits = fileSize * 8;
const bitRate = parseInt(fileSizeInBits / fileDurationInSeconds);
const userId = user && user.id.toString();
if (userId) {
analytics.videoBufferEvent(claim, {
timeAtBuffer,
bufferDuration,
bitRate,
userId,
duration: fileDurationInSeconds,
playerPoweredBy: bufferData.playerPoweredBy,
readyState: bufferData.readyState,
});
}
const userId = user.id.toString();
analytics.videoBufferEvent(claim, {
timeAtBuffer,
bufferDuration,
bitRate,
userId,
duration: fileDurationInSeconds,
playerPoweredBy: bufferData.playerPoweredBy,
readyState: bufferData.readyState,
});
};
}
+52 -477
View File
@@ -1,9 +1,8 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import * as REACTION_TYPES from 'constants/reactions';
import * as PAGES from 'constants/pages';
import { BLOCK_LEVEL } from 'constants/comment';
import { Lbry, parseURI, buildURI, selectClaimsById, selectClaimsByUri, selectMyChannelClaims } from 'lbry-redux';
import { Lbry, parseURI, buildURI, selectClaimsByUri, selectMyChannelClaims } from 'lbry-redux';
// import { BANNED_LIVESTREAM_WORDS } from 'constants/comment';
import { doToast, doSeeNotifications } from 'redux/actions/notifications';
import {
makeSelectCommentIdsForUri,
@@ -11,7 +10,6 @@ import {
makeSelectOthersReactionsForComment,
selectPendingCommentReacts,
selectModerationBlockList,
selectModerationDelegatorsById,
} from 'redux/selectors/comments';
import { makeSelectNotificationForCommentId } from 'redux/selectors/notifications';
import { selectActiveChannelClaim } from 'redux/selectors/app';
@@ -37,15 +35,10 @@ export function doCommentList(uri: string, page: number = 1, pageSize: number =
type: ACTIONS.COMMENT_LIST_STARTED,
});
// Adding 'channel_id' and 'channel_name' enables "CreatorSettings > commentsEnabled".
const authorChannelClaim = claim.value_type === 'channel' ? claim : claim.signing_channel;
return Comments.comment_list({
page,
claim_id: claimId,
page_size: pageSize,
channel_id: authorChannelClaim ? authorChannelClaim.claim_id : undefined,
channel_name: authorChannelClaim ? authorChannelClaim.name : undefined,
})
.then((result: CommentListResponse) => {
const { items: comments } = result;
@@ -54,27 +47,16 @@ export function doCommentList(uri: string, page: number = 1, pageSize: number =
data: {
comments,
claimId: claimId,
authorClaimId: authorChannelClaim ? authorChannelClaim.claim_id : undefined,
uri: uri,
},
});
return result;
})
.catch((error) => {
if (error.message === 'comments are disabled by the creator') {
dispatch({
type: ACTIONS.COMMENT_LIST_COMPLETED,
data: {
authorClaimId: authorChannelClaim ? authorChannelClaim.claim_id : undefined,
disabled: true,
},
});
} else {
dispatch({
type: ACTIONS.COMMENT_LIST_FAILED,
data: error,
});
}
dispatch({
type: ACTIONS.COMMENT_LIST_FAILED,
data: error,
});
});
};
}
@@ -525,83 +507,42 @@ async function channelSignName(channelClaimId: string, channelName: string) {
}
// Hides a users comments from all creator's claims and prevent them from commenting in the future
function doCommentModToggleBlock(
unblock: boolean,
commenterUri: string,
creatorId: string,
blockerIds: Array<string>, // [] = use all my channels
blockLevel: string,
showLink: boolean = false
) {
export function doCommentModToggleBlock(channelUri: string, showLink: boolean, unblock: boolean = false) {
return async (dispatch: Dispatch, getState: GetState) => {
const state = getState();
const myChannels = selectMyChannelClaims(state);
const claim = selectClaimsByUri(state)[channelUri];
let blockerChannelClaims = selectMyChannelClaims(state);
if (blockerIds.length === 0) {
// Specific blockers not provided, so find one based on block-level.
switch (blockLevel) {
case BLOCK_LEVEL.MODERATOR:
{
// Find the first channel that is a moderator for 'creatorId'.
const delegatorsById = selectModerationDelegatorsById(state);
blockerChannelClaims = [
blockerChannelClaims.find((x) => {
const delegatorDataForId = delegatorsById[x.claim_id];
return delegatorDataForId && Object.values(delegatorDataForId.delegators).includes(creatorId);
}),
];
}
break;
case BLOCK_LEVEL.ADMIN:
{
// Find the first admin channel and use that.
const delegatorsById = selectModerationDelegatorsById(state);
blockerChannelClaims = [
blockerChannelClaims.find((x) => delegatorsById[x.claim_id] && delegatorsById[x.claim_id].global),
];
}
break;
}
} else {
blockerChannelClaims = blockerChannelClaims.filter((x) => blockerIds.includes(x.claim_id));
}
const { channelName, channelClaimId } = parseURI(commenterUri);
const creatorClaim = selectClaimsById(state)[creatorId];
if (creatorId && !creatorClaim) {
console.error("Can't find creator claim"); // eslint-disable-line
if (!claim) {
console.error("Can't find claim to block"); // eslint-disable-line
return;
}
dispatch({
type: unblock ? ACTIONS.COMMENT_MODERATION_UN_BLOCK_STARTED : ACTIONS.COMMENT_MODERATION_BLOCK_STARTED,
data: {
blockedUri: commenterUri,
creatorUri: creatorClaim ? creatorClaim.permanent_url : undefined,
blockLevel: blockLevel,
uri: channelUri,
},
});
const commenterIdForAction = channelClaimId;
const commenterNameForAction = channelName;
const creatorIdForAction = claim ? claim.claim_id : null;
const creatorNameForAction = claim ? claim.name : null;
let channelSignatures = [];
const sharedModBlockParams = unblock
? {
un_blocked_channel_id: commenterIdForAction,
un_blocked_channel_name: commenterNameForAction,
}
un_blocked_channel_id: creatorIdForAction,
un_blocked_channel_name: creatorNameForAction,
}
: {
blocked_channel_id: commenterIdForAction,
blocked_channel_name: commenterNameForAction,
};
blocked_channel_id: creatorIdForAction,
blocked_channel_name: creatorNameForAction,
};
const commentAction = unblock ? Comments.moderation_unblock : Comments.moderation_block;
return Promise.all(blockerChannelClaims.map((x) => channelSignName(x.claim_id, x.name)))
return Promise.all(myChannels.map((channel) => channelSignName(channel.claim_id, channel.name)))
.then((response) => {
channelSignatures = response;
// $FlowFixMe
@@ -610,174 +551,49 @@ function doCommentModToggleBlock(
.filter((x) => x !== undefined && x !== null)
.map((signatureData) =>
commentAction({
// $FlowFixMe
mod_channel_id: signatureData.claim_id,
// $FlowFixMe
mod_channel_name: signatureData.name,
// $FlowFixMe
signature: signatureData.signature,
// $FlowFixMe
signing_ts: signatureData.signing_ts,
creator_channel_id: creatorClaim ? creatorClaim.claim_id : undefined,
creator_channel_name: creatorClaim ? creatorClaim.name : undefined,
block_all: unblock ? undefined : blockLevel === BLOCK_LEVEL.ADMIN,
global_un_block: unblock ? blockLevel === BLOCK_LEVEL.ADMIN : undefined,
...sharedModBlockParams,
})
)
)
.then((response) => {
const failures = [];
response.forEach((res, index) => {
if (res.status === 'rejected') {
// TODO: This should be error codes
if (res.reason.message !== 'validation is disallowed for non controlling channels') {
// $FlowFixMe
failures.push(channelSignatures[index].name + ': ' + res.reason.message);
}
}
});
if (failures.length !== 0) {
dispatch(doToast({ message: failures.join(), isError: true }));
dispatch({
type: unblock ? ACTIONS.COMMENT_MODERATION_UN_BLOCK_FAILED : ACTIONS.COMMENT_MODERATION_BLOCK_FAILED,
data: {
blockedUri: commenterUri,
creatorUri: creatorClaim ? creatorClaim.permanent_url : undefined,
blockLevel: blockLevel,
},
});
return;
}
.then(() => {
dispatch({
type: unblock ? ACTIONS.COMMENT_MODERATION_UN_BLOCK_COMPLETE : ACTIONS.COMMENT_MODERATION_BLOCK_COMPLETE,
data: {
blockedUri: commenterUri,
creatorUri: creatorClaim ? creatorClaim.permanent_url : undefined,
blockLevel: blockLevel,
},
data: { channelUri },
});
dispatch(
doToast({
message: unblock
? __('Channel unblocked!')
: __('Channel "%channel%" blocked.', { channel: commenterNameForAction }),
linkText: __(showLink ? 'See All' : ''),
linkTarget: '/settings/block_and_mute',
})
);
dispatch(doToast({
message: __(!unblock ? 'Channel blocked. They will not interact with you again.' : 'Channel unblocked!'),
linkText: __(showLink ? 'See All' : ''),
linkTarget: '/settings/block_and_mute',
}));
})
.catch(() => {
dispatch({
type: unblock ? ACTIONS.COMMENT_MODERATION_UN_BLOCK_FAILED : ACTIONS.COMMENT_MODERATION_BLOCK_FAILED,
data: {
blockedUri: commenterUri,
creatorUri: creatorClaim ? creatorClaim.permanent_url : undefined,
blockLevel: blockLevel,
},
});
});
})
.catch(() => {
dispatch({
type: unblock ? ACTIONS.COMMENT_MODERATION_UN_BLOCK_FAILED : ACTIONS.COMMENT_MODERATION_BLOCK_FAILED,
data: {
blockedUri: commenterUri,
creatorUri: creatorClaim ? creatorClaim.permanent_url : undefined,
blockLevel: blockLevel,
},
});
});
};
}
/**
* Blocks the commenter for all channels that I own.
*
* @param commenterUri
* @param showLink
* @returns {function(Dispatch): *}
*/
export function doCommentModBlock(commenterUri: string, showLink: boolean = true) {
export function doCommentModBlock(commentAuthor: string, showLink: boolean = true) {
return (dispatch: Dispatch) => {
return dispatch(doCommentModToggleBlock(false, commenterUri, '', [], BLOCK_LEVEL.SELF, showLink));
return dispatch(doCommentModToggleBlock(commentAuthor, showLink));
};
}
/**
* Blocks the commenter using the given channel that has Global privileges.
*
* @param commenterUri
* @param blockerId
* @returns {function(Dispatch): *}
*/
export function doCommentModBlockAsAdmin(commenterUri: string, blockerId: string) {
export function doCommentModUnBlock(commentAuthor: string, showLink: boolean = true) {
return (dispatch: Dispatch) => {
return dispatch(doCommentModToggleBlock(false, commenterUri, '', blockerId ? [blockerId] : [], BLOCK_LEVEL.ADMIN));
};
}
/**
* Blocks the commenter using the given channel that has been granted
* moderation rights by the creator.
*
* @param commenterUri
* @param creatorId
* @param blockerId
* @returns {function(Dispatch): *}
*/
export function doCommentModBlockAsModerator(commenterUri: string, creatorId: string, blockerId: string) {
return (dispatch: Dispatch) => {
return dispatch(
doCommentModToggleBlock(false, commenterUri, creatorId, blockerId ? [blockerId] : [], BLOCK_LEVEL.MODERATOR)
);
};
}
/**
* Unblocks the commenter for all channels that I own.
*
* @param commenterUri
* @param showLink
* @returns {function(Dispatch): *}
*/
export function doCommentModUnBlock(commenterUri: string, showLink: boolean = true) {
return (dispatch: Dispatch) => {
return dispatch(doCommentModToggleBlock(true, commenterUri, '', [], BLOCK_LEVEL.SELF, showLink));
};
}
/**
* Unblocks the commenter using the given channel that has Global privileges.
*
* @param commenterUri
* @param blockerId
* @returns {function(Dispatch): *}
*/
export function doCommentModUnBlockAsAdmin(commenterUri: string, blockerId: string) {
return (dispatch: Dispatch) => {
return dispatch(doCommentModToggleBlock(true, commenterUri, '', blockerId ? [blockerId] : [], BLOCK_LEVEL.ADMIN));
};
}
/**
* Unblocks the commenter using the given channel that has been granted
* moderation rights by the creator.
*
* @param commenterUri
* @param creatorId
* @param blockerId
* @returns {function(Dispatch): *}
*/
export function doCommentModUnBlockAsModerator(commenterUri: string, creatorId: string, blockerId: string) {
return (dispatch: Dispatch) => {
return dispatch(
doCommentModToggleBlock(true, commenterUri, creatorId, blockerId ? [blockerId] : [], BLOCK_LEVEL.MODERATOR)
);
return dispatch(doCommentModToggleBlock(commentAuthor, showLink, true));
};
}
@@ -809,80 +625,39 @@ export function doFetchModBlockedList() {
)
)
.then((res) => {
let personalBlockList = [];
let adminBlockList = [];
let moderatorBlockList = [];
let moderatorBlockListDelegatorsMap = {};
const blockListsPerChannel = res.map((r) => r.value);
blockListsPerChannel
const blockLists = res.map((r) => r.value);
let globalBlockList = [];
blockLists
.sort((a, b) => {
return 1;
})
.forEach((channelBlockLists) => {
const storeList = (fetchedList, blockedList, blockedByMap) => {
if (fetchedList) {
fetchedList.forEach((blockedChannel) => {
if (blockedChannel.blocked_channel_name) {
const channelUri = buildURI({
channelName: blockedChannel.blocked_channel_name,
claimId: blockedChannel.blocked_channel_id,
});
.forEach((channelBlockListData) => {
const blockListForChannel = channelBlockListData && channelBlockListData.blocked_channels;
if (blockListForChannel) {
blockListForChannel.forEach((blockedChannel) => {
if (blockedChannel.blocked_channel_name) {
const channelUri = buildURI({
channelName: blockedChannel.blocked_channel_name,
claimId: blockedChannel.blocked_channel_id,
});
if (!blockedList.find((blockedChannel) => blockedChannel.channelUri === channelUri)) {
blockedList.push({ channelUri, blockedAt: blockedChannel.blocked_at });
}
if (blockedByMap !== undefined) {
const blockedByChannelUri = buildURI({
channelName: blockedChannel.blocked_by_channel_name,
claimId: blockedChannel.blocked_by_channel_id,
});
if (blockedByMap[channelUri]) {
if (!blockedByMap[channelUri].includes(blockedByChannelUri)) {
blockedByMap[channelUri].push(blockedByChannelUri);
}
} else {
blockedByMap[channelUri] = [blockedByChannelUri];
}
}
if (!globalBlockList.find((blockedChannel) => blockedChannel.channelUri === channelUri)) {
globalBlockList.push({ channelUri, blockedAt: blockedChannel.blocked_at });
}
});
}
};
const blocked_channels = channelBlockLists && channelBlockLists.blocked_channels;
const globally_blocked_channels = channelBlockLists && channelBlockLists.globally_blocked_channels;
const delegated_blocked_channels = channelBlockLists && channelBlockLists.delegated_blocked_channels;
storeList(blocked_channels, personalBlockList);
storeList(globally_blocked_channels, adminBlockList);
storeList(delegated_blocked_channels, moderatorBlockList, moderatorBlockListDelegatorsMap);
}
});
}
});
dispatch({
type: ACTIONS.COMMENT_MODERATION_BLOCK_LIST_COMPLETED,
data: {
personalBlockList:
personalBlockList.length > 0
? personalBlockList
blockList:
globalBlockList.length > 0
? globalBlockList
.sort((a, b) => new Date(a.blockedAt) - new Date(b.blockedAt))
.map((blockedChannel) => blockedChannel.channelUri)
: null,
adminBlockList:
adminBlockList.length > 0
? adminBlockList
.sort((a, b) => new Date(a.blockedAt) - new Date(b.blockedAt))
.map((blockedChannel) => blockedChannel.channelUri)
: null,
moderatorBlockList:
moderatorBlockList.length > 0
? moderatorBlockList
.sort((a, b) => new Date(a.blockedAt) - new Date(b.blockedAt))
.map((blockedChannel) => blockedChannel.channelUri)
: null,
moderatorBlockListDelegatorsMap: moderatorBlockListDelegatorsMap,
},
});
})
@@ -939,206 +714,6 @@ export const doUpdateBlockListForPublishedChannel = (channelClaim: ChannelClaim)
};
};
export function doCommentModAddDelegate(
modChannelId: string,
modChannelName: string,
creatorChannelClaim: ChannelClaim,
showToast: boolean = false
) {
return async (dispatch: Dispatch, getState: GetState) => {
let signature: ?{
signature: string,
signing_ts: string,
};
try {
signature = await Lbry.channel_sign({
channel_id: creatorChannelClaim.claim_id,
hexdata: toHex(creatorChannelClaim.name),
});
} catch (e) {}
if (!signature) {
return;
}
return Comments.moderation_add_delegate({
mod_channel_id: modChannelId,
mod_channel_name: modChannelName,
creator_channel_id: creatorChannelClaim.claim_id,
creator_channel_name: creatorChannelClaim.name,
signature: signature.signature,
signing_ts: signature.signing_ts,
})
.then(() => {
if (showToast) {
dispatch(
doToast({
message: __('Added %user% as moderator for %myChannel%', {
user: modChannelName,
myChannel: creatorChannelClaim.name,
}),
linkText: __('Manage'),
linkTarget: `/${PAGES.SETTINGS_CREATOR}`,
})
);
}
})
.catch((err) => {
dispatch(
doToast({
message: err.message,
isError: true,
})
);
});
};
}
export function doCommentModRemoveDelegate(
modChannelId: string,
modChannelName: string,
creatorChannelClaim: ChannelClaim
) {
return async (dispatch: Dispatch, getState: GetState) => {
let signature: ?{
signature: string,
signing_ts: string,
};
try {
signature = await Lbry.channel_sign({
channel_id: creatorChannelClaim.claim_id,
hexdata: toHex(creatorChannelClaim.name),
});
} catch (e) {}
if (!signature) {
return;
}
return Comments.moderation_remove_delegate({
mod_channel_id: modChannelId,
mod_channel_name: modChannelName,
creator_channel_id: creatorChannelClaim.claim_id,
creator_channel_name: creatorChannelClaim.name,
signature: signature.signature,
signing_ts: signature.signing_ts,
}).catch((err) => {
dispatch(
doToast({
message: err.message,
isError: true,
})
);
});
};
}
export function doCommentModListDelegates(channelClaim: ChannelClaim) {
return async (dispatch: Dispatch, getState: GetState) => {
dispatch({
type: ACTIONS.COMMENT_FETCH_MODERATION_DELEGATES_STARTED,
});
let signature: ?{
signature: string,
signing_ts: string,
};
try {
signature = await Lbry.channel_sign({
channel_id: channelClaim.claim_id,
hexdata: toHex(channelClaim.name),
});
} catch (e) {}
if (!signature) {
dispatch({
type: ACTIONS.COMMENT_FETCH_MODERATION_DELEGATES_FAILED,
});
return;
}
return Comments.moderation_list_delegates({
creator_channel_id: channelClaim.claim_id,
creator_channel_name: channelClaim.name,
signature: signature.signature,
signing_ts: signature.signing_ts,
})
.then((response) => {
dispatch({
type: ACTIONS.COMMENT_FETCH_MODERATION_DELEGATES_COMPLETED,
data: {
id: channelClaim.claim_id,
delegates: response.Delegates,
},
});
})
.catch((err) => {
dispatch({
type: ACTIONS.COMMENT_FETCH_MODERATION_DELEGATES_FAILED,
});
});
};
}
export function doFetchCommentModAmIList(channelClaim: ChannelClaim) {
return async (dispatch: Dispatch, getState: GetState) => {
const state = getState();
const myChannels = selectMyChannelClaims(state);
dispatch({
type: ACTIONS.COMMENT_MODERATION_AM_I_LIST_STARTED,
});
let channelSignatures = [];
return Promise.all(myChannels.map((channel) => channelSignName(channel.claim_id, channel.name)))
.then((response) => {
channelSignatures = response;
// $FlowFixMe
return Promise.allSettled(
channelSignatures
.filter((x) => x !== undefined && x !== null)
.map((signatureData) =>
Comments.moderation_am_i({
channel_name: signatureData.name,
channel_id: signatureData.claim_id,
signature: signatureData.signature,
signing_ts: signatureData.signing_ts,
})
)
)
.then((res) => {
const delegatorsById = {};
channelSignatures.forEach((chanSig, index) => {
if (chanSig && res[index]) {
const value = res[index].value;
delegatorsById[chanSig.claim_id] = {
global: value ? value.type === 'Global' : false,
delegators: value && value.authorized_channels ? value.authorized_channels : {},
};
}
});
dispatch({
type: ACTIONS.COMMENT_MODERATION_AM_I_LIST_COMPLETED,
data: delegatorsById,
});
})
.catch((err) => {
dispatch({
type: ACTIONS.COMMENT_MODERATION_AM_I_LIST_FAILED,
});
});
})
.catch(() => {
dispatch({
type: ACTIONS.COMMENT_MODERATION_AM_I_LIST_FAILED,
});
});
};
}
export const doFetchCreatorSettings = (channelClaimIds: Array<string> = []) => {
return async (dispatch: Dispatch, getState: GetState) => {
const state = getState();
-7
View File
@@ -102,13 +102,6 @@ export const doCommentSocketConnect = (uri, claimId) => (dispatch) => {
data: { comment: newComment, claimId, uri },
});
}
if (response.type === 'viewers') {
const connected = response.data.connected;
dispatch({
type: ACTIONS.VIEWERS_RECEIVED,
data: { connected, claimId },
});
}
});
};
+48 -317
View File
@@ -1,7 +1,6 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import { handleActions } from 'util/redux-utils';
import { BLOCK_LEVEL } from 'constants/comment';
const defaultState: CommentsState = {
commentById: {}, // commentId -> Comment
@@ -22,18 +21,9 @@ const defaultState: CommentsState = {
myReactsByCommentId: undefined,
othersReactsByCommentId: undefined,
moderationBlockList: undefined,
adminBlockList: undefined,
moderatorBlockList: undefined,
moderatorBlockListDelegatorsMap: {},
fetchingModerationBlockList: false,
moderationDelegatesById: {},
fetchingModerationDelegates: false,
moderationDelegatorsById: {},
fetchingModerationDelegators: false,
blockingByUri: {},
unBlockingByUri: {},
togglingForDelegatorMap: {},
commentsDisabledChannelIds: [],
settingsByChannelId: {}, // ChannelId -> PerChannelSettings
fetchingSettings: false,
fetchingBlockedWords: false,
@@ -177,25 +167,7 @@ export default handleActions(
[ACTIONS.COMMENT_LIST_STARTED]: (state) => ({ ...state, isLoading: true }),
[ACTIONS.COMMENT_LIST_COMPLETED]: (state: CommentsState, action: any) => {
const { comments, claimId, uri, disabled, authorClaimId } = action.data;
const commentsDisabledChannelIds = [...state.commentsDisabledChannelIds];
if (disabled) {
if (!commentsDisabledChannelIds.includes(authorClaimId)) {
commentsDisabledChannelIds.push(authorClaimId);
}
return {
...state,
commentsDisabledChannelIds,
isLoading: false,
};
} else {
const index = commentsDisabledChannelIds.indexOf(authorClaimId);
if (index > -1) {
commentsDisabledChannelIds.splice(index, 1);
}
}
const { comments, claimId, uri } = action.data;
const commentById = Object.assign({}, state.commentById);
const byId = Object.assign({}, state.byId);
@@ -241,7 +213,6 @@ export default handleActions(
byId,
commentById,
commentsByUri,
commentsDisabledChannelIds,
isLoading: false,
};
},
@@ -400,14 +371,11 @@ export default handleActions(
fetchingModerationBlockList: true,
}),
[ACTIONS.COMMENT_MODERATION_BLOCK_LIST_COMPLETED]: (state: CommentsState, action: any) => {
const { personalBlockList, adminBlockList, moderatorBlockList, moderatorBlockListDelegatorsMap } = action.data;
const { blockList } = action.data;
return {
...state,
moderationBlockList: personalBlockList,
adminBlockList: adminBlockList,
moderatorBlockList: moderatorBlockList,
moderatorBlockListDelegatorsMap: moderatorBlockListDelegatorsMap,
moderationBlockList: blockList,
fetchingModerationBlockList: false,
};
},
@@ -416,312 +384,75 @@ export default handleActions(
fetchingModerationBlockList: false,
}),
[ACTIONS.COMMENT_MODERATION_BLOCK_STARTED]: (state: CommentsState, action: any) => {
const { blockedUri, creatorUri, blockLevel } = action.data;
[ACTIONS.COMMENT_MODERATION_BLOCK_STARTED]: (state: CommentsState, action: any) => ({
...state,
blockingByUri: {
...state.blockingByUri,
[action.data.uri]: true,
},
}),
switch (blockLevel) {
default:
case BLOCK_LEVEL.SELF:
case BLOCK_LEVEL.ADMIN:
return {
...state,
blockingByUri: {
...state.blockingByUri,
[blockedUri]: true,
},
};
[ACTIONS.COMMENT_MODERATION_UN_BLOCK_STARTED]: (state: CommentsState, action: any) => ({
...state,
unBlockingByUri: {
...state.unBlockingByUri,
[action.data.uri]: true,
},
}),
[ACTIONS.COMMENT_MODERATION_BLOCK_FAILED]: (state: CommentsState, action: any) => ({
...state,
blockingByUri: {
...state.blockingByUri,
[action.data.uri]: false,
},
}),
case BLOCK_LEVEL.MODERATOR:
const newMap = Object.assign({}, state.togglingForDelegatorMap);
const togglingDelegatorsForBlockedUri = newMap[blockedUri];
if (togglingDelegatorsForBlockedUri) {
if (!togglingDelegatorsForBlockedUri.includes(creatorUri)) {
togglingDelegatorsForBlockedUri.push(creatorUri);
}
} else {
newMap[blockedUri] = [creatorUri];
}
return {
...state,
togglingForDelegatorMap: newMap,
};
}
},
[ACTIONS.COMMENT_MODERATION_UN_BLOCK_STARTED]: (state: CommentsState, action: any) => {
const { blockedUri, creatorUri, blockLevel } = action.data;
switch (blockLevel) {
default:
case BLOCK_LEVEL.SELF:
case BLOCK_LEVEL.ADMIN:
return {
...state,
unBlockingByUri: {
...state.unBlockingByUri,
[blockedUri]: true,
},
};
case BLOCK_LEVEL.MODERATOR:
const newMap = Object.assign({}, state.togglingForDelegatorMap);
const togglingDelegatorsForBlockedUri = newMap[blockedUri];
if (togglingDelegatorsForBlockedUri) {
if (!togglingDelegatorsForBlockedUri.includes(creatorUri)) {
togglingDelegatorsForBlockedUri.push(creatorUri);
}
} else {
newMap[blockedUri] = [creatorUri];
}
return {
...state,
togglingForDelegatorMap: newMap,
};
}
},
[ACTIONS.COMMENT_MODERATION_BLOCK_FAILED]: (state: CommentsState, action: any) => {
const { blockedUri, creatorUri, blockLevel } = action.data;
switch (blockLevel) {
default:
case BLOCK_LEVEL.SELF:
case BLOCK_LEVEL.ADMIN:
return {
...state,
blockingByUri: {
...state.blockingByUri,
[blockedUri]: false,
},
};
case BLOCK_LEVEL.MODERATOR:
const newMap = Object.assign({}, state.togglingForDelegatorMap);
const togglingDelegatorsForBlockedUri = newMap[blockedUri];
if (togglingDelegatorsForBlockedUri) {
newMap[blockedUri] = togglingDelegatorsForBlockedUri.filter((x) => x !== creatorUri);
}
return {
...state,
togglingForDelegatorMap: newMap,
};
}
},
[ACTIONS.COMMENT_MODERATION_UN_BLOCK_FAILED]: (state: CommentsState, action: any) => {
const { blockedUri, creatorUri, blockLevel } = action.data;
switch (blockLevel) {
default:
case BLOCK_LEVEL.SELF:
case BLOCK_LEVEL.ADMIN:
return {
...state,
unBlockingByUri: {
...state.unBlockingByUri,
[blockedUri]: false,
},
};
case BLOCK_LEVEL.MODERATOR:
const newMap = Object.assign({}, state.togglingForDelegatorMap);
const togglingDelegatorsForBlockedUri = newMap[blockedUri];
if (togglingDelegatorsForBlockedUri) {
newMap[blockedUri] = togglingDelegatorsForBlockedUri.filter((x) => x !== creatorUri);
}
return {
...state,
togglingForDelegatorMap: newMap,
};
}
},
[ACTIONS.COMMENT_MODERATION_UN_BLOCK_FAILED]: (state: CommentsState, action: any) => ({
...state,
unBlockingByUri: {
...state.unBlockingByUri,
[action.data.uri]: false,
},
}),
[ACTIONS.COMMENT_MODERATION_BLOCK_COMPLETE]: (state: CommentsState, action: any) => {
const { blockedUri, creatorUri, blockLevel } = action.data;
const { channelUri } = action.data;
const commentById = Object.assign({}, state.commentById);
const blockingByUri = Object.assign({}, state.blockingByUri);
const moderationBlockList = state.moderationBlockList || [];
const newModerationBlockList = moderationBlockList.slice();
for (const commentId in commentById) {
const comment = commentById[commentId];
if (blockedUri === comment.channel_url) {
if (channelUri === comment.channel_url) {
delete commentById[comment.comment_id];
}
}
switch (blockLevel) {
case BLOCK_LEVEL.SELF: {
const blockList = state.moderationBlockList || [];
const newBlockList = blockList.slice();
newBlockList.push(blockedUri);
delete blockingByUri[blockedUri];
delete blockingByUri[channelUri];
return {
...state,
commentById,
blockingByUri,
moderationBlockList: newBlockList,
};
}
case BLOCK_LEVEL.MODERATOR: {
const blockList = state.moderatorBlockList || [];
const newBlockList = blockList.slice();
// Update main block list
if (!newBlockList.includes(blockedUri)) {
newBlockList.push(blockedUri);
}
// Update list of delegators
const moderatorBlockListDelegatorsMap = Object.assign({}, state.moderatorBlockListDelegatorsMap);
const delegatorUrisForBlockedUri = moderatorBlockListDelegatorsMap[blockedUri];
if (delegatorUrisForBlockedUri) {
if (!delegatorUrisForBlockedUri.includes(creatorUri)) {
delegatorUrisForBlockedUri.push(creatorUri);
}
} else {
moderatorBlockListDelegatorsMap[blockedUri] = [creatorUri];
}
// Remove "toggling" flag
const togglingMap = Object.assign({}, state.togglingForDelegatorMap);
const togglingDelegatorsForBlockedUri = togglingMap[blockedUri];
if (togglingDelegatorsForBlockedUri) {
togglingMap[blockedUri] = togglingDelegatorsForBlockedUri.filter((x) => x !== creatorUri);
}
return {
...state,
commentById,
moderatorBlockList: newBlockList,
moderatorBlockListDelegatorsMap,
togglingForDelegatorMap: togglingMap,
};
}
case BLOCK_LEVEL.ADMIN:
const blockList = state.adminBlockList || [];
const newBlockList = blockList.slice();
newBlockList.push(blockedUri);
delete blockingByUri[blockedUri];
return {
...state,
commentById,
blockingByUri,
adminBlockList: newBlockList,
};
}
},
[ACTIONS.COMMENT_MODERATION_UN_BLOCK_COMPLETE]: (state: CommentsState, action: any) => {
const { blockedUri, creatorUri, blockLevel } = action.data;
const unBlockingByUri = Object.assign(state.unBlockingByUri, {});
switch (blockLevel) {
case BLOCK_LEVEL.SELF: {
const blockList = state.moderationBlockList || [];
delete unBlockingByUri[blockedUri];
return {
...state,
unBlockingByUri,
moderationBlockList: blockList.slice().filter((uri) => uri !== blockedUri),
};
}
case BLOCK_LEVEL.ADMIN: {
const blockList = state.adminBlockList || [];
delete unBlockingByUri[blockedUri];
return {
...state,
unBlockingByUri,
adminBlockList: blockList.slice().filter((uri) => uri !== blockedUri),
};
}
case BLOCK_LEVEL.MODERATOR: {
const blockList = state.moderatorBlockList || [];
const newBlockList = blockList.slice();
const togglingMap = Object.assign({}, state.togglingForDelegatorMap);
const moderatorBlockListDelegatorsMap = Object.assign({}, state.moderatorBlockListDelegatorsMap);
const delegatorUrisForBlockedUri = moderatorBlockListDelegatorsMap[blockedUri];
if (delegatorUrisForBlockedUri) {
const index = delegatorUrisForBlockedUri.indexOf(creatorUri);
if (index > -1) {
// Remove from delegators list
delegatorUrisForBlockedUri.splice(index, 1);
// // Remove blocked entry if it was removed for all delegators
// if (delegatorUrisForBlockedUri.length === 0) {
// delete moderatorBlockListDelegatorsMap[blockedUri];
// newBlockList = newBlockList.filter((uri) => uri !== blockedUri);
// }
// Remove from "toggling" flag
const togglingDelegatorsForBlockedUri = togglingMap[blockedUri];
if (togglingDelegatorsForBlockedUri) {
togglingMap[blockedUri] = togglingDelegatorsForBlockedUri.filter((x) => x !== creatorUri);
}
}
}
return {
...state,
moderatorBlockList: newBlockList,
togglingForDelegatorMap: togglingMap,
};
}
}
},
[ACTIONS.COMMENT_FETCH_MODERATION_DELEGATES_STARTED]: (state: CommentsState, action: any) => ({
...state,
fetchingModerationDelegates: true,
}),
[ACTIONS.COMMENT_FETCH_MODERATION_DELEGATES_FAILED]: (state: CommentsState, action: any) => ({
...state,
fetchingModerationDelegates: false,
}),
[ACTIONS.COMMENT_FETCH_MODERATION_DELEGATES_COMPLETED]: (state: CommentsState, action: any) => {
const moderationDelegatesById = Object.assign({}, state.moderationDelegatesById);
if (action.data.delegates) {
moderationDelegatesById[action.data.id] = action.data.delegates.map((delegate) => {
return {
channelId: delegate.channel_id,
channelName: delegate.channel_name,
};
});
} else {
moderationDelegatesById[action.data.id] = [];
}
newModerationBlockList.push(channelUri);
return {
...state,
fetchingModerationDelegates: false,
moderationDelegatesById: moderationDelegatesById,
commentById,
blockingByUri,
moderationBlockList: newModerationBlockList,
};
},
[ACTIONS.COMMENT_MODERATION_UN_BLOCK_COMPLETE]: (state: CommentsState, action: any) => {
const { channelUri } = action.data;
const unBlockingByUri = Object.assign(state.unBlockingByUri, {});
const moderationBlockList = state.moderationBlockList || [];
const newModerationBlockList = moderationBlockList.slice().filter((uri) => uri !== channelUri);
[ACTIONS.COMMENT_MODERATION_AM_I_LIST_STARTED]: (state: CommentsState, action: any) => ({
...state,
fetchingModerationDelegators: true,
}),
delete unBlockingByUri[channelUri];
[ACTIONS.COMMENT_MODERATION_AM_I_LIST_FAILED]: (state: CommentsState, action: any) => ({
...state,
fetchingModerationDelegators: true,
}),
[ACTIONS.COMMENT_MODERATION_AM_I_LIST_COMPLETED]: (state: CommentsState, action: any) => {
return {
...state,
fetchingModerationDelegators: true,
moderationDelegatorsById: action.data,
unBlockingByUri,
moderationBlockList: newModerationBlockList,
};
},
-7
View File
@@ -4,7 +4,6 @@ import { handleActions } from 'util/redux-utils';
const defaultState: LivestreamState = {
fetchingById: {},
viewersById: {},
};
export default handleActions(
@@ -30,12 +29,6 @@ export default handleActions(
return { ...state, fetchingById: newIdsFetching };
},
[ACTIONS.VIEWERS_RECEIVED]: (state: LivestreamState, action: any) => {
const { connected, claimId } = action.data;
const newViewersById = Object.assign({}, state.viewersById);
newViewersById[claimId] = connected;
return { ...state, viewersById: newViewersById };
},
},
defaultState
);
+1 -80
View File
@@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
import { selectMutedChannels } from 'redux/selectors/blocked';
import { selectShowMatureContent } from 'redux/selectors/settings';
import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc';
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims, makeSelectClaimForUri } from 'lbry-redux';
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux';
const selectState = (state) => state.comments || {};
@@ -11,29 +11,10 @@ export const selectCommentsById = createSelector(selectState, (state) => state.c
export const selectIsFetchingComments = createSelector(selectState, (state) => state.isLoading);
export const selectIsPostingComment = createSelector(selectState, (state) => state.isCommenting);
export const selectIsFetchingReacts = createSelector(selectState, (state) => state.isFetchingReacts);
export const selectCommentsDisabledChannelIds = createSelector(
selectState,
(state) => state.commentsDisabledChannelIds
);
export const selectOthersReactsById = createSelector(selectState, (state) => state.othersReactsByCommentId);
export const selectModerationBlockList = createSelector(selectState, (state) =>
state.moderationBlockList ? state.moderationBlockList.reverse() : []
);
export const selectAdminBlockList = createSelector(selectState, (state) =>
state.adminBlockList ? state.adminBlockList.reverse() : []
);
export const selectModeratorBlockList = createSelector(selectState, (state) =>
state.moderatorBlockList ? state.moderatorBlockList.reverse() : []
);
export const selectModeratorBlockListDelegatorsMap = createSelector(
selectState,
(state) => state.moderatorBlockListDelegatorsMap
);
export const selectTogglingForDelegatorMap = createSelector(selectState, (state) => state.togglingForDelegatorMap);
export const selectBlockingByUri = createSelector(selectState, (state) => state.blockingByUri);
export const selectUnBlockingByUri = createSelector(selectState, (state) => state.unBlockingByUri);
export const selectFetchingModerationBlockList = createSelector(
@@ -41,32 +22,6 @@ export const selectFetchingModerationBlockList = createSelector(
(state) => state.fetchingModerationBlockList
);
export const selectModerationDelegatesById = createSelector(selectState, (state) => state.moderationDelegatesById);
export const selectIsFetchingModerationDelegates = createSelector(
selectState,
(state) => state.fetchingModerationDelegates
);
export const selectModerationDelegatorsById = createSelector(selectState, (state) => state.moderationDelegatorsById);
export const selectIsFetchingModerationDelegators = createSelector(
selectState,
(state) => state.fetchingModerationDelegators
);
export const selectHasAdminChannel = createSelector(selectState, (state) => {
const myChannelIds = Object.keys(state.moderationDelegatorsById);
for (let i = 0; i < myChannelIds.length; ++i) {
const id = myChannelIds[i];
if (state.moderationDelegatorsById[id] && state.moderationDelegatorsById[id].global) {
return true;
}
}
return false;
/// Lint doesn't like this:
// return Object.values(state.moderationDelegatorsById).some((x) => x.global);
});
export const selectCommentsByClaimId = createSelector(selectState, selectCommentsById, (state, byId) => {
const byClaimId = state.byId || {};
const comments = {};
@@ -339,7 +294,6 @@ export const makeSelectTotalCommentsCountForUri = (uri: string) =>
return comments ? comments.length : 0;
});
// Personal list
export const makeSelectChannelIsBlocked = (uri: string) =>
createSelector(selectModerationBlockList, (blockedChannelUris) => {
if (!blockedChannelUris || !blockedChannelUris) {
@@ -349,27 +303,6 @@ export const makeSelectChannelIsBlocked = (uri: string) =>
return blockedChannelUris.includes(uri);
});
export const makeSelectChannelIsAdminBlocked = (uri: string) =>
createSelector(selectAdminBlockList, (list) => {
return list ? list.includes(uri) : false;
});
export const makeSelectChannelIsModeratorBlocked = (uri: string) =>
createSelector(selectModeratorBlockList, (list) => {
return list ? list.includes(uri) : false;
});
export const makeSelectChannelIsModeratorBlockedForCreator = (uri: string, creatorUri: string) =>
createSelector(selectModeratorBlockList, selectModeratorBlockListDelegatorsMap, (blockList, delegatorsMap) => {
if (!blockList) return false;
return blockList.includes(uri) && delegatorsMap[uri] && delegatorsMap[uri].includes(creatorUri);
});
export const makeSelectIsTogglingForDelegator = (uri: string, creatorUri: string) =>
createSelector(selectTogglingForDelegatorMap, (togglingForDelegatorMap) => {
return togglingForDelegatorMap[uri] && togglingForDelegatorMap[uri].includes(creatorUri);
});
export const makeSelectUriIsBlockingOrUnBlocking = (uri: string) =>
createSelector(selectBlockingByUri, selectUnBlockingByUri, (blockingByUri, unBlockingByUri) => {
return blockingByUri[uri] || unBlockingByUri[uri];
@@ -397,15 +330,3 @@ export const makeSelectSuperChatTotalAmountForUri = (uri: string) =>
return superChatData.totalAmount;
});
export const makeSelectCommentsDisabledForUri = (uri: string) =>
createSelector(selectCommentsDisabledChannelIds, makeSelectClaimForUri(uri), (commentsDisabledChannelIds, claim) => {
const channelClaim = !claim
? null
: claim.value_type === 'channel'
? claim
: claim.signing_channel && claim.is_channel_signature_valid
? claim.signing_channel
: null;
return channelClaim && channelClaim.claim_id && commentsDisabledChannelIds.includes(channelClaim.claim_id);
});
-4
View File
@@ -21,14 +21,10 @@ export const makeSelectLivestreamsForChannelId = (channelId: string) =>
});
export const selectFetchingLivestreams = createSelector(selectState, (state) => state.fetchingById);
export const selectViewersById = createSelector(selectState, (state) => state.viewersById);
export const makeSelectIsFetchingLivestreams = (channelId: string) =>
createSelector(selectFetchingLivestreams, (fetchingLivestreams) => Boolean(fetchingLivestreams[channelId]));
export const makeSelectViewersForId = (channelId: string) =>
createSelector(selectViewersById, (viewers) => viewers[channelId]);
export const makeSelectPendingLivestreamsForChannelId = (channelId: string) =>
createSelector(selectPendingClaims, (pendingClaims) => {
return pendingClaims.filter(
-1
View File
@@ -10,7 +10,6 @@
@import 'component/ads';
@import 'component/animation';
@import 'component/badge';
@import 'component/block-list';
@import 'component/button';
@import 'component/card';
@import 'component/channel';
-18
View File
@@ -1,18 +0,0 @@
.block-list--moderator {
.button__content {
align-items: flex-start;
}
.section__actions {
flex-wrap: wrap;
}
}
.block-list--delegator {
padding: var(--spacing-s);
.button--alt,
.button--secondary {
margin-top: var(--spacing-xxs);
}
}
-6
View File
@@ -318,12 +318,6 @@ $thumbnailWidthSmall: 1rem;
font-size: var(--font-small);
border-bottom: 1px solid var(--color-border);
&:not(:first-child) {
margin-top: var(--spacing-xs);
padding-top: var(--spacing-xs);
border-top: 1px solid var(--color-border);
}
&:not(:last-child) {
margin-bottom: var(--spacing-xs);
}
+4 -25
View File
@@ -108,27 +108,6 @@
flex-direction: column;
}
&.navigation-link--with-thumbnail .button__content {
flex-direction: row;
.channel-thumbnail {
@include handleChannelGif(1.5rem);
flex-shrink: 0;
margin-right: var(--spacing-s);
}
.channel-staked__wrapper {
margin-bottom: 0.2rem;
left: -0.55rem;
.channel-staked__indicator {
height: 0.75rem;
width: 0.75rem;
margin-left: 0;
}
}
}
&:hover:not(.navigation-link--active),
&:focus {
@extend .navigation-link--highlighted;
@@ -139,8 +118,8 @@
margin-bottom: 0;
.icon {
height: 1.5rem;
width: 1.5rem;
height: 1rem;
width: 1rem;
}
.button__content {
@@ -226,8 +205,8 @@
margin-bottom: 0;
.icon {
height: 1.5rem;
width: 1.5rem;
height: 1rem;
width: 1rem;
}
.button__content {
-4
View File
@@ -84,8 +84,4 @@
background-color: var(--color-tag-words-bg-hover);
}
}
.tag__input {
max-width: 40rem;
}
}
-13
View File
@@ -1,13 +0,0 @@
export function webDownloadClaim(streamingUrl, fileName) {
// @if TARGET='web'
let element = document.createElement('a');
element.setAttribute('href', `${streamingUrl}?download=true`);
element.setAttribute('download', fileName);
element.style.display = 'none';
// $FlowFixMe
document.body.appendChild(element);
element.click();
// $FlowFixMe
document.body.removeChild(element);
// @endif
}
-70
View File
@@ -1,8 +1,5 @@
// @flow
import { isNameValid, isURIValid, normalizeURI, parseURI } from 'lbry-redux';
import { URL as SITE_URL, URL_LOCAL, URL_DEV } from 'config';
export function createNormalizedSearchKey(query: string) {
const FROM = '&from=';
@@ -36,70 +33,3 @@ export function getLivestreamOnlyOptions(options: any) {
newOptions.has_no_source = true;
return newOptions;
}
/**
* getUriForSearchTerm
* @param term
* @returns {string[]|*[]|(string|string)[]}
*/
export function getUriForSearchTerm(term: string) {
const WEB_DEV_PREFIX = `${URL_DEV}/`;
const WEB_LOCAL_PREFIX = `${URL_LOCAL}/`;
const WEB_PROD_PREFIX = `${SITE_URL}/`;
const ODYSEE_PREFIX = `https://odysee.com/`;
const includesLbryTvProd = term.includes(WEB_PROD_PREFIX);
const includesOdysee = term.includes(ODYSEE_PREFIX);
const includesLbryTvLocal = term.includes(WEB_LOCAL_PREFIX);
const includesLbryTvDev = term.includes(WEB_DEV_PREFIX);
const wasCopiedFromWeb = includesLbryTvDev || includesLbryTvLocal || includesLbryTvProd || includesOdysee;
const isLbryUrl = term.startsWith('lbry://') && term !== 'lbry://';
const error = '';
const addLbryIfNot = (term) => {
return term.startsWith('lbry://') ? term : `lbry://${term}`;
};
if (wasCopiedFromWeb) {
let prefix = WEB_PROD_PREFIX;
if (includesLbryTvLocal) prefix = WEB_LOCAL_PREFIX;
if (includesLbryTvDev) prefix = WEB_DEV_PREFIX;
if (includesOdysee) prefix = ODYSEE_PREFIX;
let query = (term && term.slice(prefix.length).replace(/:/g, '#')) || '';
try {
const lbryUrl = `lbry://${query}`;
parseURI(lbryUrl);
return [lbryUrl, null];
} catch (e) {
return [query, 'error'];
}
}
if (!isLbryUrl) {
if (term.startsWith('@')) {
if (isNameValid(term.slice(1))) {
return [term, null];
} else {
return [term, error];
}
}
return [addLbryIfNot(term), null];
} else {
try {
const isValid = isURIValid(term);
if (isValid) {
let uri;
try {
uri = normalizeURI(term);
} catch (e) {
return [term, null];
}
return [uri, null];
} else {
return [term, null];
}
} catch (e) {
return [term, 'error'];
}
}
}
-24
View File
@@ -1,24 +0,0 @@
// @flow
import { SITE_NAME } from 'config';
import React from 'react';
import Nag from 'component/common/nag';
import I18nMessage from 'component/i18nMessage';
export default function NagNoUser() {
return (
<Nag
type="error"
message={
<I18nMessage
tokens={{
SITE_NAME,
}}
>
Could not get a user ID. Account functions will be unavailable. Try again in a bit.
</I18nMessage>
}
actionText={__('Refresh')}
onClick={() => window.location.reload()}
/>
);
}
+2 -2
View File
@@ -14,7 +14,7 @@ export const STATUS_DOWN = 'down';
const getParams = (user) => {
const headers = {};
const token = getAuthToken();
if (token && user && user.has_verified_email) {
if (token && user.has_verified_email) {
headers[X_LBRY_AUTH_TOKEN] = token;
}
const params = { headers };
@@ -22,7 +22,7 @@ const getParams = (user) => {
};
export function useDegradedPerformance(onDegradedPerformanceCallback, user) {
const hasUser = user !== undefined && user !== null;
const hasUser = user !== undefined;
useEffect(() => {
if (hasUser) {