Compare commits

..
Author SHA1 Message Date
saltrafael aee9caa456 Squashed commit of the following: 2021-11-03 09:06:46 -04:00
351 changed files with 8654 additions and 7449 deletions

No files matched your search

+1 -2
View File
@@ -13,7 +13,6 @@ LBRY_WEB_STREAMING_API=https://cdn.lbryplayer.xyz
LBRY_WEB_BUFFER_API=https://collector-service.api.lbry.tv/api/v1/events/video
COMMENT_SERVER_API=https://comments.odysee.com/api/v2
COMMENT_SERVER_NAME=Odysee
SEARCH_SERVER_API_ALT=https://recsys.odysee.com/search
SEARCH_SERVER_API=https://lighthouse.odysee.com/search
SOCKETY_SERVER_API=wss://sockety.odysee.com/ws
THUMBNAIL_CDN_URL=https://thumbnails.odysee.com/optimize/
@@ -125,4 +124,4 @@ FIREBASE_STORAGE_BUCKET=lbry-mobile.appspot.com
FIREBASE_MESSAGING_SENDER_ID=638894153788
FIREBASE_APP_ID=1:638894153788:web:35b295b15297201bd2e339
FIREBASE_MEASUREMENT_ID=G-2MPJGFEEXC
FIREBASE_VAPID_KEY=BFayEBpwMTU9GQQpXgitIJkfx-SD8-ltrFb3wLTZWgA27MfBhG4948pe0eERl432NzPrMKsbkXnA7ap_vLPgLYk
FIREBASE_VAPID_KEY=BFayEBpwMTU9GQQpXgitIJkfx-SD8-ltrFb3wLTZWgA27MfBhG4948pe0eERl432NzPrMKsbkXnA7ap_vLPgLYk
+9 -8
View File
@@ -1,5 +1,5 @@
# Odysee Frontend - Odysee.com
# Odysee Frontend - Odysee.com
This repo contains the UI and front end code that powers Odysee.com.
@@ -37,11 +37,11 @@ This repo contains the UI and front end code that powers Odysee.com.
## Usage
Go to the website to interact on this frontend.
Double click the installed application to interact with the LBRY network.
## Running from Source
You can run the web version (odysee.com), via running onto your host machine, or go to the website itself.
You can run the web version (lbry.tv), the electron app, or both at the same time.
#### Prerequisites
@@ -49,15 +49,15 @@ You can run the web version (odysee.com), via running onto your host machine, or
- [Node.js](https://nodejs.org/en/download/) (v14 required)
- [Yarn](https://yarnpkg.com/en/docs/install)
1. Clone (or [fork](https://help.github.com/articles/fork-a-repo/)) this repository: `git clone https://github.com/OdyseeTeam/odysee-frontend`
2. Change directory into the cloned repository: `cd odysee-frontend`
1. Clone (or [fork](https://help.github.com/articles/fork-a-repo/)) this repository: `git clone https://github.com/lbryio/lbry-desktop`
2. Change directory into the cloned repository: `cd lbry-desktop`
3. Install the dependencies: `yarn`
#### Run the web app for development
`yarn dev:web`
- This uses webpack-dev-server and includes hot-reloading. If you want to debug the [web server we use in production](https://github.com/OdyseeTeam/odysee-frontend/blob/master/web/index.js) you can run `yarn dev:web-server`. This starts a server at `localhost:1337` and does not include hot reloading.
- This uses webpack-dev-server and includes hot-reloading. If you want to debug the [web server we use in production](https://github.com/lbryio/lbry-desktop/blob/master/web/index.js) you can run `yarn dev:web-server`. This starts a server at `localhost:1337` and does not include hot reloading.
#### Customize the web app
@@ -79,7 +79,7 @@ nano .env
1. add `CUSTOM_HOMEPAGE=true` to the '.env' file
2. copy `/custom/homepage.example.js` to `/custom/homepage.js` and make desired changes to `homepage.js`
- If you want up to two custom sidebar links:
- If you want up to two custom sidebar links
```
PINNED_URI_1=@someurl#2/someclaim#4
@@ -120,5 +120,6 @@ This project is MIT licensed. For the full license, see [LICENSE](LICENSE).
## Security
For security issues, please reach out to security@odysee.com
We take security seriously. Please contact security@odysee.com regarding any security issues. Our PGP key is [here](https://lbry.com/faq/pgp-key) if you need it. Previous versions up to v0.50.2 were signed by [Sean Yesmunt](https://keybase.io/seanyesmunt/key.asc).
New Releases are signed by [Jessop Breth](https://keybase.io/jessopb/key.asc).
+4 -9
View File
@@ -6,14 +6,12 @@ const config = {
WEBPACK_WEB_PORT: process.env.WEBPACK_WEB_PORT,
WEBPACK_ELECTRON_PORT: process.env.WEBPACK_ELECTRON_PORT,
WEB_SERVER_PORT: process.env.WEB_SERVER_PORT,
LBRY_WEB_API: process.env.LBRY_WEB_API, // api.na-backend.odysee.com',
LBRY_WEB_API: process.env.LBRY_WEB_API, //api.na-backend.odysee.com',
LBRY_WEB_PUBLISH_API: process.env.LBRY_WEB_PUBLISH_API,
LBRY_WEB_PUBLISH_API_V2: process.env.LBRY_WEB_PUBLISH_API_V2,
LBRY_API_URL: process.env.LBRY_API_URL, // api.lbry.com',
LBRY_WEB_STREAMING_API: process.env.LBRY_WEB_STREAMING_API, // cdn.lbryplayer.xyz',
LBRY_API_URL: process.env.LBRY_API_URL, //api.lbry.com',
LBRY_WEB_STREAMING_API: process.env.LBRY_WEB_STREAMING_API, //cdn.lbryplayer.xyz',
LBRY_WEB_BUFFER_API: process.env.LBRY_WEB_BUFFER_API,
SEARCH_SERVER_API: process.env.SEARCH_SERVER_API,
SEARCH_SERVER_API_ALT: process.env.SEARCH_SERVER_API_ALT,
COMMENT_SERVER_API: process.env.COMMENT_SERVER_API,
COMMENT_SERVER_NAME: process.env.COMMENT_SERVER_NAME,
SOCKETY_SERVER_API: process.env.SOCKETY_SERVER_API,
@@ -34,6 +32,7 @@ const config = {
TWITTER_ACCOUNT: process.env.TWITTER_ACCOUNT,
// LOGO
LOGO_TITLE: process.env.LOGO_TITLE,
FAVICON: process.env.FAVICON,
LOGO: process.env.LOGO,
LOGO_TEXT_LIGHT: process.env.LOGO_TEXT_LIGHT,
LOGO_TEXT_DARK: process.env.LOGO_TEXT_DARK,
@@ -89,11 +88,7 @@ const config = {
};
config.SDK_API_PATH = `${config.LBRY_WEB_API}/api/v1`;
config.PROXY_URL = `${config.SDK_API_PATH}/proxy`;
config.URL_DEV = `http://localhost:${config.WEBPACK_WEB_PORT}`;
config.URL_LOCAL = `http://localhost:${config.WEB_SERVER_PORT}`;
config.FAVICON = `/public/favicon-spaceman.png`;
module.exports = config;
+33
View File
@@ -1,4 +1,5 @@
import { app, Menu, shell } from 'electron';
import { ZOOM } from 'util/zoomWindow';
export default () => {
const template = [
@@ -22,6 +23,38 @@ export default () => {
label: 'View',
submenu: [
{ role: 'reload' },
{
label: 'Zoom',
submenu: [
{
label: 'Zoom In',
accelerator: 'CmdOrCtrl+=',
click: (menuItem, browserWindow) => {
if (browserWindow) {
browserWindow.webContents.send('zoom-window', ZOOM.INCREMENT);
}
},
},
{
label: 'Zoom Out',
accelerator: 'CmdOrCtrl+-',
click: (menuItem, browserWindow) => {
if (browserWindow) {
browserWindow.webContents.send('zoom-window', ZOOM.DECREMENT);
}
},
},
{
label: 'Reset Zoom',
accelerator: 'CmdOrCtrl+0',
click: (menuItem, browserWindow) => {
if (browserWindow) {
browserWindow.webContents.send('zoom-window', ZOOM.RESET);
}
},
},
],
},
{
label: 'Developer',
submenu: [{ role: 'forcereload' }, { role: 'toggledevtools' }],
+3
View File
@@ -83,6 +83,9 @@ export const SYNC_APPLY_FAILED = 'SYNC_APPLY_FAILED';
export const SYNC_APPLY_BAD_PASSWORD = 'SYNC_APPLY_BAD_PASSWORD';
export const SYNC_RESET = 'SYNC_RESET';
// Lbry.tv
export const UPDATE_UPLOAD_PROGRESS = 'UPDATE_UPLOAD_PROGRESS';
// User
export const GENERATE_AUTH_TOKEN_FAILURE = 'GENERATE_AUTH_TOKEN_FAILURE';
export const GENERATE_AUTH_TOKEN_STARTED = 'GENERATE_AUTH_TOKEN_STARTED';
+6 -3
View File
@@ -27,6 +27,7 @@ export {
doResetSync,
doSyncEncryptAndDecrypt,
} from 'redux/actions/sync';
export { doUpdateUploadProgress } from './redux/actions/web';
// reducers
export { authReducer } from './redux/reducers/auth';
@@ -36,12 +37,13 @@ export { filteredReducer } from './redux/reducers/filtered';
// export { homepageReducer } from './redux/reducers/homepage';
export { statsReducer } from './redux/reducers/stats';
export { syncReducer } from './redux/reducers/sync';
export { webReducer } from './redux/reducers/web';
// selectors
export { selectAuthToken, selectIsAuthenticating } from './redux/selectors/auth';
export {
selectFetchingCostInfoForUri,
selectCostInfoForUri,
makeSelectFetchingCostInfoForUri,
makeSelectCostInfoForUri,
selectAllCostInfoByUri,
selectFetchingCostInfo,
} from './redux/selectors/cost_info';
@@ -53,7 +55,7 @@ export { selectFilteredOutpoints, selectFilteredOutpointMap } from './redux/sele
// selectTrendingUris,
// selectFetchingTrendingUris,
// } from './redux/selectors/homepage';
export { selectViewCount, selectViewCountForUri, selectSubCountForUri } from './redux/selectors/stats';
export { selectViewCount, makeSelectViewCountForUri, makeSelectSubCountForUri } from './redux/selectors/stats';
export { selectBanStateForUri } from './redux/selectors/ban';
export {
selectHasSyncedWallet,
@@ -68,3 +70,4 @@ export {
selectSyncApplyErrorMessage,
selectSyncApplyPasswordError,
} from './redux/selectors/sync';
export { selectCurrentUploads, selectUploadCount } from './redux/selectors/web';
+4 -5
View File
@@ -1,13 +1,12 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import { Lbryio } from 'lbryinc';
import { selectClaimForUri } from 'redux/selectors/claims';
import { selectClaimsByUri } from 'redux/selectors/claims';
// eslint-disable-next-line import/prefer-default-export
export function doFetchCostInfoForUri(uri: string) {
return (dispatch: Dispatch, getState: GetState) => {
export function doFetchCostInfoForUri(uri) {
return (dispatch, getState) => {
const state = getState();
const claim = selectClaimForUri(state, uri);
const claim = selectClaimsByUri(state)[uri];
if (!claim) return;
+12
View File
@@ -0,0 +1,12 @@
// @flow
import * as ACTIONS from 'constants/action_types';
export const doUpdateUploadProgress = (
progress: string,
params: { [key: string]: any },
xhr: any
) => (dispatch: Dispatch) =>
dispatch({
type: ACTIONS.UPDATE_UPLOAD_PROGRESS,
data: { progress, params, xhr },
});
+62
View File
@@ -0,0 +1,62 @@
// @flow
import * as ACTIONS from 'constants/action_types';
/*
test mock:
currentUploads: {
'test#upload': {
progress: 50,
params: {
name: 'steve',
thumbnail_url: 'https://dev2.spee.ch/4/KMNtoSZ009fawGz59VG8PrID.jpeg',
},
},
},
*/
export type Params = {
channel?: string,
name: string,
thumbnail_url: ?string,
title: ?string,
};
export type UploadItem = {
progess: string,
params: Params,
xhr?: any,
};
export type TvState = {
currentUploads: { [key: string]: UploadItem },
};
const reducers = {};
const defaultState: TvState = {
currentUploads: {},
};
reducers[ACTIONS.UPDATE_UPLOAD_PROGRESS] = (state: TvState, action) => {
const { progress, params, xhr } = action.data;
const key = params.channel ? `${params.name}#${params.channel}` : `${params.name}#anonymous`;
let currentUploads;
if (!progress) {
currentUploads = Object.assign({}, state.currentUploads);
Object.keys(currentUploads).forEach(k => {
if (k === key) {
delete currentUploads[key];
}
});
} else {
currentUploads = Object.assign({}, state.currentUploads);
currentUploads[key] = { progress, params, xhr };
}
return { ...state, currentUploads };
};
export function webReducer(state: TvState = defaultState, action: any) {
const handler = reducers[action.type];
if (handler) return handler(state, action);
return state;
}
+51 -23
View File
@@ -8,57 +8,85 @@ import { createCachedSelector } from 're-reselect';
import { selectClaimForUri } from 'redux/selectors/claims';
import { selectMutedChannels } from 'redux/selectors/blocked';
import { selectModerationBlockList } from 'redux/selectors/comments';
import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc';
import { getChannelFromClaim } from 'util/claim';
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
import { isURIEqual } from 'util/lbryURI';
const selectClaimExistsForUri = (state, uri) => {
return Boolean(selectClaimForUri(state, uri));
};
const selectTxidForUri = (state, uri) => {
const claim = selectClaimForUri(state, uri);
const signingChannel = claim && claim.signing_channel;
return signingChannel ? signingChannel.txid : claim ? claim.txid : undefined;
};
const selectNoutForUri = (state, uri) => {
const claim = selectClaimForUri(state, uri);
const signingChannel = claim && claim.signing_channel;
return signingChannel ? signingChannel.nout : claim ? claim.nout : undefined;
};
const selectPermanentUrlForUri = (state, uri) => {
const claim = selectClaimForUri(state, uri);
const signingChannel = claim && claim.signing_channel;
return signingChannel ? signingChannel.permanent_url : claim ? claim.permanent_url : undefined;
};
export const selectBanStateForUri = createCachedSelector(
selectClaimForUri,
selectBlacklistedOutpointMap,
selectFilteredOutpointMap,
// Break apart 'selectClaimForUri' into 4 cheaper selectors that return
// primitives for values that we care about. The Claim object itself is easily
// invalidated due to constantly-changing fields like 'confirmation'.
selectClaimExistsForUri,
selectTxidForUri,
selectNoutForUri,
selectPermanentUrlForUri,
selectBlackListedOutpoints,
selectFilteredOutpoints,
selectMutedChannels,
selectModerationBlockList,
(claim, blackListedOutpointMap, filteredOutpointMap, mutedChannelUris, personalBlocklist) => {
(
claimExists,
txid,
nout,
permanentUrl,
blackListedOutpoints,
filteredOutpoints,
mutedChannelUris,
personalBlocklist
) => {
const banState = {};
if (!claim) {
if (!claimExists) {
return banState;
}
const channelClaim = getChannelFromClaim(claim);
// This will be replaced once blocking is done at the wallet server level.
if (blackListedOutpointMap) {
if (
(channelClaim && blackListedOutpointMap[`${channelClaim.txid}:${channelClaim.nout}`]) ||
blackListedOutpointMap[`${claim.txid}:${claim.nout}`]
) {
if (blackListedOutpoints) {
if (blackListedOutpoints.some((outpoint) => outpoint.txid === txid && outpoint.nout === nout)) {
banState['blacklisted'] = true;
}
}
// We're checking to see if the stream outpoint or signing channel outpoint
// is in the filter list.
if (filteredOutpointMap) {
if (
(channelClaim && filteredOutpointMap[`${channelClaim.txid}:${channelClaim.nout}`]) ||
filteredOutpointMap[`${claim.txid}:${claim.nout}`]
) {
if (filteredOutpoints) {
if (filteredOutpoints.some((outpoint) => outpoint.txid === txid && outpoint.nout === nout)) {
banState['filtered'] = true;
}
}
// block stream claims
// block channel claims if we can't control for them in claim search
if (mutedChannelUris.length && channelClaim) {
if (mutedChannelUris.some((blockedUri) => isURIEqual(blockedUri, channelClaim.permanent_url))) {
if (mutedChannelUris.length) {
if (mutedChannelUris.some((blockedUri) => isURIEqual(blockedUri, permanentUrl))) {
banState['muted'] = true;
}
}
// Commentron blocklist
if (personalBlocklist.length && channelClaim) {
if (personalBlocklist.some((blockedUri) => isURIEqual(blockedUri, channelClaim.permanent_url))) {
if (personalBlocklist.length) {
if (personalBlocklist.some((blockedUri) => isURIEqual(blockedUri, permanentUrl))) {
banState['blocked'] = true;
}
}
+10 -13
View File
@@ -1,16 +1,13 @@
// @flow
type State = { costInfo: any };
import { createSelector } from 'reselect';
export const selectState = (state: State) => state.costInfo || {};
export const selectAllCostInfoByUri = (state: State) => selectState(state).byUri;
export const selectFetchingCostInfo = (state: State) => selectState(state).fetching;
export const selectState = state => state.costInfo || {};
export const selectCostInfoForUri = (state: State, uri: string) => {
const costInfos = selectAllCostInfoByUri(state);
return costInfos && costInfos[uri];
};
export const selectAllCostInfoByUri = createSelector(selectState, state => state.byUri || {});
export const selectFetchingCostInfoForUri = (state: State, uri: string) => {
const fetchingByUri = selectFetchingCostInfo(state);
return fetchingByUri && fetchingByUri[uri];
};
export const makeSelectCostInfoForUri = uri =>
createSelector(selectAllCostInfoByUri, costInfos => costInfos && costInfos[uri]);
export const selectFetchingCostInfo = createSelector(selectState, state => state.fetching || {});
export const makeSelectFetchingCostInfoForUri = uri =>
createSelector(selectFetchingCostInfo, fetchingByUri => fetchingByUri && fetchingByUri[uri]);
+17 -17
View File
@@ -1,20 +1,20 @@
// @flow
import { selectClaimIdForUri } from 'redux/selectors/claims';
import { createSelector } from 'reselect';
import { makeSelectClaimForUri } from 'redux/selectors/claims';
type State = { claims: any, stats: any };
const selectState = state => state.stats || {};
export const selectViewCount = createSelector(selectState, state => state.viewCountById);
export const selectSubCount = createSelector(selectState, state => state.subCountById);
const selectState = (state: State) => state.stats || {};
export const selectViewCount = (state: State) => selectState(state).viewCountById;
export const selectSubCount = (state: State) => selectState(state).subCountById;
export const makeSelectViewCountForUri = uri =>
createSelector(
makeSelectClaimForUri(uri),
selectViewCount,
(claim, viewCountById) => (claim ? viewCountById[claim.claim_id] || 0 : 0)
);
export const selectViewCountForUri = (state: State, uri: string) => {
const claimId = selectClaimIdForUri(state, uri);
const viewCountById = selectViewCount(state);
return claimId ? viewCountById[claimId] || 0 : 0;
};
export const selectSubCountForUri = (state: State, uri: string) => {
const claimId = selectClaimIdForUri(state, uri);
const subCountById = selectSubCount(state);
return claimId ? subCountById[claimId] || 0 : 0;
};
export const makeSelectSubCountForUri = uri =>
createSelector(
makeSelectClaimForUri(uri),
selectSubCount,
(claim, subCountById) => (claim ? subCountById[claim.claim_id] || 0 : 0)
);
+10
View File
@@ -0,0 +1,10 @@
import { createSelector } from 'reselect';
const selectState = (state) => state.web || {};
export const selectCurrentUploads = (state) => selectState(state).currentUploads;
export const selectUploadCount = createSelector(
selectCurrentUploads,
(currentUploads) => currentUploads && Object.keys(currentUploads).length
);
+3 -3
View File
@@ -5,10 +5,10 @@ import { parseURI } from 'util/lbryURI';
import * as SETTINGS from 'constants/settings';
import { makeSelectClaimForUri } from 'redux/selectors/claims';
import { selectPlayingUri, selectPrimaryUri } from 'redux/selectors/content';
import { selectClientSetting, selectDaemonSettings } from 'redux/selectors/settings';
import { makeSelectClientSetting, selectDaemonSettings } from 'redux/selectors/settings';
import { history } from 'ui/store';
const recsysEndpoint = 'https://recsys.odysee.com/log/video/view';
const recsysEndpoint = 'https://clickstream.odysee.com/log/video/view';
const recsysId = 'lighthouse-v0';
const getClaimIdsFromUris = (uris) => {
@@ -229,7 +229,7 @@ const recsys = {
const claim = makeSelectClaimForUri(actualPlayingUri)(state);
const playingClaimId = claim ? claim.claim_id : null;
// const primaryUri = selectPrimaryUri(state);
const floatingPlayer = selectClientSetting(state, SETTINGS.FLOATING_PLAYER);
const floatingPlayer = makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state);
// When leaving page, if floating player is enabled, play will continue.
Object.keys(recsys.entries).forEach((claimId) => {
const shouldSkip = recsys.entries[claimId].parentUuid && !recsys.entries[claimId].recClaimIds;
+3 -7
View File
@@ -169,10 +169,8 @@ declare type CommentAbandonParams = {
comment_id: string,
creator_channel_id?: string,
creator_channel_name?: string,
signature?: string,
signing_ts?: string,
mod_channel_id?: string,
mod_channel_name?: string,
channel_id?: string,
hexdata?: string,
};
declare type CommentCreateParams = {
@@ -206,11 +204,9 @@ declare type ModerationBlockParams = {
// Creator that Moderator is delegated from. Used for delegated moderation
creator_channel_id?: string,
creator_channel_name?: string,
// ID of comment to remove as part of this block
offending_comment_id?: string,
// Blocks identity from comment universally, requires Admin rights on commentron instance
block_all?: boolean,
time_out?: ?number,
time_out?: number,
// If true will delete all comments of the offender, requires Admin rights on commentron for universal delete
delete_all?: boolean,
// The usual signature stuff
-23
View File
@@ -52,26 +52,3 @@ declare type PublishParams = {
nsfw: boolean,
tags: Array<Tag>,
};
declare type TusUploader = any;
declare type FileUploadSdkParams = {
file_path: string,
name: ?string,
preview?: boolean,
remote_url?: string,
thumbnail_url?: string,
title?: string,
// Temporary values
uploadUrl?: string,
};
declare type FileUploadItem = {
params: FileUploadSdkParams,
file: File,
fileFingerprint: string,
progress: string,
status?: string,
uploader?: TusUploader | XMLHttpRequest,
resumable: boolean,
};
+1 -2
View File
@@ -20,6 +20,7 @@
},
"main": "./dist/electron/main.js",
"scripts": {
"analyze": "yarn compile && source-map-explorer --no-border-checks web/dist/public/*.js --html analyzeResults.html",
"compile:electron": "node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --config webpack.electron.config.js",
"compile:web": "yarn copyenv && cd web && node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --config webpack.config.js",
"compile": "cross-env NODE_ENV=production yarn compile:electron && cross-env NODE_ENV=production yarn compile:web",
@@ -59,7 +60,6 @@
"if-env": "^1.0.4",
"match-sorter": "^6.3.0",
"parse-duration": "^1.0.0",
"player.js": "^0.1.0",
"proxy-polyfill": "0.1.6",
"re-reselect": "^4.0.0",
"react-datetime-picker": "^3.2.1",
@@ -69,7 +69,6 @@
"rss": "^1.2.2",
"source-map-explorer": "^2.5.2",
"tempy": "^0.6.0",
"tus-js-client": "^2.3.0",
"videojs-contrib-ads": "^6.9.0",
"videojs-ima": "^1.11.0",
"videojs-ima-player": "^0.5.6",
+50 -87
View File
@@ -55,30 +55,19 @@
"Deposit": "Deposit",
"Language": "Language",
"English": "English",
"Arabic": "Arabic",
"Chinese": "Chinese",
"Croatian": "Croatian",
"Czech": "Czech",
"Dutch": "Dutch",
"French": "French",
"German": "German",
"Greek": "Greek",
"Hindi": "Hindi",
"Indonesian": "Indonesian",
"Italian": "Italian",
"Japanese": "Japanese",
"Khmer": "Khmer",
"Korean": "Korean",
"Malay": "Malay",
"Norwegian": "Norwegian",
"Persian": "Persian",
"Polish": "Polish",
"Romanian": "Romanian",
"Russian": "Russian",
"Spanish": "Spanish",
"Thai": "Thai",
"Indonesian": "Indonesian",
"Italian": "Italian",
"Dutch": "Dutch",
"Turkish": "Turkish",
"Vietnamese": "Vietnamese",
"Polish": "Polish",
"Malay": "Malay",
"Khmer": "Khmer",
"By continuing, you accept the %lbry_terms_of_service%.": "By continuing, you accept the %lbry_terms_of_service%.",
"LBRY Terms of Service": "LBRY Terms of Service",
"Enter a thumbnail URL": "Enter a thumbnail URL",
@@ -122,7 +111,7 @@
"Balance": "Balance",
"Full History": "Full History",
"Refresh": "Refresh",
"Send Credits to your friends or favorite creators.": "Send Credits to your friends or favorite creators.",
"Send LBRY Credits to your friends or favorite creators.": "Send LBRY Credits to your friends or favorite creators.",
"Amount": "Amount",
"Recipient address": "Recipient address",
"Send": "Send",
@@ -184,10 +173,10 @@
"Confirm External Resource": "Confirm External Resource",
"Continue": "Continue",
"This file has been shared with you by other people.": "This file has been shared with you by other people.",
"Odysee is not responsible for its content, click continue to proceed at your own risk.": "Odysee is not responsible for its content, click continue to proceed at your own risk.",
"LBRY Inc is not responsible for its content, click continue to proceed at your own risk.": "LBRY Inc is not responsible for its content, click continue to proceed at your own risk.",
"Yes": "Yes",
"No": "No",
"These search results are provided by Odysee.": "These search results are provided by Odysee.",
"These search results are provided by LBRY, Inc.": "These search results are provided by LBRY, Inc.",
"View file": "View file",
"Files": "Files",
"Channels": "Channels",
@@ -250,9 +239,9 @@
"release notes": "release notes",
"Read the FAQ": "Read the FAQ",
"Our FAQ answers many common questions.": "Our FAQ answers many common questions.",
"Join the Foundation Chat": "Join the Foundation Chat",
"Join Our Chat": "Join Our Chat",
"Report a bug or suggest something": "Report a bug or suggest something",
"Did you find something wrong? Think Odysee could add something useful and cool?": "Did you find something wrong? Think Odysee could add something useful and cool?",
"Did you find something wrong? Think LBRY could add something useful and cool?": "Did you find something wrong? Think LBRY could add something useful and cool?",
"View your log": "View your log",
"support": "support",
"Open Log": "Open Log",
@@ -335,7 +324,7 @@
"Please wait for thumbnail to finish uploading": "Please wait for thumbnail to finish uploading",
"A thumbnail is required. Please upload or provide an image URL above.": "A thumbnail is required. Please upload or provide an image URL above.",
"Thumbnail is invalid.": "Thumbnail is invalid.",
"Please reselect a file after changing the URL": "Please reselect a file after changing the URL",
"Please reselect a file after changing the LBRY URL": "Please reselect a file after changing the LBRY URL",
"API connection string": "API connection string",
"Method": "Method",
"Parameters": "Parameters",
@@ -343,7 +332,7 @@
"Error message": "Error message",
"Error data": "Error data",
"Error": "Error",
"We're sorry that Odysee has encountered an error. Please try again or reach out to hello@odysee.com with detailed information.": "We're sorry that Odysee has encountered an error. Please try again or reach out to hello@odysee.com with detailed information.",
"We're sorry that LBRY has encountered an error. This has been reported and we will investigate the problem.": "We're sorry that LBRY has encountered an error. This has been reported and we will investigate the problem.",
"Customize": "Customize",
"Customize Your Homepage": "Customize Your Homepage",
"Tags You Follow": "Tags You Follow",
@@ -390,6 +379,7 @@
"Read more about why we do this.": "Read more about why we do this.",
"Submit Phone Number": "Submit Phone Number",
"Standard messaging rates apply. Having trouble?": "Standard messaging rates apply. Having trouble?",
"Join LBRY Chat": "Join LBRY Chat",
"Blockchain Sync": "Blockchain Sync",
"No rewards available": "No rewards available",
"You have claimed all available rewards! We're regularly adding more so be sure to check back later.": "You have claimed all available rewards! We're regularly adding more so be sure to check back later.",
@@ -403,8 +393,8 @@
"These LBRY Credits remain yours. It is a deposit to reserve the name and can be undone at any time.": "These LBRY Credits remain yours. It is a deposit to reserve the name and can be undone at any time.",
"Create channel": "Create channel",
"Uh oh. The flux in our Retro Encabulator must be out of whack. Try refreshing to fix it.": "Uh oh. The flux in our Retro Encabulator must be out of whack. Try refreshing to fix it.",
"Read Odysee Basics FAQ": "Read Odysee Basics FAQ",
"View all Odysee FAQs": "View all Odysee FAQs",
"Read the App Basics FAQ": "Read the App Basics FAQ",
"View all LBRY FAQs": "View all LBRY FAQs",
"Find assistance": "Find assistance",
"Email Us": "Email Us",
"Today": "Today",
@@ -481,7 +471,18 @@
"This file is in your library.": "This file is in your library.",
"Invalid claim ID %s.": "Invalid claim ID %s.",
"View Tag": "View Tag",
"Vietnamese": "Vietnamese",
"Thai": "Thai",
"Arabic": "Arabic",
"Czech": "Czech",
"Croatian": "Croatian",
"Korean": "Korean",
"Norwegian": "Norwegian",
"Romanian": "Romanian",
"Hindi": "Hindi",
"Greek": "Greek",
"Hide": "Hide",
"Persian": "Persian",
"Sorry, we can't preview this file.": "Sorry, we can't preview this file.",
"View File": "View File",
"Close": "Close",
@@ -513,7 +514,7 @@
"Not enough Credits": "Not enough Credits",
"Decrease amount to account for transaction fee": "Decrease amount to account for transaction fee",
"You have %credit_amount% in unclaimed rewards.": "You have %credit_amount% in unclaimed rewards.",
"In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this channel from our applications. Content may also be blocked due to DMCA Red Flag rules which are obvious copyright violations we come across, are discussed in public channels, or reported to us.": "In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this channel from our applications. Content may also be blocked due to DMCA Red Flag rules which are obvious copyright violations we come across, are discussed in public channels, or reported to us.",
"In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this channel from our applications.": "In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this channel from our applications.",
"Read More": "Read More",
"Read more": "Read more",
"Multi-language support is brand new and incomplete. Switching your language may have unintended consequences, like glossolalia.": "Multi-language support is brand new and incomplete. Switching your language may have unintended consequences, like glossolalia.",
@@ -548,7 +549,7 @@
"Your YouTube channel": "Your YouTube channel",
"Your YouTube channels": "Your YouTube channels",
"Your videos are currently being transferred. There is nothing else for you to do.": "Your videos are currently being transferred. There is nothing else for you to do.",
"Please check back later, this may take a few hours.": "Please check back later, this may take a few hours.",
"Please check back later. This may take up to 1 week.": "Please check back later. This may take up to 1 week.",
"%channelName% is not yet ready to be transferred. Please allow up to one week, though it is frequently faster.": "%channelName% is not yet ready to be transferred. Please allow up to one week, though it is frequently faster.",
"here": "here",
"%channelName% is not ready to be transferred. You can check the status %statusLink% or check back later.": "%channelName% is not ready to be transferred. You can check the status %statusLink% or check back later.",
@@ -646,8 +647,8 @@
"Failed to load %language% translations.": "Failed to load %language% translations.",
"contact support": "contact support",
"If you continue to have issues, please %support%.": "If you continue to have issues, please %support%.",
"odysee.com Account": "odysee.com Account",
"Creating a odysee.com account will allow you to earn rewards, receive content and security updates, and optionally backup your data.": "Creating a odysee.com account will allow you to earn rewards, receive content and security updates, and optionally backup your data.",
"lbry.tv Account": "lbry.tv Account",
"Creating a lbry.tv account will allow you to earn rewards, receive content and security updates, and optionally backup your data.": "Creating a lbry.tv account will allow you to earn rewards, receive content and security updates, and optionally backup your data.",
"Paid content cannot be embedded": "Paid content cannot be embedded",
"This content cannot be embedded": "This content cannot be embedded",
"Your videos are ready to be transferred.": "Your videos are ready to be transferred.",
@@ -705,6 +706,7 @@
"Use custom wallet servers": "Use custom wallet servers",
"Remove custom wallet server": "Remove custom wallet server",
"Add": "Add",
"In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.": "In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.",
"lbry.tv": "lbry.tv",
"Bid position must be a number.": "Bid position must be a number.",
"Copy": "Copy",
@@ -820,9 +822,9 @@
"Can this app send information about your usage to inform publishers and improve the software?": "Can this app send information about your usage to inform publishers and improve the software?",
"Yes, including with third-party analytics platforms": "Yes, including with third-party analytics platforms",
"Sending information to third parties (e.g. Google Analytics or Mixpanel) allows us to use detailed analytical reports to improve all aspects of LBRY.": "Sending information to third parties (e.g. Google Analytics or Mixpanel) allows us to use detailed analytical reports to improve all aspects of LBRY.",
"Yes, but only with Odysee, Inc.": "Yes, but only with Odysee, Inc.",
"Sharing information with Odysee, Inc. allows us to report to publishers how their content is doing, as well as track basic usage and performance. This is the minimum required to earn rewards from Odysee, Inc.": "Sharing information with Odysee, Inc. allows us to report to publishers how their content is doing, as well as track basic usage and performance. This is the minimum required to earn rewards from Odysee, Inc.",
"No information will be sent directly to Odysee, Inc. or third-parties about your usage. Note that as peer-to-peer software, your IP address and potentially other system information can be sent to other users, though this information is not stored permanently.": "No information will be sent directly to Odysee, Inc. or third-parties about your usage. Note that as peer-to-peer software, your IP address and potentially other system information can be sent to other users, though this information is not stored permanently.",
"Yes, but only with LBRY, Inc.": "Yes, but only with LBRY, Inc.",
"Sharing information with LBRY, Inc. allows us to report to publishers how their content is doing, as well as track basic usage and performance. This is the minimum required to earn rewards from LBRY, Inc.": "Sharing information with LBRY, Inc. allows us to report to publishers how their content is doing, as well as track basic usage and performance. This is the minimum required to earn rewards from LBRY, Inc.",
"No information will be sent directly to LBRY, Inc. or third-parties about your usage. Note that as peer-to-peer software, your IP address and potentially other system information can be sent to other users, though this information is not stored permanently.": "No information will be sent directly to LBRY, Inc. or third-parties about your usage. Note that as peer-to-peer software, your IP address and potentially other system information can be sent to other users, though this information is not stored permanently.",
"Let's go": "Let's go",
"Do you agree to the %terms%?": "Do you agree to the %terms%?",
"While we respect the desire for maximally private usage, please note that choosing this option hurts the ability for creators to understand how their content is performing.": "While we respect the desire for maximally private usage, please note that choosing this option hurts the ability for creators to understand how their content is performing.",
@@ -867,7 +869,7 @@
"Are you sure? Type %name% to confirm that you wish to remove the channel.": "Are you sure? Type %name% to confirm that you wish to remove the channel.",
"This will permanently remove your channel. Content published under this channel will be orphaned.": "This will permanently remove your channel. Content published under this channel will be orphaned.",
"Are you sure you'd like to remove \"%title%\"?": "Are you sure you'd like to remove \"%title%\"?",
"You are signed into odysee.com which automatically shares data with LBRY inc. %signout_button%.": "You are signed into odysee.com which automatically shares data with LBRY inc. %signout_button%.",
"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%.",
"%SITE_NAME% works better if you find and follow a couple creators you like. You can also block channels you never want to see.": "%SITE_NAME% 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",
"Nice! You are currently following %followingCount% creators": "Nice! You are currently following %followingCount% creators",
@@ -914,11 +916,6 @@
"Please decrease the amount to account for transaction fees": "Please decrease the amount to account for transaction fees",
"Amount cannot be blank": "Amount cannot be blank",
"Amount cannot be more than available": "Amount cannot be more than available",
"Amount is lower than price of $%price_amount%": "Amount is lower than price of $%price_amount%",
"Amount must have no more than 2 decimal places": "Amount must have no more than 2 decimal places",
"Insufficient amount (%input_amount% Credits = %converted_amount% USD).": "Insufficient amount (%input_amount% Credits = %converted_amount% USD).",
"This support is priced in $USD.": "This support is priced in $USD.",
"The current exchange rate for the submitted LBC amount is ~ $%exchange_amount%.": "The current exchange rate for the submitted LBC amount is ~ $%exchange_amount%.",
"Amount to unlock": "Amount to unlock",
"Unlock tips": "Unlock tips",
"Support This Claim": "Support This Claim",
@@ -1011,7 +1008,6 @@
"You deposited %amount% LBRY Credits as a support!": "You deposited %amount% LBRY Credits as a support!",
"You sent $%amount% as a tip to %tipChannelName%, I'm sure they appreciate it!": "You sent $%amount% as a tip to %tipChannelName%, I'm sure they appreciate it!",
"You sent %tipAmount% LBRY Credits as a tip to %tipChannelName%, I'm sure they appreciate it!": "You sent %tipAmount% LBRY Credits as a tip to %tipChannelName%, I'm sure they appreciate it!",
"You sent %lbc% as a tip, Mahalo!": "You sent %lbc% as a tip, Mahalo!",
"You sent %amount% LBRY Credits as a tip, Mahalo!": "You sent %amount% LBRY Credits as a tip, Mahalo!",
"You sent %amount% LBRY Credits": "You sent %amount% LBRY Credits",
"No stats found": "No stats found",
@@ -1056,15 +1052,15 @@
"Description of your issue or feature request": "Description of your issue or feature request",
"Submitting...": "Submitting...",
"Submit Report": "Submit Report",
"Developer? Or looking for more?": "Developer? Or looking for more?",
"Developer?": "Developer?",
"You can also:": "You can also:",
"Submit an issue on GitHub": "Submit an issue on GitHub",
"Most viewed recent content": "Most viewed recent content",
"Most viewed content all time": "Most viewed content all time",
"There are no stats for this channel yet, it will take a few views. Make sure you are signed in with the correct email and have data sharing turned on.": "There are no stats for this channel yet, it will take a few views. Make sure you are signed in with the correct email and have data sharing turned on.",
"Join LBRY's %tech_forum%": "Join LBRY's %tech_forum%",
"Join our %tech_forum%": "Join our %tech_forum%",
"tech forum": "tech forum",
"Explore LBRY's %technical_resources%": "Explore LBRY's %technical_resources%",
"Explore our %technical_resources%": "Explore our %technical_resources%",
"technical resources": "technical resources",
"Check your rewards page to see if you qualify for paid content reimbursement. Only content in this section qualifies.": "Check your rewards page to see if you qualify for paid content reimbursement. Only content in this section qualifies.",
"Discover Channels": "Discover Channels",
@@ -1084,11 +1080,11 @@
"Trending For Your Tags": "Trending For Your Tags",
"Latest From @lbry": "Latest From @lbry",
"Latest From @lbrycast": "Latest From @lbrycast",
"Hate these? %log_in_to_domain% for an ad free experience.": "Hate these? %log_in_to_domain% for an ad free experience.",
"Hate these? Login to Odysee for an ad free experience": "Hate these? Login to Odysee for an ad free experience",
"Hate these? %log_in_to_domain% or %download_the_app% for an ad free experience.": "Hate these? %log_in_to_domain% or %download_the_app% for an ad free experience.",
"Log in to %domain%": "Log in to %domain%",
"odysee collects usage information for itself only (%more_information%).": "odysee collects usage information for itself only (%more_information%).",
"odysee collects usage information for itself only (%more_information%). Want control over this and more?": "odysee collects usage information for itself only (%more_information%). Want control over this and more?",
"download the app": "download the app",
"lbry.tv collects usage information for itself only (%more_information%).": "lbry.tv collects usage information for itself only (%more_information%).",
"lbry.tv collects usage information for itself only (%more_information%). Want control over this and more?": "lbry.tv collects usage information for itself only (%more_information%). Want control over this and more?",
"more --[value for \"more_information\"]--": "more",
"%DOMAIN% performance may be degraded. You can try to use it, or wait 5 minutes and refresh. Please no crush us.": "%DOMAIN% performance may be degraded. You can try to use it, or wait 5 minutes and refresh. Please no crush us.",
"Please %sign_in_link% to comment.": "Please %sign_in_link% to comment.",
@@ -1112,7 +1108,7 @@
"minute": "minute",
"hours": "hours",
"hour": "hour",
"%SITE_NAME% uploads are limited to %limit% GB.": "%SITE_NAME% uploads are limited to %limit% GB.",
"%SITE_NAME% uploads are limited to %limit% GB. Download the app for unrestricted publishing.": "%SITE_NAME% uploads are limited to %limit% GB. Download the app for unrestricted publishing.",
"Connected": "Connected",
"Not connected": "Not connected",
"this link": "this link",
@@ -1294,19 +1290,8 @@
"Select a file to upload": "Select a file to upload",
"Select file to upload": "Select file to upload",
"Url copied.": "Url copied.",
"Failed to initiate upload (%err%)": "Failed to initiate upload (%err%)",
"Invalid file": "Invalid file",
"It appears to be a different or modified file.": "It appears to be a different or modified file.",
"Please select the same file from the initial upload.": "Please select the same file from the initial upload.",
"Cancel upload": "Cancel upload",
"Cancel and remove the selected upload?": "Cancel and remove the selected upload?",
"Select the file to resume upload...": "Select the file to resume upload...",
"Stopped.": "Stopped.",
"Resume": "Resume",
"Retrying...": "Retrying...",
"Uploading...": "Uploading...",
"Creating...": "Creating...",
"Stopped. Duplicate session detected.": "Stopped. Duplicate session detected.",
"Use a URL": "Use a URL",
"Edit Cover Image": "Edit Cover Image",
"Cover Image": "Cover Image",
@@ -1412,7 +1397,6 @@
"Cheese": "Cheese",
"Cooking": "Cooking",
"Big Hits": "Big Hits",
"Education": "Education",
"Enlightenment": "Enlightenment",
"Gaming": "Gaming",
"Game": "Game",
@@ -1423,7 +1407,6 @@
"Movies": "Movies",
"News": "News",
"News & Politics": "News & Politics",
"Pop Culture": "Pop Culture",
"Finance 2.0": "Finance 2.0",
"The Universe": "The Universe",
"Wild West": "Wild West",
@@ -1446,6 +1429,7 @@
"Log in to %SITE_NAME%": "Log in to %SITE_NAME%",
"Log in": "Log in",
"Not Yet": "Not Yet",
"Preparing...": "Preparing...",
"Confirm Upload": "Confirm Upload",
"Confirm Edit": "Confirm Edit",
"Create Livestream": "Create Livestream",
@@ -1655,6 +1639,7 @@
"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",
"Watch on %SITE_NAME%": "Watch on %SITE_NAME%",
@@ -1665,7 +1650,6 @@
"Most Supported": "Most Supported",
"Search Results": "Search Results",
"View All Results": "View All Results",
"View All Playlists": "View All Playlists",
"View competing uploads for %name%": "View competing uploads for %name%",
"Homepage": "Homepage",
"Currently winning": "Currently winning",
@@ -1676,7 +1660,7 @@
"POWERED BY %lbry_link%": "POWERED BY %lbry_link%",
"Learn more about LBRY Credits on %DOMAIN%": "Learn more about LBRY Credits on %DOMAIN%",
"Results boosted by %lbc%": "Results boosted by %lbc%",
"Uploaded image will be visible in a few minutes after you submit this form.": "Uploaded image will be visible in a few minutes after you submit this form.",
"This will be visible in a few minutes.": "This will be visible in a few minutes.",
"Turn on notifications": "Turn on notifications",
"Turn off notifications": "Turn off notifications",
"Notifications turned off for %channel%.": "Notifications turned off for %channel%.",
@@ -1712,7 +1696,7 @@
"Enter a name or %domain% URL": "Enter a name or %domain% URL",
"Winning amount: %amount%": "Winning amount: %amount%",
"Download or get the app": "Download or get the app",
"This content can be downloaded from odysee.com, but not displayed. It will display in LBRY Desktop, an app for desktop computers.": "This content can be downloaded from odysee.com, but not displayed. It will display in LBRY Desktop, an app for desktop computers.",
"This content can be downloaded from lbry.tv, but not displayed. It will display in LBRY Desktop, an app for desktop computers.": "This content can be downloaded from lbry.tv, but not displayed. It will display in LBRY Desktop, an app for desktop computers.",
"Repost Here": "Repost Here",
"Publish Here": "Publish Here",
"Close sidebar - hide channels you are following.": "Close sidebar - hide channels you are following.",
@@ -1845,7 +1829,7 @@
"Only visible to you": "Only visible to you",
"People who view this link will be redirected to your livestream. Make sure to use this for sharing so your title and thumbnail are displayed properly.": "People who view this link will be redirected to your livestream. Make sure to use this for sharing so your title and thumbnail are displayed properly.",
"View livestream": "View livestream",
"You need to upload your livestream details before you can go live. Please note: Replays must be published manually after your stream via the Update button on the livestream.": "You need to upload your livestream details before you can go live. Please note: Replays must be published manually after your stream via the Update button on the livestream.",
"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.",
@@ -1899,7 +1883,6 @@
"Alternative coins": "Alternative coins",
"Failed to initiate swap.": "Failed to initiate swap.",
"Failed to query swap status.": "Failed to query swap status.",
"odysee.com is currently down": "odysee.com is currently down",
"The system is currently down. Come back later.": "The system is currently down. Come back later.",
"Unable to obtain exchange rate. Try again later.": "Unable to obtain exchange rate. Try again later.",
"The amount needs to be higher": "The amount needs to be higher",
@@ -2036,8 +2019,7 @@
"Replay video available": "Replay video available",
"Check for Replays": "Check for Replays",
"You can upload your own recording or select a replay when your stream is over": "You can upload your own recording or select a replay when your stream is over",
"This channel isn't staking enough Credits for inline image previews.": "This channel isn't staking enough Credits for inline image previews.",
"This channel isn't staking enough Credits for link previews.": "This channel isn't staking enough Credits for link previews.",
"This channel isn't staking enough LBRY Credits for inline image previews.": "This channel isn't staking enough LBRY Credits for inline image previews.",
"Latest": "Latest",
"Channel Not Found": "Channel Not Found",
"Channel not found": "Channel not found",
@@ -2223,24 +2205,5 @@
"On Firefox, notifications won't function if cookies are set to clear on browser close. Please disable or add an exception for Odysee, then refresh.": "On Firefox, notifications won't function if cookies are set to clear on browser close. Please disable or add an exception for Odysee, then refresh.",
"For Brave, enable google push notifications in settings.": "For Brave, enable google push notifications in settings.",
"Check browser settings to see if notifications are disabled or otherwise restricted.": "Check browser settings to see if notifications are disabled or otherwise restricted.",
"Claiming credits...": "Claiming credits...",
"Sending...": "Sending...",
"Enter the full channel name or URL to search.\n\nExamples:\n - @channel\n - @channel#3\n - https://odysee.com/@Odysee:8\n - lbry://@Odysee#8": "Enter the full channel name or URL to search.\n\nExamples:\n - @channel\n - @channel#3\n - https://odysee.com/@Odysee:8\n - lbry://@Odysee#8",
"Choose %asset%": "Choose %asset%",
"Showing %filtered% results of %total%": "Showing %filtered% results of %total%",
"Failed to synchronize settings. Wait a while before retrying.": "Failed to synchronize settings. Wait a while before retrying.",
"You are offline. Check your internet connection.": "You are offline. Check your internet connection.",
"A new version of Odysee is available.": "A new version of Odysee is available.",
"Reset stream": "Reset stream",
"Live stream successfully reset.": "Live stream successfully reset.",
"There was an error resetting the live stream.": "There was an error resetting the live stream.",
"If you're having trouble starting a stream or if your stream shows that you're live but aren't, try a reset. If the problem persists, please reach out at %SITE_HELP_EMAIL%.": "If you're having trouble starting a stream or if your stream shows that you're live but aren't, try a reset. If the problem persists, please reach out at %SITE_HELP_EMAIL%.",
"Stickers": "Stickers",
"Different Sticker": "Different Sticker",
"Cash": "Cash",
"Switch to Cash": "Switch to Cash",
"Switch to Credits": "Switch to Credits",
"Cookies": "Cookies",
"Did someone invite you to use Odysee? Tell us who and you both get a reward!": "Did someone invite you to use Odysee? Tell us who and you both get a reward!",
"--end--": "--end--"
}
+4 -6
View File
@@ -5,12 +5,10 @@
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BB8DNPB73F"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
ad_storage: 'denied',
analytics_storage: 'denied',
'ad_storage': 'denied',
'analytics_storage': 'denied',
});
gtag('js', new Date());
gtag('config', 'G-BB8DNPB73F');
@@ -28,7 +26,7 @@
<link rel="preload" href="/public/font/v1/700.woff" as="font" type="font/woff" crossorigin />
<link rel="preload" href="/public/font/v1/700i.woff" as="font" type="font/woff" crossorigin />
<link rel="shortcut icon" href="/public/favicon-spaceman.png" />
<link rel="shortcut icon" href="/public/favicon-spaceman.png">
<style>
@font-face {
+3 -4
View File
@@ -2,7 +2,7 @@
import { Lbryio } from 'lbryinc';
import * as Sentry from '@sentry/browser';
import * as RENDER_MODES from 'constants/file_render_modes';
import { SDK_API_PATH } from 'config';
import { SDK_API_PATH } from './index';
// --- GA ---
// - Events: 500 max (cannot be deleted).
@@ -277,6 +277,7 @@ const analytics: Analytics = {
videoType = passedPlayer.currentSource().type;
videoPlayer = passedPlayer;
bitrateAsBitsPerSecond = videoBitrate;
sendPromMetric('time_to_start', timeToStartVideo);
},
error: (message) => {
@@ -383,8 +384,6 @@ const analytics: Analytics = {
return 'loaded_markdown';
case RENDER_MODES.IMAGE:
return 'loaded_image';
case 'livestream':
return 'loaded_livestream';
default:
return 'loaded_misc';
}
@@ -482,7 +481,7 @@ function sendPromMetric(name: string, value?: number) {
let url = new URL(SDK_API_PATH + '/metric/ui');
const params = { name: name, value: value ? value.toString() : '' };
url.search = new URLSearchParams(params).toString();
return fetch(url, { method: 'post' }).catch(function (error) {});
return fetch(url, { method: 'post' });
}
}
+18 -5
View File
@@ -1,5 +1,6 @@
import { hot } from 'react-hot-loader/root';
import { connect } from 'react-redux';
import { selectUploadCount } from 'lbryinc';
import { selectGetSyncErrorMessage, selectSyncFatalError } from 'redux/selectors/sync';
import { doFetchAccessToken, doUserSetReferrer } from 'redux/actions/user';
import { selectUser, selectAccessToken, selectUserVerifiedEmail } from 'redux/selectors/user';
@@ -8,7 +9,12 @@ import { doFetchChannelListMine, doFetchCollectionListMine, doResolveUris } from
import { selectMyChannelUrls } from 'redux/selectors/claims';
import * as SETTINGS from 'constants/settings';
import { selectSubscriptions } from 'redux/selectors/subscriptions';
import { selectClientSetting, selectLanguage, selectLoadedLanguages, selectThemePath } from 'redux/selectors/settings';
import {
makeSelectClientSetting,
selectLanguage,
selectLoadedLanguages,
selectThemePath,
} from 'redux/selectors/settings';
import {
selectIsUpgradeAvailable,
selectAutoUpdateDownloaded,
@@ -16,10 +22,15 @@ import {
selectActiveChannelClaim,
selectIsReloadRequired,
} from 'redux/selectors/app';
import { selectUploadCount } from 'redux/selectors/publish';
import { doSetLanguage } from 'redux/actions/settings';
import { doGetWalletSyncPreference, doSetLanguage } from 'redux/actions/settings';
import { doSyncLoop } from 'redux/actions/sync';
import { doDownloadUpgradeRequested, doSignIn, doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
import {
doDownloadUpgradeRequested,
doSignIn,
doGetAndPopulatePreferences,
doSetActiveChannel,
doSetIncognito,
} from 'redux/actions/app';
import { doFetchModBlockedList, doFetchCommentModAmIList } from 'redux/actions/comments';
import App from './view';
@@ -28,7 +39,7 @@ const select = (state) => ({
accessToken: selectAccessToken(state),
theme: selectThemePath(state),
language: selectLanguage(state),
syncEnabled: selectClientSetting(state, SETTINGS.ENABLE_SYNC),
syncEnabled: makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state),
languages: selectLoadedLanguages(state),
autoUpdateDownloaded: selectAutoUpdateDownloaded(state),
isUpgradeAvailable: selectIsUpgradeAvailable(state),
@@ -51,6 +62,8 @@ const perform = (dispatch) => ({
setLanguage: (language) => dispatch(doSetLanguage(language)),
signIn: () => dispatch(doSignIn()),
requestDownloadUpgrade: () => dispatch(doDownloadUpgradeRequested()),
updatePreferences: () => dispatch(doGetAndPopulatePreferences()),
getWalletSyncPref: () => dispatch(doGetWalletSyncPreference()),
syncLoop: (noInterval) => dispatch(doSyncLoop(noInterval)),
setReferrer: (referrer, doClaim) => dispatch(doUserSetReferrer(referrer, doClaim)),
setActiveChannelIfNotSet: () => dispatch(doSetActiveChannel()),
+110 -127
View File
@@ -4,7 +4,6 @@ import React, { useEffect, useRef, useState, useLayoutEffect } from 'react';
import { lazyImport } from 'util/lazyImport';
import classnames from 'classnames';
import analytics from 'analytics';
import { setSearchUserId } from 'redux/actions/search';
import { buildURI, parseURI } from 'util/lbryURI';
import { SIMPLE_SITE } from 'config';
import Router from 'component/router/index';
@@ -21,6 +20,12 @@ import REWARDS from 'rewards';
import usePersistedState from 'effects/use-persisted-state';
import Spinner from 'component/spinner';
import LANGUAGES from 'constants/languages';
// @if TARGET='app'
import useZoom from 'effects/use-zoom';
import useHistoryNav from 'effects/use-history-nav';
// @endif
// @if TARGET='web'
import YoutubeWelcome from 'web/component/youtubeReferralWelcome';
import {
useDegradedPerformance,
@@ -29,17 +34,22 @@ import {
STATUS_FAILING,
STATUS_DOWN,
} from 'web/effects/use-degraded-performance';
// @endif
import LANGUAGE_MIGRATIONS from 'constants/language-migrations';
const FileDrop = lazyImport(() => import('component/fileDrop' /* webpackChunkName: "fileDrop" */));
const NagContinueFirstRun = lazyImport(() => import('component/nagContinueFirstRun' /* webpackChunkName: "nagCFR" */));
const OpenInAppLink = lazyImport(() => import('web/component/openInAppLink' /* webpackChunkName: "openInAppLink" */));
// @if TARGET='web'
const NagDataCollection = lazyImport(() => import('web/component/nag-data-collection' /* webpackChunkName: "nagDC" */));
const NagDegradedPerformance = lazyImport(() =>
import('web/component/nag-degraded-performance' /* webpackChunkName: "NagDegradedPerformance" */)
);
const NagNoUser = lazyImport(() => import('web/component/nag-no-user' /* webpackChunkName: "nag-no-user" */));
const NagSunset = lazyImport(() => import('web/component/nag-sunset' /* webpackChunkName: "nag-sunset" */));
// @endif
const SyncFatalError = lazyImport(() => import('component/syncFatalError' /* webpackChunkName: "syncFatalError" */));
// ****************************************************************************
@@ -47,8 +57,11 @@ const SyncFatalError = lazyImport(() => import('component/syncFatalError' /* web
export const MAIN_WRAPPER_CLASS = 'main-wrapper';
export const IS_MAC = navigator.userAgent.indexOf('Mac OS X') !== -1;
// button numbers pulled from https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
const MOUSE_BACK_BTN = 3;
const MOUSE_FORWARD_BTN = 4;
const imaLibraryPath = 'https://imasdk.googleapis.com/js/sdkloader/ima3.js';
const securePrivacyScriptUrl = 'https://app.secureprivacy.ai/script/6194129b66262906dd4a5f43.js';
type Props = {
language: string,
@@ -56,7 +69,13 @@ type Props = {
theme: string,
user: ?{ id: string, has_verified_email: boolean, is_reward_approved: boolean },
location: { pathname: string, hash: string, search: string },
history: { push: (string) => void },
history: {
goBack: () => void,
goForward: () => void,
index: number,
length: number,
push: (string) => void,
},
fetchAccessToken: () => void,
fetchChannelListMine: () => void,
fetchCollectionListMine: () => void,
@@ -67,6 +86,8 @@ type Props = {
isUpgradeAvailable: boolean,
isReloadRequired: boolean,
autoUpdateDownloaded: boolean,
updatePreferences: () => Promise<any>,
getWalletSyncPref: () => Promise<any>,
uploadCount: number,
balance: ?number,
syncError: ?string,
@@ -106,6 +127,8 @@ function App(props: Props) {
language,
languages,
setLanguage,
updatePreferences,
getWalletSyncPref,
rewards,
setReferrer,
isAuthenticated,
@@ -125,18 +148,19 @@ function App(props: Props) {
const appRef = useRef();
const isEnhancedLayout = useKonamiListener();
const [hasSignedIn, setHasSignedIn] = useState(false);
const [readyForSync, setReadyForSync] = useState(false);
const [readyForPrefs, setReadyForPrefs] = useState(false);
const hasVerifiedEmail = user && Boolean(user.has_verified_email);
const isRewardApproved = user && user.is_reward_approved;
const previousHasVerifiedEmail = usePrevious(hasVerifiedEmail);
const previousRewardApproved = usePrevious(isRewardApproved);
// @if TARGET='web'
const [showAnalyticsNag, setShowAnalyticsNag] = usePersistedState('analytics-nag', true);
const [lbryTvApiStatus, setLbryTvApiStatus] = useState(STATUS_OK);
// @endif
const { pathname, hash, search } = props.location;
const [upgradeNagClosed, setUpgradeNagClosed] = useState(false);
const [resolvedSubscriptions, setResolvedSubscriptions] = useState(false);
const [retryingSync, setRetryingSync] = useState(false);
const [sidebarOpen] = usePersistedState('sidebar', true);
const [seenSunsestMessage, setSeenSunsetMessage] = usePersistedState('lbrytv-sunset', false);
const showUpgradeButton =
@@ -156,7 +180,6 @@ function App(props: Props) {
const hasActiveChannelClaim = activeChannelClaim !== undefined;
const isPersonalized = !IS_WEB || hasVerifiedEmail;
const renderFiledrop = !IS_WEB || isAuthenticated;
const isOnline = navigator.onLine;
let uri;
try {
@@ -164,58 +187,15 @@ function App(props: Props) {
uri = newpath + hash;
} catch (e) {}
// @if TARGET='web'
function handleAnalyticsDismiss() {
setShowAnalyticsNag(false);
}
function getStatusNag() {
// Handle "offline" first. Everything else is meaningless if it's offline.
if (!isOnline) {
return <Nag type="helpful" message={__('You are offline. Check your internet connection.')} />;
}
// Only 1 nag is possible, so show the most important:
if (user === null) {
return <NagNoUser />;
}
if (lbryTvApiStatus === STATUS_DEGRADED || lbryTvApiStatus === STATUS_FAILING) {
if (!shouldHideNag) {
return <NagDegradedPerformance onClose={() => setLbryTvApiStatus(STATUS_OK)} />;
}
}
if (syncFatalError) {
if (!retryingSync) {
return (
<Nag
type="error"
message={__('Failed to synchronize settings. Wait a while before retrying.')}
actionText={__('Retry')}
onClick={() => {
syncLoop(true);
setRetryingSync(true);
setTimeout(() => setRetryingSync(false), 4000);
}}
/>
);
}
} else if (isReloadRequired) {
return (
<Nag
message={__('A new version of Odysee is available.')}
actionText={__('Refresh')}
onClick={() => window.location.reload()}
/>
);
}
}
// @endif
useEffect(() => {
if (userId) {
analytics.setUser(userId);
setSearchUserId(userId);
}
}, [userId]);
@@ -229,6 +209,22 @@ function App(props: Props) {
return () => window.removeEventListener('beforeunload', handleBeforeUnload);
}, [uploadCount]);
// allows user to navigate history using the forward and backward buttons on a mouse
useEffect(() => {
const handleForwardAndBackButtons = (e) => {
switch (e.button) {
case MOUSE_BACK_BTN:
history.index > 0 && history.goBack();
break;
case MOUSE_FORWARD_BTN:
history.index < history.length - 1 && history.goForward();
break;
}
};
window.addEventListener('mouseup', handleForwardAndBackButtons);
return () => window.removeEventListener('mouseup', handleForwardAndBackButtons);
});
// allows user to pause miniplayer using the spacebar without the page scrolling down
useEffect(() => {
const handleKeyPress = (e) => {
@@ -240,6 +236,16 @@ function App(props: Props) {
return () => window.removeEventListener('keydown', handleKeyPress);
}, []);
// Enable ctrl +/- zooming on Desktop.
// @if TARGET='app'
useZoom();
// @endif
// Enable 'Alt + Left/Right' for history navigation on Desktop.
// @if TARGET='app'
useHistoryNav(history);
// @endif
useEffect(() => {
if (referredRewardAvailable && sanitizedReferrerParam && isRewardApproved) {
setReferrer(sanitizedReferrerParam, true);
@@ -318,6 +324,7 @@ function App(props: Props) {
}, [previousRewardApproved, isRewardApproved]);
// Load IMA3 SDK for aniview
// @if TARGET='web'
useEffect(() => {
const script = document.createElement('script');
script.src = imaLibraryPath;
@@ -329,91 +336,46 @@ function App(props: Props) {
document.body.removeChild(script);
};
}, []);
// @endif
// add secure privacy script
// @if TARGET='app'
useEffect(() => {
function inIframe() {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
if (updatePreferences && getWalletSyncPref && readyForPrefs) {
getWalletSyncPref()
.then(() => updatePreferences())
.then(() => {
setReadyForSync(true);
});
}
if (inIframe()) {
return;
}
const script = document.createElement('script');
script.src = securePrivacyScriptUrl;
script.async = true;
// might use this for future checking to prevent doubleloading
script.id = 'securePrivacy';
const cmpScript = document.createElement('script');
cmpScript.src = 'https://app.secureprivacy.ai/secureprivacy-plugin/web-plugin/cmp/cmp-v2.js';
cmpScript.async = true;
const getLocaleEndpoint = 'https://api.odysee.com/locale/get';
let gdprRequired;
try {
gdprRequired = localStorage.getItem('gdprRequired');
} catch (err) {
if (err) return;
}
// gdpr is known to be required, add script
if (gdprRequired === 'true') {
// $FlowFixMe
document.head.appendChild(script);
// $FlowFixMe
document.head.appendChild(cmpScript);
}
// haven't done a gdpr check, do it now
if (gdprRequired === null) {
(async function () {
const response = await fetch(getLocaleEndpoint);
const json = await response.json();
const gdprRequiredBasedOnLocation = json.data.gdpr_required;
// note we need gdpr and load script
if (gdprRequiredBasedOnLocation) {
localStorage.setItem('gdprRequired', 'true');
// $FlowFixMe
document.head.appendChild(script);
// $FlowFixMe
document.head.appendChild(cmpScript);
// note we don't need gdpr, save to session
} else if (gdprRequiredBasedOnLocation === false) {
localStorage.setItem('gdprRequired', 'false');
}
})();
}
return () => {
try {
// $FlowFixMe
document.head.removeChild(script);
// $FlowFixMe
document.head.removeChild(cmpScript);
} catch (err) {
console.log(err);
}
};
}, []);
}, [updatePreferences, getWalletSyncPref, setReadyForSync, readyForPrefs, hasVerifiedEmail]);
// @endif
// ready for sync syncs, however after signin when hasVerifiedEmail, that syncs too.
useEffect(() => {
// signInSyncPref is cleared after sharedState loop.
const syncLoopWithoutInterval = () => syncLoop(true);
if (hasSignedIn && hasVerifiedEmail) {
if (readyForSync && hasVerifiedEmail) {
// In case we are syncing.
syncLoop();
// @if TARGET='web'
window.addEventListener('focus', syncLoopWithoutInterval);
// @endif
}
// @if TARGET='web'
return () => {
window.removeEventListener('focus', syncLoopWithoutInterval);
};
}, [hasSignedIn, hasVerifiedEmail, syncLoop]);
// @endif
}, [readyForSync, hasVerifiedEmail, syncLoop]);
// We know someone is logging in or not when we get their user object
// We'll use this to determine when it's time to pull preferences
// This will no longer work if desktop users no longer get a user object from lbryinc
useEffect(() => {
if (user) {
setReadyForPrefs(true);
}
}, [user, setReadyForPrefs]);
useEffect(() => {
if (syncError && isAuthenticated && !pathname.includes(PAGES.AUTH_WALLET_PASSWORD) && !currentModal) {
@@ -427,6 +389,7 @@ function App(props: Props) {
if (!hasSignedIn && hasVerifiedEmail) {
signIn();
setHasSignedIn(true);
if (IS_WEB) setReadyForSync(true);
}
}, [hasVerifiedEmail, signIn, hasSignedIn]);
@@ -440,8 +403,11 @@ function App(props: Props) {
}
}, [sidebarOpen, isPersonalized, resolvedSubscriptions, subscriptions, resolveUris, setResolvedSubscriptions]);
// @if TARGET='web'
useDegradedPerformance(setLbryTvApiStatus, user);
// @endif
// @if TARGET='web'
// 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
@@ -452,12 +418,16 @@ function App(props: Props) {
</div>
);
}
// @endif
if (isOnline && lbryTvApiStatus === STATUS_DOWN) {
// TODO: Rename `SyncFatalError` since it has nothing to do with syncing.
if (syncFatalError) {
return (
<React.Suspense fallback={null}>
<SyncFatalError lbryTvApiStatus={lbryTvApiStatus} />
<SyncFatalError
// @if TARGET='web'
lbryTvApiStatus={lbryTvApiStatus}
// @endif
/>
</React.Suspense>
);
}
@@ -476,7 +446,7 @@ function App(props: Props) {
{IS_WEB && lbryTvApiStatus === STATUS_DOWN ? (
<Yrbl
className="main--empty"
title={__('odysee.com is currently down')}
title={__('lbry.tv is currently down')}
subtitle={__('My wheel broke, but the good news is that someone from LBRY is working on it.')}
/>
) : (
@@ -499,17 +469,30 @@ function App(props: Props) {
)}
{/* @endif */}
{/* @if TARGET='web' */}
<YoutubeWelcome />
{!SIMPLE_SITE && !shouldHideNag && <OpenInAppLink uri={uri} />}
{!shouldHideNag && <NagContinueFirstRun />}
{fromLbrytvParam && !seenSunsestMessage && !shouldHideNag && (
<NagSunset email={hasVerifiedEmail} onClose={() => setSeenSunsetMessage(true)} />
)}
{(lbryTvApiStatus === STATUS_DEGRADED || lbryTvApiStatus === STATUS_FAILING) && !shouldHideNag && (
<NagDegradedPerformance onClose={() => setLbryTvApiStatus(STATUS_OK)} />
)}
{!SIMPLE_SITE && lbryTvApiStatus === STATUS_OK && showAnalyticsNag && !shouldHideNag && (
<NagDataCollection onClose={handleAnalyticsDismiss} />
)}
{getStatusNag()}
{user === null && <NagNoUser />}
{/* @endif */}
</React.Suspense>
{isReloadRequired && (
<Nag
message={__('A new version of Odysee is available.')}
actionText={__('Refresh')}
onClick={() => window.location.reload()}
/>
)}
</React.Fragment>
)}
</div>
+1 -1
View File
@@ -94,7 +94,7 @@ function ChannelAbout(props: Props) {
<div className="media__info-text media__info-text--constrained">{claim.claim_id}</div>
</div>
<label>{__('Staked Credits')}</label>
<label>{__('Staked LBRY Credits')}</label>
<div className="media__info-text">
<CreditAmount
badge={false}
+2 -2
View File
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { selectClaimIdForUri } from 'redux/selectors/claims';
import { makeSelectClaimIdForUri } from 'redux/selectors/claims';
import {
doCommentModUnBlock,
doCommentModBlock,
@@ -43,7 +43,7 @@ const select = (state, props) => {
isBlocked,
isToggling,
isBlockingOrUnBlocking: makeSelectUriIsBlockingOrUnBlocking(props.uri)(state),
creatorId: selectClaimIdForUri(state, props.creatorUri),
creatorId: makeSelectClaimIdForUri(props.creatorUri)(state),
};
};
+6 -6
View File
@@ -11,11 +11,11 @@ type Props = {
isBlockingOrUnBlocking: boolean,
isToggling: boolean,
doCommentModUnBlock: (string, boolean) => void,
doCommentModBlock: (string, ?string, ?Number, boolean) => void,
doCommentModBlock: (string, ?Number, boolean) => void,
doCommentModUnBlockAsAdmin: (string, string) => void,
doCommentModBlockAsAdmin: (string, ?string, ?string) => void,
doCommentModBlockAsAdmin: (string, string) => void,
doCommentModUnBlockAsModerator: (string, string, string) => void,
doCommentModBlockAsModerator: (string, ?string, string, ?string) => void,
doCommentModBlockAsModerator: (string, string, string) => void,
};
function ChannelBlockButton(props: Props) {
@@ -41,7 +41,7 @@ function ChannelBlockButton(props: Props) {
if (isBlocked) {
doCommentModUnBlock(uri, false);
} else {
doCommentModBlock(uri, undefined, undefined, false);
doCommentModBlock(uri, undefined, false);
}
break;
@@ -50,7 +50,7 @@ function ChannelBlockButton(props: Props) {
if (isBlocked) {
doCommentModUnBlockAsModerator(uri, creatorUri, '');
} else {
doCommentModBlockAsModerator(uri, undefined, creatorUri, undefined);
doCommentModBlockAsModerator(uri, creatorUri, '');
}
}
break;
@@ -59,7 +59,7 @@ function ChannelBlockButton(props: Props) {
if (isBlocked) {
doCommentModUnBlockAsAdmin(uri, '');
} else {
doCommentModBlockAsAdmin(uri, undefined, undefined);
doCommentModBlockAsAdmin(uri, '');
}
break;
}
+6 -8
View File
@@ -3,16 +3,16 @@ import { PAGE_SIZE } from 'constants/claim';
import {
makeSelectClaimsInChannelForPage,
makeSelectFetchingChannelClaims,
selectClaimIsMine,
makeSelectClaimIsMine,
makeSelectTotalPagesInChannelSearch,
selectClaimForUri,
makeSelectClaimForUri,
} from 'redux/selectors/claims';
import { doResolveUris } from 'redux/actions/claims';
import * as SETTINGS from 'constants/settings';
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
import { withRouter } from 'react-router';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
import ChannelContent from './view';
@@ -20,18 +20,16 @@ const select = (state, props) => {
const { search } = props.location;
const urlParams = new URLSearchParams(search);
const page = urlParams.get('page') || 0;
const claim = props.uri && selectClaimForUri(state, props.uri);
return {
pageOfClaimsInChannel: makeSelectClaimsInChannelForPage(props.uri, page)(state),
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
totalPages: makeSelectTotalPagesInChannelSearch(props.uri, PAGE_SIZE)(state),
channelIsMine: selectClaimIsMine(state, claim),
channelIsMine: makeSelectClaimIsMine(props.uri)(state),
channelIsBlocked: makeSelectChannelIsMuted(props.uri)(state),
claim,
claim: props.uri && makeSelectClaimForUri(props.uri)(state),
isAuthenticated: selectUserVerifiedEmail(state),
showMature: selectShowMatureContent(state),
tileLayout: selectClientSetting(state, SETTINGS.TILE_LAYOUT),
tileLayout: makeSelectClientSetting(SETTINGS.TILE_LAYOUT)(state),
};
};
+2 -6
View File
@@ -1,9 +1,7 @@
// @flow
import React from 'react';
import CommentsList from 'component/commentsList';
import Empty from 'component/common/empty';
import { lazyImport } from 'util/lazyImport';
const CommentsList = lazyImport(() => import('component/commentsList' /* webpackChunkName: "comments" */));
type Props = {
uri: string,
@@ -19,9 +17,7 @@ function ChannelDiscussion(props: Props) {
}
return (
<section className="section">
<React.Suspense fallback={null}>
<CommentsList uri={uri} linkedCommentId={linkedCommentId} commentsAreExpanded />
</React.Suspense>
<CommentsList uri={uri} linkedCommentId={linkedCommentId} commentsAreExpanded />
</section>
);
}
+4 -4
View File
@@ -1,7 +1,7 @@
import { connect } from 'react-redux';
import {
selectTitleForUri,
selectThumbnailForUri,
makeSelectTitleForUri,
makeSelectThumbnailForUri,
makeSelectCoverForUri,
makeSelectMetadataItemForUri,
makeSelectAmountForUri,
@@ -21,8 +21,8 @@ import ChannelForm from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
title: selectTitleForUri(state, props.uri),
thumbnailUrl: selectThumbnailForUri(state, props.uri),
title: makeSelectTitleForUri(props.uri)(state),
thumbnailUrl: makeSelectThumbnailForUri(props.uri)(state),
coverUrl: makeSelectCoverForUri(props.uri)(state),
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
website: makeSelectMetadataItemForUri(props.uri, 'website_url')(state),
+1 -1
View File
@@ -294,7 +294,7 @@ function ChannelForm(props: Props) {
{params.coverUrl &&
(coverError && isUpload.cover ? (
<div className="channel-cover__custom--waiting">
<p>{__('Uploaded image will be visible in a few minutes after you submit this form.')}</p>
<p>{__('Uploaded image will be visible in a few minutes.')}</p>
</div>
) : (
<img className="channel-cover__custom" src={coverSrc} onError={() => setCoverError(true)} />
@@ -1,10 +1,10 @@
import { connect } from 'react-redux';
import { selectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
import { makeSelectClaimForUri, makeSelectIsUriResolving } from 'redux/selectors/claims';
import ChannelMentionSuggestion from './view';
const select = (state, props) => ({
claim: selectClaimForUri(state, props.uri),
isResolvingUri: selectIsUriResolving(state, props.uri),
claim: makeSelectClaimForUri(props.uri)(state),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
});
export default connect(select)(ChannelMentionSuggestion);
+23 -13
View File
@@ -1,25 +1,35 @@
import { connect } from 'react-redux';
import { MAX_LIVESTREAM_COMMENTS } from 'constants/livestream';
import { selectShowMatureContent } from 'redux/selectors/settings';
import { selectSubscriptionUris } from 'redux/selectors/subscriptions';
import { selectSubscriptions } from 'redux/selectors/subscriptions';
import { withRouter } from 'react-router';
import { selectCanonicalUrlForUri } from 'redux/selectors/claims';
import { makeSelectClaimForUri } from 'redux/selectors/claims';
import { doResolveUris } from 'redux/actions/claims';
import { selectChannelMentionData } from 'redux/selectors/livestream';
import { selectTopLevelCommentsForUri } from 'redux/selectors/comments';
import ChannelMentionSuggestions from './view';
const select = (state, props) => {
const maxComments = props.isLivestream ? MAX_LIVESTREAM_COMMENTS : -1;
const data = selectChannelMentionData(state, props.uri, maxComments);
const subscriptionUris = selectSubscriptions(state).map(({ uri }) => uri);
const topLevelComments = selectTopLevelCommentsForUri(state, props.uri);
const commentorUris = [];
// Avoid repeated commentors
topLevelComments.map(({ channel_url }) => !commentorUris.includes(channel_url) && commentorUris.push(channel_url));
const getUnresolved = (uris) =>
uris.map((uri) => !makeSelectClaimForUri(uri)(state) && uri).filter((uri) => uri !== false);
const getCanonical = (uris) =>
uris
.map((uri) => makeSelectClaimForUri(uri)(state) && makeSelectClaimForUri(uri)(state).canonical_url)
.filter((uri) => Boolean(uri));
return {
commentorUris: data.commentorUris,
subscriptionUris: selectSubscriptionUris(state),
unresolvedCommentors: data.unresolvedCommentors,
unresolvedSubscriptions: data.unresolvedSubscriptions,
canonicalCreator: selectCanonicalUrlForUri(state, props.creatorUri),
canonicalCommentors: data.canonicalCommentors,
canonicalSubscriptions: data.canonicalSubscriptions,
commentorUris,
subscriptionUris,
unresolvedCommentors: getUnresolved(commentorUris),
unresolvedSubscriptions: getUnresolved(subscriptionUris),
canonicalCreator: getCanonical([props.creatorUri])[0],
canonicalCommentors: getCanonical(commentorUris),
canonicalSubscriptions: getCanonical(subscriptionUris),
showMature: selectShowMatureContent(state),
};
};
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { selectIsUriResolving } from 'redux/selectors/claims';
import { makeSelectIsUriResolving } from 'redux/selectors/claims';
import { doResolveUri } from 'redux/actions/claims';
import { makeSelectWinningUriForQuery } from 'redux/selectors/search';
import ChannelMentionTopSuggestion from './view';
@@ -8,7 +8,7 @@ const select = (state, props) => {
const uriFromQuery = `lbry://${props.query}`;
return {
uriFromQuery,
isResolvingUri: selectIsUriResolving(state, uriFromQuery),
isResolvingUri: makeSelectIsUriResolving(uriFromQuery)(state),
winningUri: makeSelectWinningUriForQuery(props.query)(state),
};
};
+6 -6
View File
@@ -1,15 +1,15 @@
import { connect } from 'react-redux';
import {
selectClaimForUri,
selectStakedLevelForChannelUri,
selectTotalStakedAmountForChannelUri,
makeSelectClaimForUri,
makeSelectStakedLevelForChannelUri,
makeSelectTotalStakedAmountForChannelUri,
} from 'redux/selectors/claims';
import ChannelStakedIndicator from './view';
const select = (state, props) => ({
channelClaim: selectClaimForUri(state, props.uri),
amount: selectTotalStakedAmountForChannelUri(state, props.uri),
level: selectStakedLevelForChannelUri(state, props.uri),
channelClaim: makeSelectClaimForUri(props.uri)(state),
amount: makeSelectTotalStakedAmountForChannelUri(props.uri)(state),
level: makeSelectStakedLevelForChannelUri(props.uri)(state),
});
export default connect(select)(ChannelStakedIndicator);
+4 -4
View File
@@ -1,12 +1,12 @@
import { connect } from 'react-redux';
import { selectThumbnailForUri, selectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
import { makeSelectThumbnailForUri, makeSelectClaimForUri, makeSelectIsUriResolving } from 'redux/selectors/claims';
import { doResolveUri } from 'redux/actions/claims';
import ChannelThumbnail from './view';
const select = (state, props) => ({
thumbnail: selectThumbnailForUri(state, props.uri),
claim: selectClaimForUri(state, props.uri),
isResolving: selectIsUriResolving(state, props.uri),
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
isResolving: makeSelectIsUriResolving(props.uri)(state),
});
export default connect(select, {
+2 -4
View File
@@ -49,7 +49,7 @@ function ChannelThumbnail(props: Props) {
ThumbUploadError,
} = props;
const [thumbLoadError, setThumbLoadError] = React.useState(ThumbUploadError);
const shouldResolve = !isResolving && claim === undefined;
const shouldResolve = claim === undefined;
const thumbnail = rawThumbnail && rawThumbnail.trim().replace(/^http:\/\//i, 'https://');
const thumbnailPreview = rawThumbnailPreview && rawThumbnailPreview.trim().replace(/^http:\/\//i, 'https://');
const defaultAvatar = AVATAR_DEFAULT || Gerbil;
@@ -92,9 +92,7 @@ function ChannelThumbnail(props: Props) {
})}
>
{showDelayedMessage ? (
<div className="channel-thumbnail--waiting">
{__('This will be visible in a few minutes after you submit this form.')}
</div>
<div className="channel-thumbnail--waiting">{__('This will be visible in a few minutes.')}</div>
) : (
<OptimizedImage
alt={__('Channel profile picture')}
+2 -2
View File
@@ -1,9 +1,9 @@
import { connect } from 'react-redux';
import { makeSelectClaimForUri, selectTitleForUri } from 'redux/selectors/claims';
import { makeSelectClaimForUri, makeSelectTitleForUri } from 'redux/selectors/claims';
import ChannelTitle from './view';
const select = (state, props) => ({
title: selectTitleForUri(state, props.uri),
title: makeSelectTitleForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
});
@@ -1,10 +1,10 @@
import { connect } from 'react-redux';
import { selectInsufficientCreditsForUri } from 'redux/selectors/content';
import { makeSelectInsufficientCreditsForUri } from 'redux/selectors/content';
import { makeSelectClaimWasPurchased } from 'redux/selectors/claims';
import ClaimInsufficientCredits from './view';
const select = (state, props) => ({
isInsufficientCredits: selectInsufficientCreditsForUri(state, props.uri),
isInsufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
});
+4 -2
View File
@@ -1,8 +1,9 @@
import { connect } from 'react-redux';
import { makeSelectClaimForUri, selectIsUriResolving } from 'redux/selectors/claims';
import { makeSelectClaimForUri, makeSelectIsUriResolving } from 'redux/selectors/claims';
import { doResolveUri } from 'redux/actions/claims';
import { doSetPlayingUri } from 'redux/actions/content';
import { punctuationMarks } from 'util/remark-lbry';
import { selectBlackListedOutpoints } from 'lbryinc';
import { selectPlayingUri } from 'redux/selectors/content';
import ClaimLink from './view';
@@ -24,7 +25,8 @@ const select = (state, props) => {
uri,
claim,
fullUri: props.uri,
isResolvingUri: selectIsUriResolving(state, uri),
isResolvingUri: makeSelectIsUriResolving(uri)(state),
blackListedOutpoints: selectBlackListedOutpoints(state),
playingUri: selectPlayingUri(state),
};
};
+22 -2
View File
@@ -15,6 +15,10 @@ type Props = {
description: ?string,
isResolvingUri: boolean,
doResolveUri: (string) => void,
blackListedOutpoints: Array<{
txid: string,
nout: number,
}>,
playingUri: ?PlayingUri,
parentCommentId?: string,
isMarkdownPost?: boolean,
@@ -39,6 +43,21 @@ class ClaimLink extends React.Component<Props> {
this.resolve(this.props);
}
isClaimBlackListed() {
const { claim, blackListedOutpoints } = this.props;
const signingChannel = claim && claim.signing_channel;
if (claim && blackListedOutpoints) {
let blackListed = false;
blackListed = blackListedOutpoints.some(
(outpoint) =>
(signingChannel && outpoint.txid === signingChannel.txid && outpoint.nout === signingChannel.nout) ||
(outpoint.txid === claim.txid && outpoint.nout === claim.nout)
);
return blackListed;
}
}
resolve = (props: Props) => {
const { isResolvingUri, doResolveUri, claim, uri } = props;
@@ -60,13 +79,14 @@ class ClaimLink extends React.Component<Props> {
allowPreview,
} = this.props;
const isUnresolved = (!isResolvingUri && !claim) || !claim;
const isBlacklisted = this.isClaimBlackListed();
const isPlayingInline =
playingUri &&
playingUri.uri === uri &&
((playingUri.source === 'comment' && parentCommentId === playingUri.commentId) ||
playingUri.source === 'markdown');
if (isUnresolved) {
if (isBlacklisted || isUnresolved) {
return <span>{children}</span>;
}
@@ -92,7 +112,7 @@ class ClaimLink extends React.Component<Props> {
) : (
<Button
button="link"
title={SIMPLE_SITE ? __("This channel isn't staking enough Credits for link previews.") : children}
title={SIMPLE_SITE ? __("This channel isn't staking enough LBRY Credits for link previews.") : children}
label={children}
className="button--external-link"
navigate={uri}
+2 -2
View File
@@ -2,10 +2,10 @@ import { connect } from 'react-redux';
import ClaimList from './view';
import * as SETTINGS from 'constants/settings';
import { selectClientSetting } from 'redux/selectors/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
const select = (state) => ({
searchInLanguage: selectClientSetting(state, SETTINGS.SEARCH_IN_LANGUAGE),
searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state),
});
export default connect(select)(ClaimList);
+5 -5
View File
@@ -10,23 +10,23 @@ import * as SETTINGS from 'constants/settings';
import { selectFollowedTags } from 'redux/selectors/tags';
import { selectMutedChannels } from 'redux/selectors/blocked';
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { selectClientSetting, selectShowMatureContent, selectLanguage } from 'redux/selectors/settings';
import { makeSelectClientSetting, selectShowMatureContent, selectLanguage } from 'redux/selectors/settings';
import { selectModerationBlockList } from 'redux/selectors/comments';
import ClaimListDiscover from './view';
import { doFetchViewCount } from 'lbryinc';
const select = (state, props) => ({
const select = (state) => ({
followedTags: selectFollowedTags(state),
claimSearchByQuery: selectClaimSearchByQuery(state),
claimSearchByQueryLastPageReached: selectClaimSearchByQueryLastPageReached(state),
claimsByUri: selectClaimsByUri(state),
loading: props.loading !== undefined ? props.loading : selectFetchingClaimSearch(state),
loading: selectFetchingClaimSearch(state),
showNsfw: selectShowMatureContent(state),
hideReposts: selectClientSetting(state, SETTINGS.HIDE_REPOSTS),
hideReposts: makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state),
languageSetting: selectLanguage(state),
mutedUris: selectMutedChannels(state),
blockedUris: selectModerationBlockList(state),
searchInLanguage: selectClientSetting(state, SETTINGS.SEARCH_IN_LANGUAGE),
searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state),
});
const perform = {
-24
View File
@@ -21,7 +21,6 @@ import { useIsLargeScreen } from 'effects/use-screensize';
type Props = {
uris: Array<string>,
prefixUris?: Array<string>,
pins?: { urls: Array<string>, onlyPinForOrder?: string },
name?: string,
type: string,
pageSize?: number,
@@ -140,7 +139,6 @@ function ClaimListDiscover(props: Props) {
feeAmount,
uris,
prefixUris,
pins,
tileLayout,
hideFilters = false,
claimIds,
@@ -250,7 +248,6 @@ function ClaimListDiscover(props: Props) {
has_source?: boolean,
has_no_source?: boolean,
limit_claims_per_channel?: number,
remove_duplicates?: boolean,
} = {
page_size: dynamicPageSize,
page,
@@ -262,7 +259,6 @@ function ClaimListDiscover(props: Props) {
not_channel_ids: isChannel ? undefined : mutedAndBlockedChannelIds,
not_tags: !showNsfw ? MATURE_TAGS : [],
order_by: resolveOrderByOption(orderParam, sortByParam),
remove_duplicates: isChannel ? undefined : true,
};
if (ENABLE_NO_SOURCE_CLAIMS && hasNoSource) {
@@ -468,7 +464,6 @@ function ClaimListDiscover(props: Props) {
);
const renderUris = uris || claimSearchResult;
injectPinUrls(renderUris, orderParam, pins);
// **************************************************************************
// Helpers
@@ -530,25 +525,6 @@ function ClaimListDiscover(props: Props) {
return order_by;
}
function injectPinUrls(uris, order, pins) {
if (!pins || !pins.urls || (pins.onlyPinForOrder && pins.onlyPinForOrder !== order)) {
return;
}
const pinUrls = pins.urls;
if (pinUrls && uris && uris.length > 2) {
pinUrls.forEach((pin) => {
if (uris.includes(pin)) {
uris.splice(uris.indexOf(pin), 1);
} else {
uris.pop();
}
});
uris.splice(2, 0, ...pinUrls);
}
}
// **************************************************************************
// **************************************************************************
+2 -2
View File
@@ -2,7 +2,7 @@ import { connect } from 'react-redux';
import { selectFetchingClaimSearch } from 'redux/selectors/claims';
import { selectFollowedTags } from 'redux/selectors/tags';
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { selectClientSetting, selectShowMatureContent, selectLanguage } from 'redux/selectors/settings';
import { makeSelectClientSetting, selectShowMatureContent, selectLanguage } from 'redux/selectors/settings';
import { doSetClientSetting } from 'redux/actions/settings';
import * as SETTINGS from 'constants/settings';
import ClaimListHeader from './view';
@@ -11,7 +11,7 @@ const select = (state) => ({
followedTags: selectFollowedTags(state),
loading: selectFetchingClaimSearch(state),
showNsfw: selectShowMatureContent(state),
searchInLanguage: selectClientSetting(state, SETTINGS.SEARCH_IN_LANGUAGE),
searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state),
languageSetting: selectLanguage(state),
});
+6 -6
View File
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { selectClaimForUri, selectClaimIsMine } from 'redux/selectors/claims';
import { makeSelectClaimForUri, makeSelectClaimIsMine } from 'redux/selectors/claims';
import { doCollectionEdit, doFetchItemsInCollection } from 'redux/actions/collections';
import { doPrepareEdit } from 'redux/actions/publish';
import {
@@ -26,7 +26,7 @@ import {
} from 'redux/selectors/comments';
import { doToast } from 'redux/actions/notifications';
import { doChannelSubscribe, doChannelUnsubscribe } from 'redux/actions/subscriptions';
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectListShuffle } from 'redux/selectors/content';
import { doToggleLoopList, doToggleShuffleList } from 'redux/actions/content';
@@ -34,7 +34,7 @@ import ClaimPreview from './view';
import fs from 'fs';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri, false); // @KP test no repost!
const claim = makeSelectClaimForUri(props.uri, false)(state);
const collectionId = props.collectionId;
const repostedClaim = claim && claim.reposted_claim;
const contentClaim = repostedClaim || claim;
@@ -51,7 +51,7 @@ const select = (state, props) => {
contentClaim,
contentSigningChannel,
contentChannelUri,
claimIsMine: selectClaimIsMine(state, claim),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
hasClaimInWatchLater: makeSelectCollectionForIdHasClaimUrl(
COLLECTIONS_CONSTS.WATCH_LATER_ID,
contentPermanentUri
@@ -63,7 +63,7 @@ const select = (state, props) => {
channelIsMuted: makeSelectChannelIsMuted(contentChannelUri)(state),
channelIsBlocked: makeSelectChannelIsBlocked(contentChannelUri)(state),
fileInfo: makeSelectFileInfoForUri(contentPermanentUri)(state),
isSubscribed: selectIsSubscribedForUri(state, contentChannelUri),
isSubscribed: makeSelectIsSubscribed(contentChannelUri, true)(state),
channelIsAdminBlocked: makeSelectChannelIsAdminBlocked(props.uri)(state),
isAdmin: selectHasAdminChannel(state),
claimInCollection: makeSelectCollectionForIdHasClaimUrl(collectionId, contentPermanentUri)(state),
@@ -92,7 +92,7 @@ const perform = (dispatch) => ({
doChannelUnmute: (channelUri) => dispatch(doChannelUnmute(channelUri)),
doCommentModBlock: (channelUri) => dispatch(doCommentModBlock(channelUri)),
doCommentModUnBlock: (channelUri) => dispatch(doCommentModUnBlock(channelUri)),
doCommentModBlockAsAdmin: (a, b, c) => dispatch(doCommentModBlockAsAdmin(a, b, c)),
doCommentModBlockAsAdmin: (commenterUri, blockerId) => dispatch(doCommentModBlockAsAdmin(commenterUri, blockerId)),
doCommentModUnBlockAsAdmin: (commenterUri, blockerId) =>
dispatch(doCommentModUnBlockAsAdmin(commenterUri, blockerId)),
doChannelSubscribe: (subscription) => dispatch(doChannelSubscribe(subscription)),
+2 -2
View File
@@ -45,7 +45,7 @@ type Props = {
doChannelUnmute: (string) => void,
doCommentModBlock: (string) => void,
doCommentModUnBlock: (string) => void,
doCommentModBlockAsAdmin: (commenterUri: string, offendingCommentId: ?string, blockerId: ?string) => void,
doCommentModBlockAsAdmin: (string, string) => void,
doCommentModUnBlockAsAdmin: (string, string) => void,
doCollectionEdit: (string, any) => void,
hasClaimInWatchLater: boolean,
@@ -237,7 +237,7 @@ function ClaimMenuList(props: Props) {
if (channelIsAdminBlocked) {
doCommentModUnBlockAsAdmin(contentChannelUri, '');
} else {
doCommentModBlockAsAdmin(contentChannelUri, undefined, undefined);
doCommentModBlockAsAdmin(contentChannelUri, '');
}
}
+15 -16
View File
@@ -1,13 +1,14 @@
import { connect } from 'react-redux';
import {
selectClaimForUri,
selectIsUriResolving,
selectClaimIsMine,
makeSelectIsUriResolving,
makeSelectClaimIsMine,
makeSelectClaimIsPending,
makeSelectClaimIsNsfw,
makeSelectReflectingClaimForUri,
makeSelectClaimWasPurchased,
isStreamPlaceholderClaim,
selectTitleForUri,
makeSelectClaimIsStreamPlaceholder,
makeSelectTitleForUri,
selectDateForUri,
} from 'redux/selectors/claims';
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
@@ -21,11 +22,10 @@ import { doResolveUri } from 'redux/actions/claims';
import { doCollectionEdit } from 'redux/actions/collections';
import { doFileGet } from 'redux/actions/file';
import { selectBanStateForUri } from 'lbryinc';
import { selectIsActiveLivestreamForUri } from 'redux/selectors/livestream';
import { makeSelectIsActiveLivestream } from 'redux/selectors/livestream';
import { selectShowMatureContent } from 'redux/selectors/settings';
import { makeSelectHasVisitedUri } from 'redux/selectors/content';
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
import { isClaimNsfw } from 'util/claim';
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import ClaimPreview from './view';
import formatMediaDuration from 'util/formatMediaDuration';
@@ -33,27 +33,26 @@ const select = (state, props) => {
const claim = props.uri && selectClaimForUri(state, props.uri);
const media = claim && claim.value && (claim.value.video || claim.value.audio);
const mediaDuration = media && media.duration && formatMediaDuration(media.duration, { screenReader: true });
const isLivestream = isStreamPlaceholderClaim(claim);
return {
claim,
mediaDuration,
date: props.uri && selectDateForUri(state, props.uri),
title: props.uri && selectTitleForUri(state, props.uri),
title: props.uri && makeSelectTitleForUri(props.uri)(state),
pending: props.uri && makeSelectClaimIsPending(props.uri)(state),
reflectingProgress: props.uri && makeSelectReflectingClaimForUri(props.uri)(state),
obscureNsfw: selectShowMatureContent(state) === false,
claimIsMine: props.uri && selectClaimIsMine(state, claim),
isResolvingUri: props.uri && selectIsUriResolving(state, props.uri),
isResolvingRepost: props.uri && selectIsUriResolving(state, props.repostUrl),
nsfw: claim ? isClaimNsfw(claim) : false,
claimIsMine: props.uri && makeSelectClaimIsMine(props.uri)(state),
isResolvingUri: props.uri && makeSelectIsUriResolving(props.uri)(state),
isResolvingRepost: props.uri && makeSelectIsUriResolving(props.repostUrl)(state),
nsfw: props.uri && makeSelectClaimIsNsfw(props.uri)(state),
banState: selectBanStateForUri(state, props.uri),
hasVisitedUri: props.uri && makeSelectHasVisitedUri(props.uri)(state),
isSubscribed: props.uri && selectIsSubscribedForUri(state, props.uri),
isSubscribed: props.uri && makeSelectIsSubscribed(props.uri, true)(state),
streamingUrl: props.uri && makeSelectStreamingUrlForUri(props.uri)(state),
wasPurchased: props.uri && makeSelectClaimWasPurchased(props.uri)(state),
isLivestream,
isLivestreamActive: isLivestream && selectIsActiveLivestreamForUri(state, props.uri),
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
isLivestreamActive: makeSelectIsActiveLivestream(props.uri)(state),
isCollectionMine: makeSelectCollectionIsMine(props.collectionId)(state),
collectionUris: makeSelectUrlsForCollectionId(props.collectionId)(state),
collectionIndex: makeSelectIndexForUrlInCollection(props.uri, props.collectionId)(state),
+2 -9
View File
@@ -7,7 +7,6 @@ import { lazyImport } from 'util/lazyImport';
import classnames from 'classnames';
import { isURIValid } from 'util/lbryURI';
import * as COLLECTIONS_CONSTS from 'constants/collections';
import { isChannelClaim } from 'util/claim';
import { formatLbryUrlForWeb } from 'util/url';
import { formatClaimPreviewTitle } from 'util/formatAriaLabel';
import FileThumbnail from 'component/fileThumbnail';
@@ -25,7 +24,6 @@ import FileDownloadLink from 'component/fileDownloadLink';
import FileWatchLaterLink from 'component/fileWatchLaterLink';
import PublishPending from 'component/publishPending';
import ClaimMenuList from 'component/claimMenuList';
import ClaimPreviewReset from 'component/claimPreviewReset';
import ClaimPreviewLoading from './claim-preview-loading';
import ClaimPreviewHidden from './claim-preview-no-mature';
import ClaimPreviewNoContent from './claim-preview-no-content';
@@ -136,7 +134,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
renderActions,
hideMenu = false,
// repostUrl,
isLivestream,
isLivestream, // need both? CHECK
isLivestreamActive,
collectionId,
collectionIndex,
@@ -147,7 +145,6 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
indexInContainer,
channelSubCount,
} = props;
const isCollection = claim && claim.value_type === 'collection';
const collectionClaimId = isCollection && claim && claim.claim_id;
const listId = collectionId || collectionClaimId;
@@ -181,7 +178,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
claim.value.stream_type &&
// $FlowFixMe
(claim.value.stream_type === 'audio' || claim.value.stream_type === 'video');
const isChannelUri = isChannelClaim(claim, uri);
const isChannelUri = claim ? claim.value_type === 'channel' : false;
const signingChannel = claim && claim.signing_channel;
const repostedChannelUri =
claim && claim.repost_channel_url && claim.value_type === 'channel'
@@ -483,10 +480,6 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
)}
</div>
</div>
{/* Todo: check isLivestreamActive once we have that data consistently everywhere. */}
{claim && isLivestream && <ClaimPreviewReset uri={uri} />}
{!hideMenu && <ClaimMenuList uri={uri} collectionId={listId} />}
</>
</WrapperElement>
-20
View File
@@ -1,20 +0,0 @@
import { connect } from 'react-redux';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectClaimIsMineForUri } from 'redux/selectors/claims';
import { doToast } from 'redux/actions/notifications';
import ClaimPreviewReset from './view';
const select = (state, props) => {
const { claim_id: channelId, name: channelName } = selectActiveChannelClaim(state) || {};
return {
channelName,
channelId,
claimIsMine: props.uri && selectClaimIsMineForUri(state, props.uri),
};
};
const perform = (dispatch) => ({
doToast: (props) => dispatch(doToast(props)),
});
export default connect(select, perform)(ClaimPreviewReset);
-56
View File
@@ -1,56 +0,0 @@
// @flow
import React from 'react';
import { SITE_HELP_EMAIL } from 'config';
import Button from 'component/button';
import { killStream } from '$web/src/livestreaming';
import watchLivestreamStatus from '$web/src/livestreaming/long-polling';
import 'scss/component/claim-preview-reset.scss';
type Props = {
channelId: string,
channelName: string,
claimIsMine: boolean,
doToast: ({ message: string, isError?: boolean }) => void,
};
const ClaimPreviewReset = (props: Props) => {
const { channelId, channelName, claimIsMine, doToast } = props;
const [isLivestreaming, setIsLivestreaming] = React.useState(false);
React.useEffect(() => {
if (!claimIsMine) return;
return watchLivestreamStatus(channelId, (state) => setIsLivestreaming(state));
}, [channelId, setIsLivestreaming, claimIsMine]);
if (!claimIsMine || !isLivestreaming) return null;
const handleClick = async () => {
try {
await killStream(channelId, channelName);
doToast({ message: __('Live stream successfully reset.'), isError: false });
} catch {
doToast({ message: __('There was an error resetting the live stream.'), isError: true });
}
};
return (
<p className={'claimPreviewReset'}>
<span className={'claimPreviewReset__hint'}>
{__(
"If you're having trouble starting a stream or if your stream shows that you're live but aren't, try a reset. If the problem persists, please reach out at %SITE_HELP_EMAIL%.",
{ SITE_HELP_EMAIL }
)}
</span>
<Button
button="primary"
label={__('Reset stream')}
className={'claimPreviewReset__button'}
onClick={handleClick}
/>
</p>
);
};
export default ClaimPreviewReset;
+8 -4
View File
@@ -1,10 +1,14 @@
import * as PAGES from 'constants/pages';
import { connect } from 'react-redux';
import { selectClaimForUri, makeSelectClaimIsPending, isStreamPlaceholderClaim } from 'redux/selectors/claims';
import {
selectClaimForUri,
makeSelectClaimIsPending,
makeSelectClaimIsStreamPlaceholder,
} from 'redux/selectors/claims';
import { doClearPublish, doPrepareEdit } from 'redux/actions/publish';
import { push } from 'connected-react-router';
import ClaimPreviewSubtitle from './view';
import { doFetchSubCount, selectSubCountForUri } from 'lbryinc';
import { doFetchSubCount, makeSelectSubCountForUri } from 'lbryinc';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
@@ -13,8 +17,8 @@ const select = (state, props) => {
return {
claim,
pending: makeSelectClaimIsPending(props.uri)(state),
isLivestream: isStreamPlaceholderClaim(claim),
subCount: isChannel ? selectSubCountForUri(state, props.uri) : 0,
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
subCount: isChannel ? makeSelectSubCountForUri(props.uri)(state) : 0,
};
};
+16 -15
View File
@@ -1,18 +1,19 @@
import { connect } from 'react-redux';
import {
makeSelectClaimForUri,
selectIsUriResolving,
getThumbnailFromClaim,
selectTitleForUri,
isStreamPlaceholderClaim,
makeSelectIsUriResolving,
makeSelectThumbnailForUri,
makeSelectTitleForUri,
makeSelectChannelForClaimUri,
makeSelectClaimIsNsfw,
makeSelectClaimIsStreamPlaceholder,
selectDateForUri,
} from 'redux/selectors/claims';
import { doFileGet } from 'redux/actions/file';
import { doResolveUri } from 'redux/actions/claims';
import { selectViewCountForUri, selectBanStateForUri } from 'lbryinc';
import { selectIsActiveLivestreamForUri } from 'redux/selectors/livestream';
import { makeSelectViewCountForUri, selectBanStateForUri } from 'lbryinc';
import { makeSelectIsActiveLivestream } from 'redux/selectors/livestream';
import { selectShowMatureContent } from 'redux/selectors/settings';
import { isClaimNsfw } from 'util/claim';
import ClaimPreviewTile from './view';
import formatMediaDuration from 'util/formatMediaDuration';
@@ -20,21 +21,21 @@ const select = (state, props) => {
const claim = props.uri && makeSelectClaimForUri(props.uri)(state);
const media = claim && claim.value && (claim.value.video || claim.value.audio);
const mediaDuration = media && media.duration && formatMediaDuration(media.duration, { screenReader: true });
const isLivestream = isStreamPlaceholderClaim(claim);
return {
claim,
mediaDuration,
date: props.uri && selectDateForUri(state, props.uri),
isResolvingUri: props.uri && selectIsUriResolving(state, props.uri),
thumbnail: getThumbnailFromClaim(claim),
title: props.uri && selectTitleForUri(state, props.uri),
channel: props.uri && makeSelectChannelForClaimUri(props.uri)(state),
isResolvingUri: props.uri && makeSelectIsUriResolving(props.uri)(state),
thumbnail: props.uri && makeSelectThumbnailForUri(props.uri)(state),
title: props.uri && makeSelectTitleForUri(props.uri)(state),
banState: selectBanStateForUri(state, props.uri),
showMature: selectShowMatureContent(state),
isMature: claim ? isClaimNsfw(claim) : false,
isLivestream,
isLivestreamActive: isLivestream && selectIsActiveLivestreamForUri(state, props.uri),
viewCount: selectViewCountForUri(state, props.uri),
isMature: makeSelectClaimIsNsfw(props.uri)(state),
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
isLivestreamActive: makeSelectIsActiveLivestream(props.uri)(state),
viewCount: makeSelectViewCountForUri(props.uri)(state),
};
};
+2 -2
View File
@@ -1,10 +1,10 @@
import { connect } from 'react-redux';
import { makeSelectClaimForUri, selectTitleForUri } from 'redux/selectors/claims';
import { makeSelectClaimForUri, makeSelectTitleForUri } from 'redux/selectors/claims';
import ClaimPreviewTitle from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
title: selectTitleForUri(state, props.uri),
title: makeSelectTitleForUri(props.uri)(state),
});
export default connect(select)(ClaimPreviewTitle);
+7 -11
View File
@@ -1,16 +1,12 @@
import { connect } from 'react-redux';
import { selectClaimIsMine, selectClaimForUri } from 'redux/selectors/claims';
import { selectIsSubscribedForUri } from 'redux/selectors/subscriptions';
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'redux/selectors/claims';
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import ClaimProperties from './view';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
claim,
isSubscribed: selectIsSubscribedForUri(state, props.uri),
claimIsMine: selectClaimIsMine(state, claim),
};
};
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
isSubscribed: makeSelectIsSubscribed(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
});
export default connect(select, null)(ClaimProperties);
+2 -3
View File
@@ -6,7 +6,7 @@ import * as SETTINGS from 'constants/settings';
import { MATURE_TAGS } from 'constants/tags';
import { doFetchViewCount } from 'lbryinc';
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { selectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
import { selectMutedAndBlockedChannelIds } from 'redux/selectors/blocked';
import { ENABLE_NO_SOURCE_CLAIMS, SIMPLE_SITE } from 'config';
import * as CS from 'constants/claim_search';
@@ -15,7 +15,7 @@ import ClaimListDiscover from './view';
const select = (state, props) => {
const showNsfw = selectShowMatureContent(state);
const hideReposts = selectClientSetting(state, SETTINGS.HIDE_REPOSTS);
const hideReposts = makeSelectClientSetting(SETTINGS.HIDE_REPOSTS)(state);
const mutedAndBlockedChannelIds = selectMutedAndBlockedChannelIds(state);
return {
@@ -85,7 +85,6 @@ function resolveSearchOptions(props) {
not_channel_ids: mutedAndBlockedChannelIds,
order_by: orderBy || ['trending_group', 'trending_mixed'],
stream_types: streamTypesParam,
remove_duplicates: true,
};
if (ENABLE_NO_SOURCE_CLAIMS && hasNoSource) {
+2 -2
View File
@@ -1,10 +1,10 @@
import { connect } from 'react-redux';
import { makeSelectClaimForUri, selectIsStreamPlaceholderForUri } from 'redux/selectors/claims';
import { makeSelectClaimForUri, makeSelectClaimIsStreamPlaceholder } from 'redux/selectors/claims';
import FileType from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
isLivestream: selectIsStreamPlaceholderForUri(state, props.uri),
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
});
export default connect(select)(FileType);
+2 -2
View File
@@ -1,10 +1,10 @@
import { connect } from 'react-redux';
import { selectCanonicalUrlForUri } from 'redux/selectors/claims';
import { makeSelectCanonicalUrlForUri } from 'redux/selectors/claims';
import { doToast } from 'redux/actions/notifications';
import ClaimUri from './view';
const select = (state, props) => ({
shortUrl: selectCanonicalUrlForUri(state, props.uri),
shortUrl: makeSelectCanonicalUrlForUri(props.uri)(state),
});
export default connect(select, {
@@ -1,6 +1,6 @@
import { connect } from 'react-redux';
import CollectionContent from './view';
import { selectClaimForUri, selectClaimIsMine } from 'redux/selectors/claims';
import { makeSelectClaimForUri, makeSelectClaimIsMine } from 'redux/selectors/claims';
import {
makeSelectUrlsForCollectionId,
makeSelectNameForCollectionId,
@@ -12,7 +12,7 @@ import { doToggleLoopList, doToggleShuffleList } from 'redux/actions/content';
const select = (state, props) => {
const playingUri = selectPlayingUri(state);
const playingUrl = playingUri && playingUri.uri;
const claim = selectClaimForUri(state, playingUrl);
const claim = makeSelectClaimForUri(playingUrl)(state);
const url = claim && claim.permanent_url;
const loopList = selectListLoop(state);
const loop = loopList && loopList.collectionId === props.id && loopList.loop;
@@ -24,7 +24,7 @@ const select = (state, props) => {
collection: makeSelectCollectionForId(props.id)(state),
collectionUrls: makeSelectUrlsForCollectionId(props.id)(state),
collectionName: makeSelectNameForCollectionId(props.id)(state),
isMine: selectClaimIsMine(state, claim),
isMine: makeSelectClaimIsMine(url)(state),
loop,
shuffle,
};
+4 -4
View File
@@ -1,7 +1,7 @@
import { connect } from 'react-redux';
import {
selectTitleForUri,
selectThumbnailForUri,
makeSelectTitleForUri,
makeSelectThumbnailForUri,
makeSelectMetadataItemForUri,
makeSelectAmountForUri,
makeSelectClaimForUri,
@@ -25,8 +25,8 @@ import { doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
title: selectTitleForUri(state, props.uri),
thumbnailUrl: selectThumbnailForUri(state, props.uri),
title: makeSelectTitleForUri(props.uri)(state),
thumbnailUrl: makeSelectThumbnailForUri(props.uri)(state),
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
tags: makeSelectMetadataItemForUri(props.uri, 'tags')(state),
locations: makeSelectMetadataItemForUri(props.uri, 'locations')(state),
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { selectIsUriResolving, selectClaimIdForUri, makeSelectClaimForClaimId } from 'redux/selectors/claims';
import { makeSelectIsUriResolving, makeSelectClaimIdForUri, makeSelectClaimForClaimId } from 'redux/selectors/claims';
import {
makeSelectUrlsForCollectionId,
makeSelectNameForCollectionId,
@@ -10,7 +10,7 @@ import { doFetchItemsInCollection } from 'redux/actions/collections';
import CollectionPreviewOverlay from './view';
const select = (state, props) => {
const collectionId = props.collectionId || (props.uri && selectClaimIdForUri(state, props.uri));
const collectionId = props.collectionId || (props.uri && makeSelectClaimIdForUri(props.uri));
const claim = props.collectionId && makeSelectClaimForClaimId(props.collectionId)(state);
const collectionUri = props.uri || (claim && (claim.canonical_url || claim.permanent_url)) || null;
@@ -22,7 +22,7 @@ const select = (state, props) => {
collectionItemUrls: makeSelectUrlsForCollectionId(collectionId)(state), // ForId || ForUri
pendingCollection: makeSelectPendingCollectionForId(collectionId)(state),
claim,
isResolvingUri: collectionUri && selectIsUriResolving(state, collectionUri),
isResolvingUri: collectionUri && makeSelectIsUriResolving(collectionUri)(state),
};
};
+10 -10
View File
@@ -1,11 +1,11 @@
import { connect } from 'react-redux';
import {
selectIsUriResolving,
getThumbnailFromClaim,
selectTitleForUri,
makeSelectIsUriResolving,
makeSelectThumbnailForUri,
makeSelectTitleForUri,
makeSelectChannelForClaimUri,
selectClaimIsNsfwForUri,
selectClaimIdForUri,
makeSelectClaimIsNsfw,
makeSelectClaimIdForUri,
makeSelectClaimForClaimId,
} from 'redux/selectors/claims';
import {
@@ -24,7 +24,7 @@ import { selectShowMatureContent } from 'redux/selectors/settings';
import CollectionPreviewTile from './view';
const select = (state, props) => {
const collectionId = props.collectionId || (props.uri && selectClaimIdForUri(state, props.uri));
const collectionId = props.collectionId || (props.uri && makeSelectClaimIdForUri(props.uri));
const claim = props.collectionId && makeSelectClaimForClaimId(props.collectionId)(state);
const collectionUri = props.uri || (claim && (claim.canonical_url || claim.permanent_url)) || null;
@@ -39,14 +39,14 @@ const select = (state, props) => {
claim,
isResolvingCollectionClaims: makeSelectIsResolvingCollectionForId(collectionId)(state),
channelClaim: collectionUri && makeSelectChannelForClaimUri(collectionUri)(state),
isResolvingUri: collectionUri && selectIsUriResolving(state, collectionUri),
thumbnail: getThumbnailFromClaim(claim),
title: collectionUri && selectTitleForUri(state, collectionUri),
isResolvingUri: collectionUri && makeSelectIsUriResolving(collectionUri)(state),
thumbnail: collectionUri && makeSelectThumbnailForUri(collectionUri)(state),
title: collectionUri && makeSelectTitleForUri(collectionUri)(state),
blackListedOutpoints: selectBlackListedOutpoints(state),
filteredOutpoints: selectFilteredOutpoints(state),
blockedChannelUris: selectMutedChannels(state),
showMature: selectShowMatureContent(state),
isMature: selectClaimIsNsfwForUri(state, collectionUri),
isMature: makeSelectClaimIsNsfw(collectionUri)(state),
};
};
+28 -62
View File
@@ -25,7 +25,7 @@ const ALL = 'All';
const PRIVATE = 'Private';
const PUBLIC = 'Public';
const COLLECTION_FILTERS = [ALL, PRIVATE, PUBLIC];
const COLLECTION_SHOW_COUNT = 12;
const COLLECTION_SHOW_COUNT = 24;
export default function CollectionsListMine(props: Props) {
const {
@@ -43,7 +43,6 @@ export default function CollectionsListMine(props: Props) {
const [filterType, setFilterType] = React.useState(ALL);
const [searchText, setSearchText] = React.useState('');
const playlistPageUrl = `/$/${PAGES.PLAYLISTS}?type=${filterType}`;
let collectionsToShow = [];
if (filterType === ALL) {
collectionsToShow = unpublishedCollectionsList.concat(publishedList);
@@ -69,10 +68,6 @@ export default function CollectionsListMine(props: Props) {
filteredCollections = collectionsToShow.slice(0, COLLECTION_SHOW_COUNT) || [];
}
const totalLength = collectionsToShow ? collectionsToShow.length : 0;
const filteredLength = filteredCollections.length;
const isTruncated = totalLength > filteredLength;
const watchLater = builtinCollectionsList.find((list) => list.id === COLLECTIONS_CONSTS.WATCH_LATER_ID);
const favorites = builtinCollectionsList.find((list) => list.id === COLLECTIONS_CONSTS.FAVORITES_ID);
const builtin = [watchLater, favorites];
@@ -138,19 +133,7 @@ export default function CollectionsListMine(props: Props) {
<div className="claim-grid__wrapper">
<div className="claim-grid__header section">
<h1 className="claim-grid__title">
<Button
className="claim-grid__title"
button="link"
navigate={playlistPageUrl}
label={
<span className="claim-grid__title-span">
{__('Playlists')}
<div className="claim-grid__title--empty">
<Icon className="icon--margin-right" icon={ICONS.STACK} />
</div>
</span>
}
/>
{__('Playlists')}
{!hasCollections && !fetchingCollections && (
<div className="claim-grid__title--empty">{__('(Empty) --[indicates empty playlist]--')}</div>
)}
@@ -159,55 +142,38 @@ export default function CollectionsListMine(props: Props) {
)}
</h1>
</div>
<div className="section__header-action-stack">
<div className="section__header--actions">
<div className="claim-search__wrapper">
<div className="claim-search__menu-group">
{COLLECTION_FILTERS.map((value) => (
<Button
label={__(value)}
key={value}
button="alt"
onClick={() => setFilterType(value)}
className={classnames('button-toggle', {
'button-toggle--active': filterType === value,
})}
/>
))}
</div>
<div className="section__header--actions">
<div className="claim-search__wrapper">
<div className="claim-search__menu-group">
{COLLECTION_FILTERS.map((value) => (
<Button
label={__(value)}
key={value}
button="alt"
onClick={() => setFilterType(value)}
className={classnames('button-toggle', {
'button-toggle--active': filterType === value,
})}
/>
))}
</div>
<Form onSubmit={() => {}} className="wunderbar--inline">
<Icon icon={ICONS.SEARCH} />
<FormField
onFocus={onTextareaFocus}
onBlur={onTextareaBlur}
className="wunderbar__input--inline"
value={searchText}
onChange={(e) => setSearchText(e.target.value)}
type="text"
placeholder={__('Search')}
/>
</Form>
</div>
<p className="collection-grid__results-summary">
{isTruncated && (
<>
{__(`Showing %filtered% results of %total%`, {
filtered: filteredLength,
total: totalLength,
})}
{`${searchText ? ' (' + __('filtered') + ') ' : ' '}`}
</>
)}
<Button
button="link"
navigate={playlistPageUrl}
label={<span className="claim-grid__title-span">{__('View All Playlists')}</span>}
<Form onSubmit={() => {}} className="wunderbar--inline">
<Icon icon={ICONS.SEARCH} />
<FormField
onFocus={onTextareaFocus}
onBlur={onTextareaBlur}
className="wunderbar__input--inline"
value={searchText}
onChange={(e) => setSearchText(e.target.value)}
type="text"
placeholder={__('Search')}
/>
</p>
</Form>
</div>
{Boolean(hasCollections) && (
<div>
{/* TODO: fix above spacing hack */}
<div className="claim-grid">
{filteredCollections &&
filteredCollections.length > 0 &&
+25 -24
View File
@@ -1,50 +1,51 @@
import { connect } from 'react-redux';
import {
selectStakedLevelForChannelUri,
makeSelectStakedLevelForChannelUri,
makeSelectClaimForUri,
selectThumbnailForUri,
selectHasChannels,
makeSelectThumbnailForUri,
selectMyChannelClaims,
} from 'redux/selectors/claims';
import { doCommentUpdate, doCommentList } from 'redux/actions/comments';
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
import { doToast } from 'redux/actions/notifications';
import { doSetPlayingUri } from 'redux/actions/content';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import {
selectLinkedCommentAncestors,
selectOthersReactsForComment,
makeSelectTotalReplyPagesForParentId,
} from 'redux/selectors/comments';
import { doCommentUpdate, doCommentList } from 'redux/actions/comments';
import { doSetPlayingUri } from 'redux/actions/content';
import { doToast } from 'redux/actions/notifications';
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectPlayingUri } from 'redux/selectors/content';
import Comment from './view';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import CommentView from './view';
const select = (state, props) => {
const { channel_url: authorUri, comment_id: commentId } = props.comment;
const activeChannelClaim = selectActiveChannelClaim(state);
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
const reactionKey = activeChannelId ? `${props.commentId}:${activeChannelId}` : props.commentId;
const reactionKey = activeChannelId ? `${commentId}:${activeChannelId}` : commentId;
return {
channelIsBlocked: authorUri && makeSelectChannelIsMuted(authorUri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
thumbnail: props.authorUri && selectThumbnailForUri(state, props.authorUri),
channelIsBlocked: props.authorUri && makeSelectChannelIsMuted(props.authorUri)(state),
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
othersReacts: selectOthersReactsForComment(state, reactionKey),
activeChannelClaim,
hasChannels: selectHasChannels(state),
playingUri: selectPlayingUri(state),
stakedLevel: selectStakedLevelForChannelUri(state, props.authorUri),
linkedCommentAncestors: selectLinkedCommentAncestors(state),
totalReplyPages: makeSelectTotalReplyPagesForParentId(props.commentId)(state),
myChannels: selectMyChannelClaims(state),
othersReacts: selectOthersReactsForComment(state, reactionKey),
playingUri: selectPlayingUri(state),
stakedLevel: makeSelectStakedLevelForChannelUri(authorUri)(state),
thumbnail: authorUri && makeSelectThumbnailForUri(authorUri)(state),
totalReplyPages: makeSelectTotalReplyPagesForParentId(commentId)(state),
userCanComment: selectUserVerifiedEmail(state),
};
};
const perform = (dispatch) => ({
const perform = (dispatch, ownProps) => ({
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
updateComment: (commentId, comment) => dispatch(doCommentUpdate(commentId, comment)),
fetchReplies: (uri, parentId, page, pageSize, sortBy) =>
dispatch(doCommentList(uri, parentId, page, pageSize, sortBy)),
updateComment: (editedComment) => dispatch(doCommentUpdate(ownProps.comment.comment_id, editedComment)),
fetchReplies: (page, pageSize, sortBy) =>
dispatch(doCommentList(ownProps.uri, ownProps.comment.comment_id, page, pageSize, sortBy)),
doToast: (options) => dispatch(doToast(options)),
});
export default connect(select, perform)(Comment);
export default connect(select, perform)(CommentView);
+180 -275
View File
@@ -1,121 +1,100 @@
// @flow
import * as ICONS from 'constants/icons';
import * as PAGES from 'constants/pages';
import * as KEYCODES from 'constants/keycodes';
import { COMMENT_HIGHLIGHTED } from 'constants/classnames';
import { SORT_BY, COMMENT_PAGE_SIZE_REPLIES } from 'constants/comment';
import { FF_MAX_CHARS_IN_COMMENT } from 'constants/form-field';
import { SITE_NAME, SIMPLE_SITE, ENABLE_COMMENT_REACTIONS } from 'config';
import React, { useEffect, useState } from 'react';
import { parseURI } from 'util/lbryURI';
import DateTime from 'component/dateTime';
import Button from 'component/button';
import Expandable from 'component/expandable';
import MarkdownPreview from 'component/common/markdown-preview';
import Tooltip from 'component/common/tooltip';
import ChannelThumbnail from 'component/channelThumbnail';
import 'scss/component/_comments.scss';
import { ENABLE_COMMENT_REACTIONS } from 'config';
import { Menu, MenuButton } from '@reach/menu-button';
import Icon from 'component/common/icon';
import { FormField, Form } from 'component/common/form';
import classnames from 'classnames';
import usePersistedState from 'effects/use-persisted-state';
import CommentReactions from 'component/commentReactions';
import CommentsReplies from 'component/commentsReplies';
import { parseSticker } from 'util/comments';
import { parseURI } from 'util/lbryURI';
import { SORT_BY, COMMENT_PAGE_SIZE_REPLIES } from 'constants/comment';
import { useHistory } from 'react-router';
import * as ICONS from 'constants/icons';
import Button from 'component/button';
import ChannelThumbnail from 'component/channelThumbnail';
import classnames from 'classnames';
import CommentCreate from 'component/commentCreate';
import CommentMenuList from 'component/commentMenuList';
import UriIndicator from 'component/uriIndicator';
import CommentReactions from 'component/commentReactions';
import CommentsReplies from 'component/commentsReplies';
import CreditAmount from 'component/common/credit-amount';
import DateTime from 'component/dateTime';
import Expandable from 'component/expandable';
import Icon from 'component/common/icon';
import MarkdownPreview from 'component/common/markdown-preview';
import OptimizedImage from 'component/optimizedImage';
import { getChannelFromClaim } from 'util/claim';
import { parseSticker } from 'util/comments';
import React, { useEffect, useState } from 'react';
import Tooltip from 'component/common/tooltip';
import UriIndicator from 'component/uriIndicator';
const AUTO_EXPAND_ALL_REPLIES = false;
type Props = {
clearPlayingUri: () => void,
uri: string,
claim: StreamClaim,
author: ?string, // LBRY Channel Name, e.g. @channel
authorUri: string, // full LBRY Channel URI: lbry://@channel#123...
commentId: string, // sha256 digest identifying the comment
message: string, // comment body
timePosted: number, // Comment timestamp
channelIsBlocked: boolean, // if the channel is blacklisted in the app
claimIsMine: boolean, // if you control the claim which this comment was posted on
commentIsMine: boolean, // if this comment was signed by an owned channel
updateComment: (string, string) => void,
fetchReplies: (string, string, number, number, number) => void,
totalReplyPages: number,
commentModBlock: (string) => void,
linkedCommentId?: string,
linkedCommentAncestors: { [string]: Array<string> },
hasChannels: boolean,
commentingEnabled: boolean,
doToast: ({ message: string }) => void,
isTopLevel?: boolean,
threadDepth: number,
hideActions?: boolean,
isPinned: boolean,
othersReacts: ?{
like: number,
dislike: number,
},
commentIdentityChannel: any,
activeChannelClaim: ?ChannelClaim,
playingUri: ?PlayingUri,
stakedLevel: number,
supportAmount: number,
numDirectReplies: number,
isModerator: boolean,
isGlobalMod: boolean,
isFiat: boolean,
supportDisabled: boolean,
setQuickReply: (any) => void,
quickReply: any,
};
const LENGTH_TO_COLLAPSE = 300;
function Comment(props: Props) {
type Props = {
channelIsBlocked: boolean, // if the channel is blacklisted in the app
claim: StreamClaim,
claimIsMine: boolean, // if you control the claim which this comment was posted on
comment: Comment,
commentIdentityChannel: any,
hideActions?: boolean,
isTopLevel?: boolean,
linkedCommentAncestors: { [string]: Array<string> },
linkedCommentId?: string,
myChannels: ?Array<ChannelClaim>,
othersReacts: ?{ like: number, dislike: number },
playingUri: ?PlayingUri,
quickReply: any,
stakedLevel: number,
supportDisabled: boolean,
threadDepth: number,
totalReplyPages: number,
uri: string,
userCanComment: boolean,
clearPlayingUri: () => void,
commentModBlock: (string) => void,
fetchReplies: (number, number, string) => void,
setQuickReply: (any) => void,
updateComment: (string) => void,
};
function CommentView(props: Props) {
const {
clearPlayingUri,
claim,
uri,
author,
authorUri,
timePosted,
message,
channelIsBlocked,
commentIsMine,
commentId,
updateComment,
fetchReplies,
totalReplyPages,
linkedCommentId,
linkedCommentAncestors,
commentingEnabled,
hasChannels,
doToast,
isTopLevel,
threadDepth,
claim,
comment,
hideActions,
isPinned,
isTopLevel,
linkedCommentAncestors,
linkedCommentId,
myChannels,
othersReacts,
playingUri,
stakedLevel,
supportAmount,
numDirectReplies,
isModerator,
isGlobalMod,
isFiat,
supportDisabled,
setQuickReply,
quickReply,
stakedLevel,
supportDisabled,
threadDepth,
totalReplyPages,
uri,
userCanComment,
clearPlayingUri,
fetchReplies,
setQuickReply,
updateComment,
} = props;
const {
push,
channel_id: authorId,
channel_url: authorUri,
comment_id: commentId,
comment: message,
is_fiat: isFiat,
is_global_mod: isGlobalMod,
is_moderator: isModerator,
is_pinned: isPinned,
replies: numDirectReplies,
support_amount: supportAmount,
} = comment;
const timePosted = comment.timestamp * 1000;
const commentIsMine = authorId && myChannels && myChannels.some(({ claim_id }) => claim_id === authorId);
const {
replace,
location: { pathname, search },
} = useHistory();
@@ -130,79 +109,22 @@ function Comment(props: Props) {
const [isReplying, setReplying] = React.useState(false);
const [isEditing, setEditing] = useState(false);
const [editedMessage, setCommentValue] = useState(message);
const [charCount, setCharCount] = useState(editedMessage.length);
const [showReplies, setShowReplies] = useState(showRepliesOnMount);
const [page, setPage] = useState(showRepliesOnMount ? 1 : 0);
const [advancedEditor] = usePersistedState('comment-editor-mode', false);
const [displayDeadComment, setDisplayDeadComment] = React.useState(false);
const likesCount = (othersReacts && othersReacts.like) || 0;
const dislikesCount = (othersReacts && othersReacts.dislike) || 0;
const totalLikesAndDislikes = likesCount + dislikesCount;
const slimedToDeath = totalLikesAndDislikes >= 5 && dislikesCount / totalLikesAndDislikes > 0.8;
const contentChannelClaim = getChannelFromClaim(claim);
const commentByOwnerOfContent = contentChannelClaim && contentChannelClaim.permanent_url === authorUri;
const commentByContentOwner = claim && claim.signing_channel && claim.signing_channel.permanent_url === authorUri;
const stickerFromMessage = parseSticker(message);
let channelOwnerOfContent;
let contentOwnerChannel;
try {
const { channelName } = parseURI(uri);
if (channelName) {
channelOwnerOfContent = channelName;
}
({ channelName: contentOwnerChannel } = parseURI(uri));
} catch (e) {}
useEffect(() => {
if (isEditing) {
setCharCount(editedMessage.length);
// a user will try and press the escape key to cancel editing their comment
const handleEscape = (event) => {
if (event.keyCode === KEYCODES.ESCAPE) {
setEditing(false);
}
};
window.addEventListener('keydown', handleEscape);
// removes the listener so it doesn't cause problems elsewhere in the app
return () => {
window.removeEventListener('keydown', handleEscape);
};
}
}, [author, authorUri, editedMessage, isEditing, setEditing]);
useEffect(() => {
if (page > 0) {
fetchReplies(uri, commentId, page, COMMENT_PAGE_SIZE_REPLIES, SORT_BY.OLDEST);
}
}, [page, uri, commentId, fetchReplies]);
function handleEditMessageChanged(event) {
setCommentValue(!SIMPLE_SITE && advancedEditor ? event : event.target.value);
}
function handleEditComment() {
if (playingUri && playingUri.source === 'comment') {
clearPlayingUri();
}
setEditing(true);
}
function handleSubmit() {
updateComment(commentId, editedMessage);
if (setQuickReply) setQuickReply({ ...quickReply, comment_id: commentId, comment: editedMessage });
setEditing(false);
}
function handleCommentReply() {
if (!hasChannels) {
push(`/$/${PAGES.CHANNEL_NEW}?redirect=${pathname}`);
doToast({ message: __('A channel is required to comment on %SITE_NAME%', { SITE_NAME }) });
} else {
setReplying(!isReplying);
}
}
function handleTimeClick() {
const urlParams = new URLSearchParams(search);
urlParams.delete('lc');
@@ -222,10 +144,27 @@ function Comment(props: Props) {
}
}, []);
useEffect(() => {
if (page > 0) fetchReplies(page, COMMENT_PAGE_SIZE_REPLIES, SORT_BY.OLDEST);
}, [commentId, fetchReplies, page, uri]);
const commentBadge = (label: string, className: string, icon: string) => (
<Tooltip label={label}>
<span className={`comment__badge ${className}`}>
<Icon icon={icon} size={20} />
</span>
</Tooltip>
);
const MarkdownWrapper =
editedMessage.length >= LENGTH_TO_COLLAPSE
? ({ children }) => <Expandable>{children}</Expandable>
: ({ children }) => children;
return (
<li
className={classnames('comment', {
'comment--top-level': isTopLevel,
'comment--topLevel': isTopLevel,
'comment--reply': !isTopLevel,
'comment--superchat': supportAmount > 0,
})}
@@ -234,48 +173,25 @@ function Comment(props: Props) {
<div
ref={isLinkedComment ? linkedCommentRef : undefined}
className={classnames('comment__content', {
[COMMENT_HIGHLIGHTED]: isLinkedComment,
'comment--slimed': slimedToDeath && !displayDeadComment,
'comment__content--highlighted': isLinkedComment,
'comment__content--slimed': slimedToDeath && !displayDeadComment,
})}
>
<div className="comment__thumbnail-wrapper">
{authorUri ? (
<ChannelThumbnail uri={authorUri} obscure={channelIsBlocked} xsmall className="comment__author-thumbnail" />
) : (
<ChannelThumbnail xsmall className="comment__author-thumbnail" />
)}
<div className="commentThumbnail__wrapper">
<ChannelThumbnail uri={authorUri} obscure={channelIsBlocked} xsmall className="commentAuthor__thumbnail" />
</div>
<div className="comment__body-container">
<div className="commentBody__container">
<div className="comment__meta">
<div className="comment__meta-information">
{isGlobalMod && (
<Tooltip label={__('Admin')}>
<span className="comment__badge comment__badge--global-mod">
<Icon icon={ICONS.BADGE_MOD} size={20} />
</span>
</Tooltip>
)}
<div className="commentMeta__information">
{isModerator && commentBadge(__('Moderator'), 'commentBadge__mod', ICONS.BADGE_MOD)}
{isGlobalMod && commentBadge(__('Admin'), 'commentBadge__globalMod', ICONS.BADGE_MOD)}
{isModerator && (
<Tooltip label={__('Moderator')}>
<span className="comment__badge comment__badge--mod">
<Icon icon={ICONS.BADGE_MOD} size={20} />
</span>
</Tooltip>
)}
{!author ? (
<span className="comment__author">{__('Anonymous')}</span>
) : (
<UriIndicator
className={classnames('comment__author', {
'comment__author--creator': commentByOwnerOfContent,
})}
link
uri={authorUri}
/>
)}
<UriIndicator
uri={authorUri}
className={classnames('comment__author', { 'comment__author--creator': commentByContentOwner })}
link
/>
<Button
className="comment__time"
onClick={handleTimeClick}
@@ -287,8 +203,8 @@ function Comment(props: Props) {
{isPinned && (
<span className="comment__pin">
<Icon icon={ICONS.PIN} size={14} />
{channelOwnerOfContent
? __('Pinned by @%channel%', { channel: channelOwnerOfContent })
{contentOwnerChannel
? __('Pinned by @%channel%', { channel: contentOwnerChannel })
: __('Pinned by creator')}
</span>
)}
@@ -305,63 +221,57 @@ function Comment(props: Props) {
commentId={commentId}
authorUri={authorUri}
commentIsMine={commentIsMine}
handleEditComment={handleEditComment}
handleEditComment={() => {
if (playingUri && playingUri.source === 'comment') clearPlayingUri();
setEditing(true);
}}
supportAmount={supportAmount}
setQuickReply={setQuickReply}
disableEdit={Boolean(stickerFromMessage)}
/>
</Menu>
</div>
</div>
<div>
<div className="comment__body">
{isEditing ? (
<Form onSubmit={handleSubmit}>
<FormField
className="comment__edit-input"
type={!SIMPLE_SITE && advancedEditor ? 'markdown' : 'textarea'}
name="editing_comment"
value={editedMessage}
charCount={charCount}
onChange={handleEditMessageChanged}
textAreaMaxLength={FF_MAX_CHARS_IN_COMMENT}
/>
<div className="section__actions section__actions--no-margin">
<Button
button="primary"
type="submit"
label={__('Done')}
requiresAuth={IS_WEB}
disabled={message === editedMessage}
/>
<Button button="link" label={__('Cancel')} onClick={() => setEditing(false)} />
</div>
</Form>
<CommentCreate
isEdit
editedMessage={message}
onDoneEditing={(editedMessage) => {
if (editedMessage) {
updateComment(editedMessage);
if (setQuickReply) setQuickReply({ ...quickReply, comment_id: commentId, comment: editedMessage });
setCommentValue(editedMessage);
}
setEditing(false);
}}
supportDisabled
/>
) : (
<>
<div className="comment__message">
<div
className={classnames('comment__message', {
'comment__message--dead': slimedToDeath && !displayDeadComment,
'comment__message--sticker': stickerFromMessage,
})}
onClick={() => slimedToDeath && setDisplayDeadComment(true)}
>
{slimedToDeath && !displayDeadComment ? (
<div onClick={() => setDisplayDeadComment(true)} className="comment__dead">
{__('This comment was slimed to death.')} <Icon icon={ICONS.SLIME_ACTIVE} />
</div>
<>
{__('This comment was slimed to death.')}
<Icon icon={ICONS.SLIME_ACTIVE} />
</>
) : stickerFromMessage ? (
<div className="sticker__comment">
<OptimizedImage src={stickerFromMessage.url} waitLoad loading="lazy" />
</div>
) : editedMessage.length >= LENGTH_TO_COLLAPSE ? (
<Expandable>
<OptimizedImage src={stickerFromMessage.url} waitLoad />
) : (
<MarkdownWrapper>
<MarkdownPreview
content={message}
promptLinks
parentCommentId={commentId}
stakedLevel={stakedLevel}
promptLinks
/>
</Expandable>
) : (
<MarkdownPreview
content={message}
promptLinks
parentCommentId={commentId}
stakedLevel={stakedLevel}
/>
</MarkdownWrapper>
)}
</div>
@@ -369,10 +279,10 @@ function Comment(props: Props) {
<div className="comment__actions">
{threadDepth !== 0 && (
<Button
requiresAuth={IS_WEB}
label={commentingEnabled ? __('Reply') : __('Log in to reply')}
requiresAuth
label={userCanComment ? __('Reply') : __('Log in to reply')}
className="comment__action"
onClick={handleCommentReply}
onClick={() => setReplying(!isReplying)}
icon={ICONS.REPLY}
/>
)}
@@ -380,36 +290,33 @@ function Comment(props: Props) {
</div>
)}
{numDirectReplies > 0 && !showReplies && (
<div className="comment__actions">
<Button
label={
numDirectReplies < 2
? __('Show reply')
: __('Show %count% replies', { count: numDirectReplies })
}
button="link"
onClick={() => {
setShowReplies(true);
if (page === 0) {
setPage(1);
{numDirectReplies > 0 &&
(!showReplies ? (
<div className="comment__actions">
<Button
label={
numDirectReplies < 2
? __('Show reply')
: __('Show %count% replies', { count: numDirectReplies })
}
}}
icon={ICONS.DOWN}
/>
</div>
)}
{numDirectReplies > 0 && showReplies && (
<div className="comment__actions">
<Button
label={__('Hide replies')}
button="link"
onClick={() => setShowReplies(false)}
icon={ICONS.UP}
/>
</div>
)}
button="link"
onClick={() => {
setShowReplies(true);
if (page === 0) setPage(1);
}}
icon={ICONS.DOWN}
/>
</div>
) : (
<div className="comment__actions">
<Button
label={__('Hide replies')}
button="link"
onClick={() => setShowReplies(false)}
icon={ICONS.UP}
/>
</div>
))}
{isReplying && (
<CommentCreate
@@ -420,9 +327,7 @@ function Comment(props: Props) {
setShowReplies(true);
setReplying(false);
}}
onCancelReplying={() => {
setReplying(false);
}}
onCancelReplying={() => setReplying(false)}
supportDisabled={supportDisabled}
/>
)}
@@ -447,4 +352,4 @@ function Comment(props: Props) {
);
}
export default Comment;
export default CommentView;
@@ -1,6 +1,6 @@
// @flow
import 'scss/component/_emote-selector.scss';
import { EMOTES_48px as EMOTES } from 'constants/emotes';
import { EMOTES_24px as EMOTES } from 'constants/emotes';
import * as ICONS from 'constants/icons';
import Button from 'component/button';
import EMOJIS from 'emoji-dictionary';
@@ -32,6 +32,8 @@ export default function EmoteSelector(props: Props) {
<div className="emoteSelector__list">
<div className="emoteSelector__listRow">
<div className="emoteSelector__listRowTitle">{__('Global Emotes')}</div>
<div className="emoteSelector__listRowItems">
{OLD_QUICK_EMOJIS.map((emoji) => (
<Button
@@ -48,7 +50,7 @@ export default function EmoteSelector(props: Props) {
return (
<Button
key={emoteName}
key={String(emote)}
title={emoteName}
button="alt"
className="button--file-action"
+12 -15
View File
@@ -1,8 +1,8 @@
import { connect } from 'react-redux';
import {
selectClaimForUri,
selectClaimIsMine,
selectHasChannels,
makeSelectClaimForUri,
makeSelectClaimIsMine,
selectMyChannelClaims,
selectFetchingMyChannels,
makeSelectTagInClaimOrChannelForUri,
} from 'redux/selectors/claims';
@@ -14,18 +14,15 @@ import { doToast } from 'redux/actions/notifications';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectSettingsByChannelId } from 'redux/selectors/comments';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
activeChannelClaim: selectActiveChannelClaim(state),
hasChannels: selectHasChannels(state),
claim,
claimIsMine: selectClaimIsMine(state, claim),
isFetchingChannels: selectFetchingMyChannels(state),
settingsByChannelId: selectSettingsByChannelId(state),
supportDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_SUPPORT_TAG)(state),
};
};
const select = (state, props) => ({
activeChannelClaim: selectActiveChannelClaim(state),
channels: selectMyChannelClaims(state),
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
isFetchingChannels: selectFetchingMyChannels(state),
settingsByChannelId: selectSettingsByChannelId(state),
supportDisabled: props.supportDisabled || makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_SUPPORT_TAG)(state),
});
const perform = (dispatch, ownProps) => ({
createComment: (comment, claimId, parentId, txid, payment_intent_id, environment, sticker) =>
@@ -47,7 +47,7 @@ export default function StickerSelector(props: Props) {
className="button--file-action"
onClick={() => onSelect(sticker)}
>
<OptimizedImage src={sticker.url} waitLoad loading="lazy" />
<OptimizedImage src={sticker.url} waitLoad />
{sticker.price && sticker.price > 0 && (
<CreditAmount superChatLight amount={sticker.price} size={2} isFiat />
)}
+82 -113
View File
@@ -4,7 +4,6 @@ import { buildValidSticker } from 'util/comments';
import { FF_MAX_CHARS_IN_COMMENT, FF_MAX_CHARS_IN_LIVESTREAM_COMMENT } from 'constants/form-field';
import { FormField, Form } from 'component/common/form';
import { getChannelIdFromClaim } from 'util/claim';
import { Lbryio } from 'lbryinc';
import { SIMPLE_SITE } from 'config';
import { useHistory } from 'react-router';
import * as ICONS from 'constants/icons';
@@ -43,10 +42,12 @@ type Props = {
activeChannel: string,
activeChannelClaim: ?ChannelClaim,
bottom: boolean,
hasChannels: boolean,
channels: ?Array<ChannelClaim>,
claim: StreamClaim,
claimIsMine: boolean,
editedMessage?: string,
embed?: boolean,
isEdit?: boolean,
isFetchingChannels: boolean,
isNested: boolean,
isReply: boolean,
@@ -61,6 +62,7 @@ type Props = {
doToast: ({ message: string }) => void,
fetchComment: (commentId: string) => Promise<any>,
onCancelReplying?: () => void,
onDoneEditing?: (editedMessage?: string) => void,
onDoneReplying?: () => void,
sendCashTip: (TipParams, UserParams, string, ?string, (any) => void) => string,
sendTip: ({}, (any) => void, (any) => void) => void,
@@ -72,10 +74,12 @@ export function CommentCreate(props: Props) {
const {
activeChannelClaim,
bottom,
hasChannels,
channels,
claim,
claimIsMine,
editedMessage,
embed,
isEdit,
isFetchingChannels,
isNested,
isReply,
@@ -92,6 +96,7 @@ export function CommentCreate(props: Props) {
onCancelReplying,
onDoneReplying,
sendCashTip,
onDoneEditing,
sendTip,
setQuickReply,
} = props;
@@ -115,17 +120,15 @@ export function CommentCreate(props: Props) {
const [selectedSticker, setSelectedSticker] = React.useState();
const [tipAmount, setTipAmount] = React.useState(1);
const [convertedAmount, setConvertedAmount] = React.useState();
const [commentValue, setCommentValue] = React.useState('');
const [commentValue, setCommentValue] = React.useState(editedMessage || '');
const [advancedEditor, setAdvancedEditor] = usePersistedState('comment-editor-mode', false);
const [stickerSelector, setStickerSelector] = React.useState();
const [activeTab, setActiveTab] = React.useState();
const [activeTab, setActiveTab] = React.useState('');
const [tipError, setTipError] = React.useState();
const [deletedComment, setDeletedComment] = React.useState(false);
const [pauseQuickSend, setPauseQuickSend] = React.useState(false);
const [showEmotes, setShowEmotes] = React.useState(false);
const [disableReviewButton, setDisableReviewButton] = React.useState();
const [exchangeRate, setExchangeRate] = React.useState();
const [canReceiveFiatTip, setCanReceiveFiatTip] = React.useState(undefined);
const selectedMentionIndex =
commentValue.indexOf('@', selectionIndex) === selectionIndex
@@ -146,6 +149,7 @@ export function CommentCreate(props: Props) {
const claimId = claim && claim.claim_id;
const channelUri = claim && (claim.signing_channel ? claim.signing_channel.permanent_url : claim.permanent_url);
const hasChannels = channels && channels.length;
const charCount = commentValue ? commentValue.length : 0;
const disabled = deletedComment || isSubmitting || isFetchingChannels || !commentValue.length || pauseQuickSend;
const channelId = getChannelIdFromClaim(claim);
@@ -154,7 +158,6 @@ export function CommentCreate(props: Props) {
const minTip = (channelSettings && channelSettings.min_tip_amount_comment) || 0;
const minAmount = minTip || minSuper || 0;
const minAmountMet = minAmount === 0 || tipAmount >= minAmount;
const stickerPrice = selectedSticker && selectedSticker.price;
const minAmountRef = React.useRef(minAmount);
minAmountRef.current = minAmount;
@@ -171,7 +174,7 @@ export function CommentCreate(props: Props) {
setStickerSelector(false);
if (sticker.price && sticker.price > 0) {
setActiveTab(canReceiveFiatTip ? TAB_FIAT : TAB_LBC);
setActiveTab(TAB_FIAT);
setIsSupportComment(true);
}
}
@@ -271,10 +274,13 @@ export function CommentCreate(props: Props) {
}, 1500);
doToast({
message: __("You sent %tipAmount% Credits as a tip to %tipChannelName%, I'm sure they appreciate it!", {
tipAmount: tipAmount, // force show decimal places
tipChannelName,
}),
message: __(
"You sent %tipAmount% LBRY Credits as a tip to %tipChannelName%, I'm sure they appreciate it!",
{
tipAmount: tipAmount, // force show decimal places
tipChannelName,
}
),
});
setSuccessTip({ txid, tipAmount });
@@ -319,7 +325,7 @@ export function CommentCreate(props: Props) {
if (setQuickReply) setQuickReply(res);
if (res && res.signature) {
if (!stickerValue) setCommentValue('');
setCommentValue('');
setReviewingSupportComment(false);
setIsSupportComment(false);
setCommentFailure(false);
@@ -373,45 +379,12 @@ export function CommentCreate(props: Props) {
return () => clearTimeout(timer);
}, [pauseQuickSend]);
// Stickers: Get LBC-USD exchange rate if hasn't yet and selected a paid sticker
React.useEffect(() => {
if (stickerPrice && !exchangeRate) Lbryio.getExchangeRates().then(({ LBC_USD }) => setExchangeRate(LBC_USD));
}, [exchangeRate, stickerPrice]);
// Stickers: Check if creator has a tip account saved (on selector so that if a paid sticker is selected,
// it defaults to LBC tip instead of USD)
React.useEffect(() => {
if (!stripeEnvironment || !stickerSelector || canReceiveFiatTip !== undefined) return;
const channelClaimId = claim.signing_channel ? claim.signing_channel.claim_id : claim.claim_id;
const tipChannelName = claim.signing_channel ? claim.signing_channel.name : claim.name;
Lbryio.call(
'account',
'check',
{
channel_claim_id: channelClaimId,
channel_name: tipChannelName,
environment: stripeEnvironment,
},
'post'
)
.then((accountCheckResponse) => {
if (accountCheckResponse === true && canReceiveFiatTip !== true) {
setCanReceiveFiatTip(true);
} else {
setCanReceiveFiatTip(false);
}
})
.catch(() => {});
}, [canReceiveFiatTip, claim.claim_id, claim.name, claim.signing_channel, stickerSelector]);
// **************************************************************************
// Render
// **************************************************************************
const getActionButton = (title: string, label?: string, icon: string, handleClick: () => void) => (
<Button title={title} label={label} button="alt" icon={icon} onClick={handleClick} />
const getActionButton = (title: string, icon: string, handleClick: () => void) => (
<Button title={title} button="alt" icon={icon} onClick={handleClick} />
);
if (channelSettings && !channelSettings.comments_enabled) {
@@ -446,7 +419,6 @@ export function CommentCreate(props: Props) {
return (
<Form
onSubmit={() => {}}
className={classnames('commentCreate', {
'commentCreate--reply': isReply,
'commentCreate--nestedReply': isNested,
@@ -464,15 +436,10 @@ export function CommentCreate(props: Props) {
</div>
<div className="commentCreate__stickerPreviewImage">
<OptimizedImage src={selectedSticker && selectedSticker.url} waitLoad loading="lazy" />
<OptimizedImage src={selectedSticker && selectedSticker.url} waitLoad />
</div>
{selectedSticker.price && exchangeRate && (
<FilePrice
customPrices={{ priceFiat: selectedSticker.price, priceLBC: selectedSticker.price / exchangeRate }}
isFiat
/>
)}
{selectedSticker.price && <FilePrice customPrice={selectedSticker.price} isFiat />}
</div>
) : isReviewingSupportComment && activeChannelClaim ? (
<div className="commentCreate__supportCommentPreview">
@@ -513,16 +480,18 @@ export function CommentCreate(props: Props) {
<FormField
disabled={isFetchingChannels}
type={SIMPLE_SITE ? 'textarea' : advancedEditor && !isReply ? 'markdown' : 'textarea'}
name={isReply ? 'content_reply' : 'content_description'}
name={(isReply && 'content_reply') || (isEdit && 'editing_comment') || 'content_description'}
ref={formFieldRef}
className={isReply ? 'content_reply' : 'content_comment'}
className={(isReply && 'content_reply') || (isEdit && 'commentEdit__input') || 'content_comment'}
label={
<span className="commentCreate__labelWrapper">
{!livestream && (
<div className="commentCreate__label">{(isReply ? __('Replying as') : __('Comment as')) + ' '}</div>
)}
<SelectChannel tiny />
</span>
!isEdit && (
<span className="commentCreate__labelWrapper">
{!livestream && (
<div className="commentCreate__label">{isReply ? __('Replying as ') : __('Comment as ')}</div>
)}
<SelectChannel tiny />
</span>
)
}
quickActionLabel={
!SIMPLE_SITE && (isReply ? undefined : advancedEditor ? __('Simple Editor') : __('Advanced Editor'))
@@ -541,14 +510,13 @@ export function CommentCreate(props: Props) {
</>
)}
{(isSupportComment || (isReviewingStickerComment && stickerPrice)) && (
{(isSupportComment || (isReviewingStickerComment && selectedSticker && selectedSticker.price)) && (
<WalletTipAmountSelector
activeTab={activeTab}
amount={tipAmount}
claim={claim}
convertedAmount={convertedAmount}
customTipAmount={stickerPrice}
exchangeRate={exchangeRate}
customTipAmount={selectedSticker && selectedSticker.price}
fiatConversion={selectedSticker && !!selectedSticker.price}
onChange={(amount) => setTipAmount(amount)}
setConvertedAmount={setConvertedAmount}
@@ -579,7 +547,14 @@ export function CommentCreate(props: Props) {
<Button
button="primary"
label={__('Send')}
disabled={isSupportComment && (tipError || disableReviewButton)}
disabled={
(isSupportComment && (tipError || disableReviewButton)) ||
(selectedSticker &&
selectedSticker.price &&
(activeTab === TAB_FIAT
? tipAmount < selectedSticker.price
: convertedAmount && convertedAmount < selectedSticker.price))
}
onClick={() => {
if (isSupportComment) {
handleSupportComment();
@@ -610,16 +585,17 @@ export function CommentCreate(props: Props) {
disabled={disabled || stickerSelector}
type="submit"
label={
isReply
? isSubmitting
? __('Replying...')
: __('Reply')
: isSubmitting
? __('Commenting...')
: __('Comment --[button to submit something]--')
(isEdit && __('Done')) ||
(isSubmitting
? (isReply && __('Replying...')) || __('Commenting...')
: (isReply && __('Reply')) || __('Comment --[button to submit something]--'))
}
requiresAuth
onClick={() => activeChannelClaim && commentValue.length && handleCreateComment()}
onClick={() =>
activeChannelClaim &&
commentValue.length &&
(isEdit && editedMessage && onDoneEditing ? onDoneEditing() : handleCreateComment())
}
/>
)
)}
@@ -627,43 +603,33 @@ export function CommentCreate(props: Props) {
{/** Stickers/Support Buttons **/}
{!supportDisabled && !stickerSelector && (
<>
{getActionButton(
__('Stickers'),
isReviewingStickerComment ? __('Different Sticker') : undefined,
ICONS.STICKER,
() => {
if (isReviewingStickerComment) setReviewingStickerComment(false);
{isReviewingStickerComment ? (
<Button
button="alt"
label={__('Different Sticker')}
onClick={() => {
setReviewingStickerComment(false);
setIsSupportComment(false);
setStickerSelector(true);
}}
/>
) : (
getActionButton(__('Stickers'), ICONS.TAG, () => {
setIsSupportComment(false);
setStickerSelector(true);
}
)}
{!claimIsMine && (
<>
{(!isSupportComment || activeTab !== TAB_LBC) &&
getActionButton(
__('Credits'),
isSupportComment ? __('Switch to Credits') : undefined,
ICONS.LBC,
() => {
setIsSupportComment(true);
setActiveTab(TAB_LBC);
}
)}
{stripeEnvironment &&
(!isSupportComment || activeTab !== TAB_FIAT) &&
getActionButton(
__('Cash'),
isSupportComment ? __('Switch to Cash') : undefined,
ICONS.FINANCE,
() => {
setIsSupportComment(true);
setActiveTab(TAB_FIAT);
}
)}
</>
})
)}
{!claimIsMine &&
getActionButton(__('LBC'), ICONS.LBC, () => {
setIsSupportComment(true);
setActiveTab(TAB_LBC);
})}
{!claimIsMine &&
stripeEnvironment &&
getActionButton(__('Cash'), ICONS.FINANCE, () => {
setIsSupportComment(true);
setActiveTab(TAB_FIAT);
})}
</>
)}
@@ -672,7 +638,8 @@ export function CommentCreate(props: Props) {
isReviewingSupportComment ||
stickerSelector ||
isReviewingStickerComment ||
(isReply && !minTip)) && (
(isReply && !minTip) ||
isEdit) && (
<Button
disabled={isSupportComment && isSubmitting}
button="link"
@@ -681,7 +648,7 @@ export function CommentCreate(props: Props) {
if (isSupportComment || isReviewingSupportComment) {
if (!isReviewingSupportComment) setIsSupportComment(false);
setReviewingSupportComment(false);
if (stickerPrice) {
if (selectedSticker && selectedSticker.price) {
setReviewingStickerComment(false);
setStickerSelector(false);
setSelectedSticker(null);
@@ -691,6 +658,8 @@ export function CommentCreate(props: Props) {
setStickerSelector(false);
} else if (isReply && !minTip && onCancelReplying) {
onCancelReplying();
} else if (isEdit && onDoneEditing) {
onDoneEditing();
}
}}
/>
+13 -11
View File
@@ -4,22 +4,24 @@ import { doCommentPin, doCommentModAddDelegate } from 'redux/actions/comments';
import { doOpenModal } from 'redux/actions/app';
import { doSetPlayingUri } from 'redux/actions/content';
import { doToast } from 'redux/actions/notifications';
import { selectClaimIsMine, selectClaimForUri } from 'redux/selectors/claims';
import {
makeSelectChannelPermUrlForClaimUri,
makeSelectClaimIsMine,
makeSelectClaimForUri,
} from 'redux/selectors/claims';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectModerationDelegatorsById } from 'redux/selectors/comments';
import { selectPlayingUri } from 'redux/selectors/content';
import CommentMenuList from './view';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
claim,
claimIsMine: selectClaimIsMine(state, claim),
activeChannelClaim: selectActiveChannelClaim(state),
playingUri: selectPlayingUri(state),
moderationDelegatorsById: selectModerationDelegatorsById(state),
};
};
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
contentChannelPermanentUrl: makeSelectChannelPermUrlForClaimUri(props.uri)(state),
activeChannelClaim: selectActiveChannelClaim(state),
playingUri: selectPlayingUri(state),
moderationDelegatorsById: selectModerationDelegatorsById(state),
});
const perform = (dispatch) => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
+7 -18
View File
@@ -24,6 +24,7 @@ type Props = {
// --- select ---
claim: ?Claim,
claimIsMine: boolean,
contentChannelPermanentUrl: any,
activeChannelClaim: ?ChannelClaim,
playingUri: ?PlayingUri,
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
@@ -42,11 +43,11 @@ function CommentMenuList(props: Props) {
const {
uri,
claim,
claimIsMine,
authorUri,
commentIsMine,
commentId,
activeChannelClaim,
contentChannelPermanentUrl,
isTopLevel,
isPinned,
playingUri,
@@ -70,8 +71,6 @@ function CommentMenuList(props: Props) {
} = useHistory();
const contentChannelClaim = getChannelFromClaim(claim);
const contentChannelPermanentUrl = contentChannelClaim && contentChannelClaim.permanent_url;
const activeModeratorInfo = activeChannelClaim && moderationDelegatorsById[activeChannelClaim.claim_id];
const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl;
const activeChannelIsAdmin = activeChannelClaim && activeModeratorInfo && activeModeratorInfo.global;
@@ -85,12 +84,10 @@ function CommentMenuList(props: Props) {
if (playingUri && playingUri.source === 'comment') {
clearPlayingUri();
}
openModal(MODALS.CONFIRM_REMOVE_COMMENT, {
commentId,
deleterClaim: activeChannelClaim,
deleterIsModOrAdmin: activeChannelIsAdmin || activeChannelIsModerator,
creatorClaim: commentIsMine ? undefined : contentChannelClaim,
commentIsMine,
contentChannelPermanentUrl,
supportAmount,
setQuickReply,
});
@@ -105,7 +102,7 @@ function CommentMenuList(props: Props) {
function getBlockOptionElem() {
const isPersonalBlockTheOnlyOption = !activeChannelIsModerator && !activeChannelIsAdmin;
const isTimeoutBlockAvailable = claimIsMine || activeChannelIsModerator;
const isTimeoutBlockAvailable = (claim && claim.is_my_output) || activeChannelIsModerator;
const personalPermanentBlockOnly = isPersonalBlockTheOnlyOption && !isTimeoutBlockAvailable;
function getSubtitle() {
@@ -204,9 +201,7 @@ function CommentMenuList(props: Props) {
{!disableRemove &&
activeChannelClaim &&
(activeChannelIsModerator ||
activeChannelIsAdmin ||
activeChannelClaim.permanent_url === authorUri ||
(activeChannelClaim.permanent_url === authorUri ||
activeChannelClaim.permanent_url === contentChannelPermanentUrl) && (
<MenuItem className="comment__menu-option" onSelect={handleDeleteComment}>
<div className="menu__link">
@@ -220,13 +215,7 @@ function CommentMenuList(props: Props) {
<>
<MenuItem
className="comment__menu-option"
onSelect={() =>
openModal(MODALS.BLOCK_CHANNEL, {
contentUri: uri,
commenterUri: authorUri,
offendingCommentId: commentId,
})
}
onSelect={() => openModal(MODALS.BLOCK_CHANNEL, { contentUri: uri, commenterUri: authorUri })}
>
{getBlockOptionElem()}
</MenuItem>
+3 -4
View File
@@ -1,6 +1,6 @@
import { connect } from 'react-redux';
import Comment from './view';
import { selectClaimIsMine, selectClaimForUri } from 'redux/selectors/claims';
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'redux/selectors/claims';
import { doResolveUri } from 'redux/actions/claims';
import { doToast } from 'redux/actions/notifications';
import { selectMyReactsForComment, selectOthersReactsForComment } from 'redux/selectors/comments';
@@ -11,11 +11,10 @@ const select = (state, props) => {
const activeChannelClaim = selectActiveChannelClaim(state);
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
const reactionKey = activeChannelId ? `${props.commentId}:${activeChannelId}` : props.commentId;
const claim = selectClaimForUri(state, props.uri);
return {
claim,
claimIsMine: selectClaimIsMine(state, claim),
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
myReacts: selectMyReactsForComment(state, reactionKey),
othersReacts: selectOthersReactsForComment(state, reactionKey),
activeChannelId,
+18 -26
View File
@@ -1,12 +1,4 @@
import { connect } from 'react-redux';
import { doResolveUris } from 'redux/actions/claims';
import {
selectClaimForUri,
makeSelectClaimForUri,
selectClaimIsMine,
selectFetchingMyChannels,
selectMyClaimIdsRaw,
} from 'redux/selectors/claims';
import {
selectTopLevelCommentsForUri,
makeSelectTopLevelTotalPagesForUri,
@@ -16,16 +8,17 @@ import {
makeSelectTotalCommentsCountForUri,
selectOthersReacts,
selectMyReacts,
selectCommentIdsForUri,
makeSelectCommentIdsForUri,
selectSettingsByChannelId,
selectPinnedCommentsForUri,
} from 'redux/selectors/comments';
import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
import { doResolveUris } from 'redux/actions/claims';
import { makeSelectClaimForUri, makeSelectClaimIsMine, selectFetchingMyChannels } from 'redux/selectors/claims';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import CommentsList from './view';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
const activeChannelClaim = selectActiveChannelClaim(state);
const topLevelComments = selectTopLevelCommentsForUri(state, props.uri);
@@ -35,32 +28,31 @@ const select = (state, props) => {
: [];
return {
topLevelComments,
resolvedComments,
myChannelIds: selectMyClaimIdsRaw(state),
allCommentIds: selectCommentIdsForUri(state, props.uri),
pinnedComments: selectPinnedCommentsForUri(state, props.uri),
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
claim,
claimIsMine: selectClaimIsMine(state, claim),
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
allCommentIds: makeSelectCommentIdsForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
fetchingChannels: selectFetchingMyChannels(state),
isFetchingComments: selectIsFetchingComments(state),
isFetchingCommentsById: selectIsFetchingCommentsById(state),
isFetchingReacts: selectIsFetchingReacts(state),
fetchingChannels: selectFetchingMyChannels(state),
settingsByChannelId: selectSettingsByChannelId(state),
myReactsByCommentId: selectMyReacts(state),
othersReactsById: selectOthersReacts(state),
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
pinnedComments: selectPinnedCommentsForUri(state, props.uri),
resolvedComments,
settingsByChannelId: selectSettingsByChannelId(state),
topLevelComments,
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
};
};
const perform = (dispatch) => ({
fetchTopLevelComments: (uri, page, pageSize, sortBy) => dispatch(doCommentList(uri, '', page, pageSize, sortBy)),
const perform = (dispatch, ownProps) => ({
doResolveUris: (uris) => dispatch(doResolveUris(uris, true)),
fetchComment: (commentId) => dispatch(doCommentById(commentId)),
fetchReacts: (commentIds) => dispatch(doCommentReactList(commentIds)),
resetComments: (claimId) => dispatch(doCommentReset(claimId)),
doResolveUris: (uris) => dispatch(doResolveUris(uris, true)),
fetchTopLevelComments: (page, pageSize, sortBy) => dispatch(doCommentList(ownProps.uri, '', page, pageSize, sortBy)),
resetComments: () => ownProps.claim && dispatch(doCommentReset(ownProps.claim.claimId)),
});
export default connect(select, perform)(CommentsList);
+42 -64
View File
@@ -1,7 +1,9 @@
// @flow
import 'scss/component/_comments-list.scss';
import { COMMENT_PAGE_SIZE_TOP_LEVEL, SORT_BY } from 'constants/comment';
import { ENABLE_COMMENT_REACTIONS } from 'config';
import { getChannelIdFromClaim } from 'util/claim';
import { scaleToDevicePixelRatio } from 'util/scale';
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
import * as ICONS from 'constants/icons';
import * as REACTION_TYPES from 'constants/reactions';
@@ -18,67 +20,57 @@ import usePersistedState from 'effects/use-persisted-state';
const DEBOUNCE_SCROLL_HANDLER_MS = 200;
function scaleToDevicePixelRatio(value) {
const devicePixelRatio = window.devicePixelRatio || 1.0;
if (devicePixelRatio < 1.0) {
return Math.ceil(value / devicePixelRatio);
}
return Math.ceil(value * devicePixelRatio);
}
type Props = {
activeChannelId: ?string,
allCommentIds: any,
pinnedComments: Array<Comment>,
topLevelComments: Array<Comment>,
resolvedComments: Array<Comment>,
topLevelTotalPages: number,
uri: string,
claim: ?Claim,
claimIsMine: boolean,
myChannelIds: ?Array<string>,
commentsAreExpanded?: boolean,
fetchingChannels: boolean,
isFetchingComments: boolean,
isFetchingCommentsById: boolean,
isFetchingReacts: boolean,
linkedCommentId?: string,
totalComments: number,
fetchingChannels: boolean,
myReactsByCommentId: ?{ [string]: Array<string> }, // "CommentId:MyChannelId" -> reaction array (note the ID concatenation)
othersReactsById: ?{ [string]: { [REACTION_TYPES.LIKE | REACTION_TYPES.DISLIKE]: number } },
activeChannelId: ?string,
pinnedComments: Array<Comment>,
resolvedComments: Array<Comment>,
settingsByChannelId: { [channelId: string]: PerChannelSettings },
commentsAreExpanded?: boolean,
fetchReacts: (Array<string>) => Promise<any>,
topLevelComments: Array<Comment>,
topLevelTotalPages: number,
totalComments: number,
uri: string,
doResolveUris: (Array<string>) => void,
fetchTopLevelComments: (string, number, number, number) => void,
fetchComment: (string) => void,
resetComments: (string) => void,
fetchReacts: (Array<string>) => Promise<any>,
fetchTopLevelComments: (number, number, string) => void,
resetComments: () => void,
};
function CommentList(props: Props) {
function CommentsList(props: Props) {
const {
activeChannelId,
allCommentIds,
uri,
pinnedComments,
topLevelComments,
resolvedComments,
topLevelTotalPages,
claim,
claimIsMine,
myChannelIds,
commentsAreExpanded,
doResolveUris,
fetchingChannels,
fetchReacts,
isFetchingComments,
isFetchingReacts,
linkedCommentId,
totalComments,
fetchingChannels,
myReactsByCommentId,
othersReactsById,
activeChannelId,
pinnedComments,
resolvedComments,
settingsByChannelId,
commentsAreExpanded,
fetchReacts,
doResolveUris,
fetchTopLevelComments,
topLevelComments,
topLevelTotalPages,
totalComments,
uri,
fetchComment,
fetchTopLevelComments,
resetComments,
} = props;
@@ -92,6 +84,7 @@ function CommentList(props: Props) {
const [commentsToDisplay, setCommentsToDisplay] = React.useState(topLevelComments);
const hasDefaultExpansion = commentsAreExpanded || desktopView;
const [expandedComments, setExpandedComments] = React.useState(hasDefaultExpansion);
const totalFetchedComments = allCommentIds ? allCommentIds.length : 0;
const channelId = getChannelIdFromClaim(claim);
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
@@ -106,7 +99,7 @@ function CommentList(props: Props) {
Boolean(othersReactsById) || !ENABLE_COMMENT_REACTIONS
);
function changeSort(newSort) {
function changeSort(newSort: string) {
if (sort !== newSort) {
setSort(newSort);
setPage(0); // Invalidate existing comments
@@ -116,9 +109,7 @@ function CommentList(props: Props) {
// Reset comments
useEffect(() => {
if (page === 0) {
if (claim) {
resetComments(claim.claim_id);
}
if (claim) resetComments();
setPage(1);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -131,7 +122,7 @@ function CommentList(props: Props) {
fetchComment(linkedCommentId);
}
fetchTopLevelComments(uri, page, COMMENT_PAGE_SIZE_TOP_LEVEL, sort);
fetchTopLevelComments(page, COMMENT_PAGE_SIZE_TOP_LEVEL, sort);
}
}, [fetchComment, fetchTopLevelComments, linkedCommentId, page, sort, uri]);
@@ -237,37 +228,25 @@ function CommentList(props: Props) {
if (!topLevelComments || alreadyResolved) return;
const urisToResolve = [];
topLevelComments.map(({ channel_url }) => channel_url !== undefined && urisToResolve.push(channel_url));
topLevelComments.forEach(({ channel_url }) => channel_url !== undefined && urisToResolve.push(channel_url));
if (urisToResolve.length > 0) doResolveUris(urisToResolve);
}, [alreadyResolved, doResolveUris, topLevelComments]);
const getCommentElems = (comments) =>
comments.map((comment) => (
const getCommentElems = (comments: Array<Comment>) =>
comments.map((comment: Comment) => (
<CommentView
isTopLevel
threadDepth={3}
key={comment.comment_id}
uri={uri}
authorUri={comment.channel_url}
author={comment.channel_name}
claimId={comment.claim_id}
commentId={comment.comment_id}
message={comment.comment}
timePosted={comment.timestamp * 1000}
claimIsMine={claimIsMine}
commentIsMine={comment.channel_id && myChannelIds && myChannelIds.includes(comment.channel_id)}
comment={comment}
isTopLevel
key={comment.comment_id}
linkedCommentId={linkedCommentId}
isPinned={comment.is_pinned}
supportAmount={comment.support_amount}
numDirectReplies={comment.replies}
isModerator={comment.is_moderator}
isGlobalMod={comment.is_global_mod}
isFiat={comment.is_fiat}
threadDepth={3}
uri={uri}
/>
));
const sortButton = (label, icon, sortOption) => (
const sortButton = (label: string, icon: string, sortOption: string) => (
<Button
button="alt"
label={label}
@@ -309,8 +288,7 @@ function CommentList(props: Props) {
)}
<ul
className={classnames({
comments: desktopView || expandedComments,
className={classnames('comments', {
'comments--contracted': !desktopView && !expandedComments,
})}
>
@@ -350,4 +328,4 @@ function CommentList(props: Props) {
);
}
export default CommentList;
export default CommentsList;
+4 -5
View File
@@ -1,6 +1,6 @@
import { connect } from 'react-redux';
import { doResolveUris } from 'redux/actions/claims';
import { selectClaimIsMineForUri, selectMyChannelClaimIds, makeSelectClaimForUri } from 'redux/selectors/claims';
import { makeSelectClaimIsMine, makeSelectClaimForUri } from 'redux/selectors/claims';
import { selectIsFetchingCommentsByParentId, selectRepliesForParentId } from 'redux/selectors/comments';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import CommentsReplies from './view';
@@ -13,12 +13,11 @@ const select = (state, props) => {
: [];
return {
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
fetchedReplies,
resolvedReplies,
claimIsMine: selectClaimIsMineForUri(state, props.uri),
userCanComment: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
myChannelIds: selectMyChannelClaimIds(state),
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
resolvedReplies,
userCanComment: selectUserVerifiedEmail(state),
};
};
+33 -43
View File
@@ -1,4 +1,5 @@
// @flow
import 'scss/component/_comments.scss';
import * as ICONS from 'constants/icons';
import Button from 'component/button';
import Comment from 'component/comment';
@@ -6,44 +7,43 @@ import React from 'react';
import Spinner from 'component/spinner';
type Props = {
fetchedReplies: Array<Comment>,
resolvedReplies: Array<Comment>,
uri: string,
parentId: string,
claimIsMine: boolean,
myChannelIds: ?Array<string>,
linkedCommentId?: string,
userCanComment: boolean,
threadDepth: number,
numDirectReplies: number, // Total replies for parentId as reported by 'comment[replies]'. Includes blocked items.
isFetchingByParentId: { [string]: boolean },
fetchedReplies: Array<Comment>,
hasMore: boolean,
isFetchingByParentId: { [string]: boolean },
linkedCommentId?: string,
numDirectReplies: number, // Total replies for parentId as reported by 'comment[replies]'. Includes blocked items.
parentId: string,
resolvedReplies: Array<Comment>,
supportDisabled: boolean,
threadDepth: number,
uri: string,
userCanComment: boolean,
doResolveUris: (Array<string>) => void,
onShowMore?: () => void,
};
function CommentsReplies(props: Props) {
const {
uri,
parentId,
fetchedReplies,
resolvedReplies,
claimIsMine,
myChannelIds,
linkedCommentId,
userCanComment,
threadDepth,
numDirectReplies,
isFetchingByParentId,
fetchedReplies,
hasMore,
isFetchingByParentId,
linkedCommentId,
numDirectReplies,
parentId,
resolvedReplies,
supportDisabled,
threadDepth,
uri,
userCanComment,
doResolveUris,
onShowMore,
} = props;
const [isExpanded, setExpanded] = React.useState(true);
const [commentsToDisplay, setCommentsToDisplay] = React.useState(fetchedReplies);
const isResolvingReplies = fetchedReplies && resolvedReplies.length !== fetchedReplies.length;
const alreadyResolved = !isResolvingReplies && resolvedReplies.length !== 0;
const canDisplayComments = commentsToDisplay && commentsToDisplay.length === fetchedReplies.length;
@@ -53,7 +53,7 @@ function CommentsReplies(props: Props) {
if (!fetchedReplies || alreadyResolved) return;
const urisToResolve = [];
fetchedReplies.map(({ channel_url }) => channel_url !== undefined && urisToResolve.push(channel_url));
fetchedReplies.forEach(({ channel_url }) => channel_url !== undefined && urisToResolve.push(channel_url));
if (urisToResolve.length > 0) doResolveUris(urisToResolve);
}, [alreadyResolved, doResolveUris, fetchedReplies]);
@@ -65,7 +65,7 @@ function CommentsReplies(props: Props) {
}, [isResolvingReplies, fetchedReplies]);
return !numDirectReplies ? null : (
<div className="comment__replies-container">
<div className="commentReplies__container">
{!isExpanded ? (
<div className="comment__actions--nested">
<Button
@@ -83,31 +83,22 @@ function CommentsReplies(props: Props) {
{!isResolvingReplies &&
commentsToDisplay &&
commentsToDisplay.length > 0 &&
commentsToDisplay.map((comment) => (
commentsToDisplay.map((comment: Comment) => (
<Comment
claimIsMine={claimIsMine}
comment={comment}
commentingEnabled={userCanComment}
key={comment.comment_id}
linkedCommentId={linkedCommentId}
supportDisabled={supportDisabled}
threadDepth={threadDepth}
uri={uri}
authorUri={comment.channel_url}
author={comment.channel_name}
claimId={comment.claim_id}
commentId={comment.comment_id}
key={comment.comment_id}
message={comment.comment}
timePosted={comment.timestamp * 1000}
claimIsMine={claimIsMine}
commentIsMine={comment.channel_id && myChannelIds && myChannelIds.includes(comment.channel_id)}
linkedCommentId={linkedCommentId}
commentingEnabled={userCanComment}
supportAmount={comment.support_amount}
numDirectReplies={comment.replies}
isModerator={comment.is_moderator}
isGlobalMod={comment.is_global_mod}
supportDisabled={supportDisabled}
/>
))}
</ul>
</div>
)}
{isExpanded && fetchedReplies && hasMore && (
<div className="comment__actions--nested">
<Button
@@ -118,11 +109,10 @@ function CommentsReplies(props: Props) {
/>
</div>
)}
{(isFetchingByParentId[parentId] || isResolvingReplies || !canDisplayComments) && (
<div className="comment__replies-container">
<div className="comment__actions--nested">
<Spinner type="small" />
</div>
<div className="comment__actions--nested">
<Spinner type="small" />
</div>
)}
</div>
+51 -61
View File
@@ -1,112 +1,102 @@
// @flow
import { formatCredits, formatFullPrice } from 'util/format-credits';
import React from 'react';
import classnames from 'classnames';
import LbcSymbol from 'component/common/lbc-symbol';
import React from 'react';
import { formatCredits, formatFullPrice } from 'util/format-credits';
type Props = {
amount?: number,
className?: string,
customAmounts?: { amountFiat: number, amountLBC: number },
fee?: boolean,
isEstimate?: boolean,
isFiat?: boolean,
noFormat?: boolean,
amount: number,
precision: number,
showFree: boolean,
showFullPrice: boolean,
showLBC?: boolean,
showPlus: boolean,
isEstimate?: boolean,
showLBC?: boolean,
fee?: boolean,
className?: string,
noFormat?: boolean,
size?: number,
superChat?: boolean,
superChatLight?: boolean,
isFiat?: boolean,
};
class CreditAmount extends React.PureComponent<Props> {
static defaultProps = {
noFormat: false,
precision: 2,
showFree: false,
showFullPrice: false,
showLBC: true,
showPlus: false,
showLBC: true,
noFormat: false,
};
render() {
const {
amount,
className,
customAmounts,
fee,
isEstimate,
isFiat,
noFormat,
precision,
showFree,
showFullPrice,
showLBC,
showFree,
showPlus,
isEstimate,
fee,
showLBC,
className,
noFormat,
size,
superChat,
superChatLight,
isFiat,
} = this.props;
const minimumRenderableAmount = 10 ** (-1 * precision);
// return null, otherwise it will try and convert undefined to a string
if (amount === undefined && customAmounts === undefined) return null;
if (amount === undefined) {
return null;
}
const fullPrice = formatFullPrice(amount, 2);
const isFree = parseFloat(amount) === 0;
function getAmountText(amount: number, isFiat?: boolean) {
const fullPrice = formatFullPrice(amount, 2);
const isFree = parseFloat(amount) === 0;
let formattedAmount;
let formattedAmount;
if (showFullPrice) {
formattedAmount = fullPrice;
} else {
formattedAmount =
amount > 0 && amount < minimumRenderableAmount
? `<${minimumRenderableAmount}`
: formatCredits(amount, precision, true);
}
if (showFullPrice) {
formattedAmount = fullPrice;
} else {
formattedAmount =
amount > 0 && amount < minimumRenderableAmount
? `<${minimumRenderableAmount}`
: formatCredits(amount, precision, true);
let amountText;
if (showFree && isFree) {
amountText = __('Free');
} else {
amountText = noFormat ? amount : formattedAmount;
if (showPlus && amount > 0) {
amountText = `+${amountText}`;
}
if (showFree && isFree) {
return __('Free');
} else {
let amountText = noFormat ? amount : formattedAmount;
if (showLBC && !isFiat) {
amountText = <LbcSymbol postfix={amountText} size={size} />;
} else if (showLBC && isFiat) {
amountText = <p style={{ display: 'inline' }}> ${(Math.round(Number(amountText) * 100) / 100).toFixed(2)}</p>;
}
if (showPlus && amount > 0) {
amountText = `+${amountText}`;
}
if (showLBC && !isFiat) {
amountText = <LbcSymbol postfix={amountText} size={size} />;
} else if (showLBC && isFiat) {
amountText = <p style={{ display: 'inline' }}> ${(Math.round(Number(amountText) * 100) / 100).toFixed(2)}</p>;
}
if (fee) {
amountText = __('%amount% fee', { amount: amountText });
}
return amountText;
if (fee) {
amountText = __('%amount% fee', { amount: amountText });
}
}
return (
<span
title={amount ? formatFullPrice(amount, 2) : ''}
title={fullPrice}
className={classnames(className, {
'super-chat': superChat,
'super-chat--light': superChatLight,
superChat: superChat,
'superChat--light': superChatLight,
})}
>
{customAmounts
? Object.values(customAmounts).map((amount, index) => (
<span key={String(amount)} className="credit-amount">
{getAmountText(Number(amount), !index)}
</span>
))
: amount && <span className="credit-amount">{getAmountText(amount, isFiat)}</span>}
<span className="credit-amount">{amountText}</span>
{isEstimate ? (
<span className="credit-amount__estimate" title={__('This is an estimate and does not include data fees')}>
@@ -239,7 +239,7 @@ export class FormField extends React.PureComponent<Props> {
{...inputProps}
/>
<div className="form-field__textarea-info">
{!noEmojis && openEmoteMenu && (
{!noEmojis && (
<Button
type="alt"
className="button--file-action"
-28
View File
@@ -2534,32 +2534,4 @@ export const icons = {
<line x1="15" y1="9" x2="15.01" y2="9" />
</g>
),
[ICONS.STICKER]: buildIcon(
<g>
<path d="M7.13,9a.38.38,0,1,1-.38.38A.38.38,0,0,1,7.13,9" />
<path d="M5.51,15.42A7.34,7.34,0,0,0,12,19.34a7.83,7.83,0,0,0,.92-.06" />
<path d="M23.24,11.52A11.25,11.25,0,1,0,12,23.25h.5" />
<path d="M14.45,9.66a2.31,2.31,0,0,1,3.91,0" />
<line x1="23.24" y1="11.52" x2="12.5" y2="23.24" />
<path d="M12.5,23.24v-1A10.74,10.74,0,0,1,23.24,11.52" />
</g>
),
[ICONS.EDUCATION]: buildIcon(
<g>
<path d="M12,14c0-1.455,2.964-3.381,8.484-3.494a.508.508,0,0,1,.516.5v8.5a.5.5,0,0,1-.5.5c-5.533.11-8.5,2.038-8.5,3.5,0-1.457-2.971-3.385-8.5-3.5a.5.5,0,0,1-.5-.5v-8.5a.508.508,0,0,1,.516-.5C9.035,10.62,12,12.546,12,14Z" />
<path d="M12 14.001L12 23.376" />
<path d="M10,14.742A20.1,20.1,0,0,0,5.52,13.7" />
<path d="M10,17.742a20.265,20.265,0,0,0-4.521-1.048" />
<path d="M14,14.742a20.2,20.2,0,0,1,4.523-1.048" />
<path d="M14,17.742a20.213,20.213,0,0,1,4.524-1.048" />
<path d="M4.566,9A7.5,7.5,0,1,1,19.434,9" />
<path d="M9.624,9,9.189,7.259a1,1,0,0,0-.97-.758H4.651" />
<path d="M17.99,3.5H15.281a1,1,0,0,0-.97.758l-.5,2a1,1,0,0,0,.97,1.242h1.052l.245,1.469" />
</g>
),
[ICONS.POP_CULTURE]: buildIcon(
<g>
<path d="M23.5,12.11a7,7,0,0,1-3.27,5.59.26.26,0,0,1-.32,0,.27.27,0,0,1-.05-.31A2.71,2.71,0,0,0,20,17c.65-1.4.5-2.85-.34-3.25s-2,.41-2.67,1.77c.06-.93-.26-1.7-.86-1.88-1.27-.4-1.77,1.24-4.17,5.44-2.44-4.27-2.9-5.84-4.17-5.44-.6.18-.92.95-.86,1.88-.66-1.36-1.84-2.15-2.67-1.77S3.31,15.63,4,17a2.71,2.71,0,0,0,.18.34.27.27,0,0,1,0,.31.26.26,0,0,1-.32,0A7,7,0,0,1,.5,12.11C.5,8.93,3.17,6.18,7,4.9a.25.25,0,0,1,.32.3L7,6.73a3.37,3.37,0,0,0,.78,3,1,1,0,0,0,1.1.28,1,1,0,0,0,.65-.94V5.61a.25.25,0,0,1,.4-.2l1.6,1.2h1l1.6-1.2a.25.25,0,0,1,.4.2V9.05a1,1,0,0,0,.65.94,1,1,0,0,0,1.1-.28,3.35,3.35,0,0,0,.78-3L16.65,5.2A.25.25,0,0,1,17,4.9C20.83,6.18,23.5,8.93,23.5,12.11Z" />
</g>
),
};
+52 -36
View File
@@ -1,34 +1,26 @@
// @flow
import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS, SIMPLE_SITE } from 'config';
import { formattedEmote, inlineEmote } from 'util/remark-emote';
import { formattedLinks, inlineLinks } from 'util/remark-lbry';
import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp';
import * as ICONS from 'constants/icons';
import * as React from 'react';
import Button from 'component/button';
import classnames from 'classnames';
import defaultSchema from 'hast-util-sanitize/lib/github.json';
import MarkdownLink from 'component/markdownLink';
import OptimizedImage from 'component/optimizedImage';
import reactRenderer from 'remark-react';
import remark from 'remark';
import remarkAttr from 'remark-attr';
import remarkBreaks from 'remark-breaks';
import remarkEmoji from 'remark-emoji';
import remarkFrontMatter from 'remark-frontmatter';
import remarkStrip from 'strip-markdown';
import remarkEmoji from 'remark-emoji';
import remarkBreaks from 'remark-breaks';
import remarkFrontMatter from 'remark-frontmatter';
import reactRenderer from 'remark-react';
import MarkdownLink from 'component/markdownLink';
import defaultSchema from 'hast-util-sanitize/lib/github.json';
import { formattedLinks, inlineLinks } from 'util/remark-lbry';
import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp';
import { formattedEmote, inlineEmote } from 'util/remark-emote';
import ZoomableImage from 'component/zoomableImage';
import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS, SIMPLE_SITE } from 'config';
import Button from 'component/button';
import * as ICONS from 'constants/icons';
import OptimizedImage from 'component/optimizedImage';
const RE_EMOTE = /:\+1:|:-1:|:[\w-]+:/;
function isEmote(title, src) {
return title && RE_EMOTE.test(title) && src.includes('static.odycdn.com/emoticons');
}
function isStakeEnoughForPreview(stakedLevel) {
return !stakedLevel || stakedLevel >= CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS;
}
type SimpleTextProps = {
children?: React.Node,
};
@@ -111,8 +103,8 @@ const SimpleImageLink = (props: ImageLinkProps) => {
return null;
}
if (isEmote(title, src)) {
return <OptimizedImage src={src} title={title} className="emote" waitLoad loading="lazy" />;
if (title && RE_EMOTE.test(title) && src.includes('static.odycdn.com/emoticons')) {
return <OptimizedImage title={title} src={src} />;
}
return (
@@ -142,6 +134,13 @@ const REPLACE_REGEX = /(<iframe\s+src=["'])(.*?(?=))(["']\s*><\/iframe>)/g;
// ****************************************************************************
// ****************************************************************************
function isStakeEnoughForPreview(stakedLevel) {
return !stakedLevel || stakedLevel >= CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS;
}
// ****************************************************************************
// ****************************************************************************
const MarkdownPreview = (props: MarkdownProps) => {
const {
content,
@@ -174,6 +173,10 @@ const MarkdownPreview = (props: MarkdownProps) => {
})
: '';
const initialQuote = strippedContent.split(' ').find((word) => word.length > 0 || word.charAt(0) === '>');
let stripQuote;
if (initialQuote && initialQuote.charAt(0) === '>') stripQuote = true;
const remarkOptions: Object = {
sanitize: schema,
fragment: React.Fragment,
@@ -191,17 +194,18 @@ const MarkdownPreview = (props: MarkdownProps) => {
),
// Workaraund of remarkOptions.Fragment
div: React.Fragment,
img: (imgProps) =>
isStakeEnoughForPreview(stakedLevel) && !isEmote(imgProps.title, imgProps.src) ? (
<ZoomableImage {...imgProps} />
) : (
<SimpleImageLink
src={imgProps.src}
alt={imgProps.alt}
title={imgProps.title}
helpText={SIMPLE_SITE ? __("This channel isn't staking enough Credits for inline image previews.") : ''}
/>
),
img: isStakeEnoughForPreview(stakedLevel)
? ZoomableImage
: (imgProps) => (
<SimpleImageLink
src={imgProps.src}
alt={imgProps.alt}
title={imgProps.title}
helpText={
SIMPLE_SITE ? __("This channel isn't staking enough LBRY Credits for inline image previews.") : ''
}
/>
),
},
};
@@ -213,10 +217,22 @@ const MarkdownPreview = (props: MarkdownProps) => {
};
// Strip all content and just render text
if (strip) {
if (strip || stripQuote) {
// Remove new lines and extra space
remarkOptions.remarkReactComponents.p = SimpleText;
return (
return stripQuote ? (
<span dir="auto" className="markdown-preview">
<blockquote>
{
remark()
.use(remarkStrip)
.use(remarkFrontMatter, ['yaml'])
.use(reactRenderer, remarkOptions)
.processSync(content).contents
}
</blockquote>
</span>
) : (
<span dir="auto" className="markdown-preview">
{
remark()
+1 -8
View File
@@ -20,8 +20,7 @@ function Paginate(props: Props) {
const { search } = location;
const [textValue, setTextValue] = React.useState('');
const urlParams = new URLSearchParams(search);
const urlParamPage = Number(urlParams.get(PAGINATE_PARAM));
const initialPage = disableHistory ? 1 : urlParamPage || 1;
const initialPage = disableHistory ? 1 : Number(urlParams.get(PAGINATE_PARAM)) || 1;
const [currentPage, setCurrentPage] = React.useState(initialPage);
const isMobile = useIsMobile();
@@ -48,12 +47,6 @@ function Paginate(props: Props) {
}
}
React.useEffect(() => {
if (urlParamPage) {
setCurrentPage(urlParamPage);
}
}, [urlParamPage, setCurrentPage]);
return (
// Hide the paginate controls if we are loading or there is only one page
// It should still be rendered to trigger the onPageChange callback
+2 -9
View File
@@ -1,17 +1,10 @@
// @flow
import React from 'react';
import { scaleToDevicePixelRatio } from 'util/scale';
import debounce from 'util/debounce';
import React from 'react';
const DEBOUNCE_SCROLL_HANDLER_MS = 50;
function scaleToDevicePixelRatio(value) {
const devicePixelRatio = window.devicePixelRatio || 1.0;
if (devicePixelRatio < 1.0) {
return Math.ceil(value / devicePixelRatio);
}
return Math.ceil(value * devicePixelRatio);
}
type Props = {
children: any,
skipWait?: boolean,
+2 -2
View File
@@ -1,11 +1,11 @@
import { connect } from 'react-redux';
import { selectDateForUri } from 'redux/selectors/claims';
import * as SETTINGS from 'constants/settings';
import { selectClientSetting } from 'redux/selectors/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import DateTime from './view';
const select = (state, props) => ({
date: props.date || selectDateForUri(state, props.uri),
clock24h: selectClientSetting(state, SETTINGS.CLOCK_24H),
clock24h: makeSelectClientSetting(SETTINGS.CLOCK_24H)(state),
});
export default connect(select)(DateTime);
+2 -2
View File
@@ -1,12 +1,12 @@
import { connect } from 'react-redux';
import { doSetClientSetting } from 'redux/actions/settings';
import { selectClientSetting } from 'redux/selectors/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { selectEmailToVerify, selectUser } from 'redux/selectors/user';
import FirstRunEmailCollection from './view';
import * as SETTINGS from 'constants/settings';
const select = (state) => ({
emailCollectionAcknowledged: selectClientSetting(state, SETTINGS.EMAIL_COLLECTION_ACKNOWLEDGED),
emailCollectionAcknowledged: makeSelectClientSetting(SETTINGS.EMAIL_COLLECTION_ACKNOWLEDGED)(state),
email: selectEmailToVerify(state),
user: selectUser(state),
});
+6 -6
View File
@@ -1,20 +1,20 @@
import { connect } from 'react-redux';
import { selectThumbnailForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
import { makeSelectThumbnailForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
import { doResolveUri } from 'redux/actions/claims';
import * as SETTINGS from 'constants/settings';
import { doFetchCostInfoForUri, selectCostInfoForUri } from 'lbryinc';
import { doFetchCostInfoForUri, makeSelectCostInfoForUri } from 'lbryinc';
import { doPlayUri, doSetPlayingUri } from 'redux/actions/content';
import { doAnaltyicsPurchaseEvent } from 'redux/actions/app';
import { selectClientSetting } from 'redux/selectors/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
import ChannelThumbnail from './view';
const select = (state, props) => ({
thumbnail: selectThumbnailForUri(state, props.uri),
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
floatingPlayerEnabled: selectClientSetting(state, SETTINGS.FLOATING_PLAYER),
costInfo: selectCostInfoForUri(state, props.uri),
floatingPlayerEnabled: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
});
+2 -2
View File
@@ -3,7 +3,7 @@ import * as ICONS from 'constants/icons';
import { FormField } from 'component/common/form';
import Button from 'component/button';
import React, { useRef } from 'react';
import { generateEmbedUrl, generateEmbedIframeData } from 'util/web';
import { generateEmbedUrl } from 'util/web';
type Props = {
copyable: string,
@@ -22,7 +22,7 @@ export default function EmbedTextArea(props: Props) {
const input = useRef();
const streamUrl = generateEmbedUrl(name, claimId, includeStartTime, startTime, referralCode);
const { html: embedText } = generateEmbedIframeData(streamUrl);
let embedText = `<iframe id="lbry-iframe" width="560" height="315" src="${streamUrl}" allowfullscreen></iframe>`;
function copyToClipboard() {
const topRef = input.current;
+16 -20
View File
@@ -1,15 +1,15 @@
import { connect } from 'react-redux';
import {
selectClaimIsMine,
selectClaimForUri,
selectHasChannels,
selectIsStreamPlaceholderForUri,
makeSelectClaimIsMine,
makeSelectClaimForUri,
selectMyChannelClaims,
makeSelectClaimIsStreamPlaceholder,
makeSelectTagInClaimOrChannelForUri,
} from 'redux/selectors/claims';
import { makeSelectStreamingUrlForUri, makeSelectFileInfoForUri } from 'redux/selectors/file_info';
import { doPrepareEdit } from 'redux/actions/publish';
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
import { selectCostInfoForUri } from 'lbryinc';
import { makeSelectCostInfoForUri } from 'lbryinc';
import { doSetPlayingUri, doPlayUri } from 'redux/actions/content';
import { doToast } from 'redux/actions/notifications';
import { doOpenModal, doSetActiveChannel, doSetIncognito, doAnalyticsView } from 'redux/actions/app';
@@ -17,21 +17,17 @@ import fs from 'fs';
import FileActions from './view';
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
claim,
claimIsMine: selectClaimIsMine(state, claim),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
costInfo: selectCostInfoForUri(state, props.uri),
hasChannels: selectHasChannels(state),
isLivestreamClaim: selectIsStreamPlaceholderForUri(state, props.uri),
reactionsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
};
};
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
myChannels: selectMyChannelClaims(state),
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
reactionsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
});
const perform = (dispatch) => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
+3 -2
View File
@@ -27,7 +27,7 @@ type Props = {
fileInfo: FileListItem,
costInfo: ?{ cost: number },
renderMode: string,
hasChannels: boolean,
myChannels: ?Array<ChannelClaim>,
doToast: ({ message: string }) => void,
clearPlayingUri: () => void,
hideRepost?: boolean,
@@ -47,7 +47,7 @@ function FileActions(props: Props) {
costInfo,
renderMode,
prepareEdit,
hasChannels,
myChannels,
clearPlayingUri,
doToast,
hideRepost,
@@ -63,6 +63,7 @@ function FileActions(props: Props) {
const isMobile = useIsMobile();
const webShareable = costInfo && costInfo.cost === 0 && RENDER_MODES.WEB_SHAREABLE_MODES.includes(renderMode);
const showDelete = claimIsMine || (fileInfo && (fileInfo.written_bytes > 0 || fileInfo.blobs_completed > 0));
const hasChannels = myChannels && myChannels.length > 0;
const claimId = claim && claim.claim_id;
const { signing_channel: signingChannel } = claim;
const channelName = signingChannel && signingChannel.name;
+12 -12
View File
@@ -1,21 +1,21 @@
import { connect } from 'react-redux';
import { selectClaimForUri, makeSelectMetadataForUri, selectClaimIsMine } from 'redux/selectors/claims';
import {
makeSelectClaimForUri,
makeSelectMetadataForUri,
makeSelectClaimIsMine,
} from 'redux/selectors/claims';
import { makeSelectPendingAmountByUri } from 'redux/selectors/wallet';
import { doOpenModal } from 'redux/actions/app';
import { selectUser } from 'redux/selectors/user';
import FileDescription from './view';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
claim,
claimIsMine: selectClaimIsMine(state, claim),
metadata: makeSelectMetadataForUri(props.uri)(state),
user: selectUser(state),
pendingAmount: makeSelectPendingAmountByUri(props.uri)(state),
};
};
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
user: selectUser(state),
pendingAmount: makeSelectPendingAmountByUri(props.uri)(state),
});
export default connect(select, {
doOpenModal,
+12 -16
View File
@@ -1,30 +1,26 @@
import { connect } from 'react-redux';
import { selectClaimIsMine, selectClaimForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
import { makeSelectClaimIsMine, makeSelectClaimForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
import {
makeSelectFileInfoForUri,
makeSelectDownloadingForUri,
makeSelectLoadingForUri,
makeSelectStreamingUrlForUri,
} from 'redux/selectors/file_info';
import { selectCostInfoForUri } from 'lbryinc';
import { makeSelectCostInfoForUri } from 'lbryinc';
import { doOpenModal, doAnalyticsView } from 'redux/actions/app';
import { doSetPlayingUri, doPlayUri } from 'redux/actions/content';
import FileDownloadLink from './view';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
downloading: makeSelectDownloadingForUri(props.uri)(state),
loading: makeSelectLoadingForUri(props.uri)(state),
claimIsMine: selectClaimIsMine(state, claim),
claim,
costInfo: selectCostInfoForUri(state, props.uri),
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
};
};
const select = (state, props) => ({
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
downloading: makeSelectDownloadingForUri(props.uri)(state),
loading: makeSelectLoadingForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
});
const perform = (dispatch) => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
+9 -13
View File
@@ -1,18 +1,14 @@
import { connect } from 'react-redux';
import { selectClaimForUri, makeSelectClaimWasPurchased, selectClaimIsMine } from 'redux/selectors/claims';
import { selectCostInfoForUri, doFetchCostInfoForUri, selectFetchingCostInfoForUri } from 'lbryinc';
import { makeSelectClaimForUri, makeSelectClaimWasPurchased, makeSelectClaimIsMine } from 'redux/selectors/claims';
import { makeSelectCostInfoForUri, doFetchCostInfoForUri, makeSelectFetchingCostInfoForUri } from 'lbryinc';
import FilePrice from './view';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
claim,
claimIsMine: selectClaimIsMine(state, claim),
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
costInfo: selectCostInfoForUri(state, props.uri),
fetching: selectFetchingCostInfoForUri(state, props.uri),
};
};
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
fetching: makeSelectFetchingCostInfoForUri(props.uri)(state),
});
export default connect(select, { doFetchCostInfoForUri })(FilePrice);
+4 -7
View File
@@ -16,7 +16,7 @@ type Props = {
type?: string,
uri: string,
// below props are just passed to <CreditAmount />
customPrices?: { priceFiat: number, priceLBC: number },
customPrice: number,
hideFree?: boolean, // hide the file price if it's free
isFiat?: boolean,
showLBC?: boolean,
@@ -50,10 +50,10 @@ class FilePrice extends React.PureComponent<Props> {
claimWasPurchased,
type,
claimIsMine,
customPrices,
customPrice,
} = this.props;
if (!customPrices && (claimIsMine || !costInfo || !costInfo.cost || (!costInfo.cost && hideFree))) return null;
if (!customPrice && (claimIsMine || !costInfo || !costInfo.cost || (!costInfo.cost && hideFree))) return null;
const className = classnames(claimWasPurchased ? 'filePrice__key' : 'filePrice', {
'filePrice--filepage': type === 'filepage',
@@ -66,10 +66,7 @@ class FilePrice extends React.PureComponent<Props> {
</span>
) : (
<CreditAmount
amount={costInfo ? costInfo.cost : undefined}
customAmounts={
customPrices ? { amountFiat: customPrices.priceFiat, amountLBC: customPrices.priceLBC } : undefined
}
amount={costInfo ? costInfo.cost : customPrice}
className={className}
isEstimate={!!costInfo && !costInfo.includesData}
isFiat={isFiat}
+5 -5
View File
@@ -1,17 +1,17 @@
import { connect } from 'react-redux';
import { makeSelectDownloadPathForUri, makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
import { makeSelectClaimForUri, selectThumbnailForUri, makeSelectContentTypeForUri } from 'redux/selectors/claims';
import { makeSelectClaimForUri, makeSelectThumbnailForUri, makeSelectContentTypeForUri } from 'redux/selectors/claims';
import * as SETTINGS from 'constants/settings';
import { selectClientSetting } from 'redux/selectors/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { makeSelectFileRenderModeForUri, makeSelectFileExtensionForUri } from 'redux/selectors/content';
import FileRender from './view';
const select = (state, props) => {
const autoplay = props.embedded ? false : selectClientSetting(state, SETTINGS.AUTOPLAY_MEDIA);
const autoplay = props.embedded ? false : makeSelectClientSetting(SETTINGS.AUTOPLAY_MEDIA)(state);
return {
currentTheme: selectClientSetting(state, SETTINGS.THEME),
currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state),
claim: makeSelectClaimForUri(props.uri)(state),
thumbnail: selectThumbnailForUri(state, props.uri),
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
contentType: makeSelectContentTypeForUri(props.uri)(state),
downloadPath: makeSelectDownloadPathForUri(props.uri)(state),
fileExtension: makeSelectFileExtensionForUri(props.uri)(state),
+19 -2
View File
@@ -36,6 +36,7 @@ type Props = {
autoplay: boolean,
renderMode: string,
thumbnail: string,
desktopPlayStartTime?: number,
className?: string,
};
@@ -69,13 +70,29 @@ class FileRender extends React.PureComponent<Props> {
}
renderViewer() {
const { currentTheme, contentType, downloadPath, fileExtension, streamingUrl, uri, renderMode } = this.props;
const {
currentTheme,
contentType,
downloadPath,
fileExtension,
streamingUrl,
uri,
renderMode,
desktopPlayStartTime,
} = this.props;
const source = streamingUrl;
switch (renderMode) {
case RENDER_MODES.AUDIO:
case RENDER_MODES.VIDEO:
return <VideoViewer uri={uri} source={source} contentType={contentType} />;
return (
<VideoViewer
uri={uri}
source={source}
contentType={contentType}
desktopPlayStartTime={desktopPlayStartTime}
/>
);
case RENDER_MODES.IMAGE:
return (
<React.Suspense fallback={null}>
+1 -1
View File
@@ -21,7 +21,7 @@ export default function FileRenderDownload(props: Props) {
subtitle={
<p>
{__(
'This content can be downloaded from odysee.com, but not displayed. It will display in LBRY Desktop, an app for desktop computers.'
'This content can be downloaded from lbry.tv, but not displayed. It will display in LBRY Desktop, an app for desktop computers.'
)}
</p>
}
+8 -8
View File
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { selectTitleForUri, selectClaimIsNsfwForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
import { makeSelectTitleForUri, makeSelectClaimIsNsfw, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
import { makeSelectFileInfoForUri, makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
import {
makeSelectNextUrlForCollectionAndUrl,
@@ -12,8 +12,8 @@ import {
selectPlayingUri,
makeSelectFileRenderModeForUri,
} from 'redux/selectors/content';
import { selectClientSetting } from 'redux/selectors/settings';
import { selectCostInfoForUri } from 'lbryinc';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { makeSelectCostInfoForUri } from 'lbryinc';
import { doPlayUri, doSetPlayingUri } from 'redux/actions/content';
import { doFetchRecommendedContent } from 'redux/actions/search';
import { doAnaltyicsPurchaseEvent } from 'redux/actions/app';
@@ -30,15 +30,15 @@ const select = (state, props) => {
uri,
primaryUri,
playingUri,
title: selectTitleForUri(state, uri),
title: makeSelectTitleForUri(uri)(state),
fileInfo: makeSelectFileInfoForUri(uri)(state),
mature: selectClaimIsNsfwForUri(state, uri),
mature: makeSelectClaimIsNsfw(uri)(state),
isFloating: makeSelectIsPlayerFloating(props.location)(state),
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
floatingPlayerEnabled: selectClientSetting(state, SETTINGS.FLOATING_PLAYER),
floatingPlayerEnabled: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
renderMode: makeSelectFileRenderModeForUri(uri)(state),
videoTheaterMode: selectClientSetting(state, SETTINGS.VIDEO_THEATER_MODE),
costInfo: selectCostInfoForUri(state, uri),
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
costInfo: makeSelectCostInfoForUri(uri)(state),
claimWasPurchased: makeSelectClaimWasPurchased(uri)(state),
nextListUri: collectionId && makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state),
previousListUri: collectionId && makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state),
+111 -103
View File
@@ -19,64 +19,9 @@ import { isURIEqual } from 'util/lbryURI';
import AutoplayCountdown from 'component/autoplayCountdown';
const IS_DESKTOP_MAC = typeof process === 'object' ? process.platform === 'darwin' : false;
const DEBOUNCE_WINDOW_RESIZE_HANDLER_MS = 100;
const DEBOUNCE_WINDOW_RESIZE_HANDLER_MS = 60;
export const INLINE_PLAYER_WRAPPER_CLASS = 'inline-player__wrapper';
function getScreenWidth() {
if (document && document.documentElement) {
return document.documentElement.clientWidth;
} else {
return window.innerWidth;
}
}
function getScreenHeight() {
if (document && document.documentElement) {
return document.documentElement.clientHeight;
} else {
return window.innerHeight;
}
}
function getFloatingPlayerRect() {
// TODO: use 'fileViewerRect'?
const FLOATING_PLAYER_CLASS = 'content__viewer--floating';
const elem = document.querySelector(`.${FLOATING_PLAYER_CLASS}`);
if (elem) {
return elem.getBoundingClientRect();
} else {
return null;
}
}
function clampRectToScreen(x, y, rect) {
if (rect) {
const ESTIMATED_SCROLL_BAR_PX = 50;
const screenW = getScreenWidth();
const screenH = getScreenHeight();
if (x + rect.width > screenW - ESTIMATED_SCROLL_BAR_PX) {
x = screenW - rect.width - ESTIMATED_SCROLL_BAR_PX;
}
if (y + rect.height > screenH) {
y = screenH - rect.height;
}
}
return { x, y };
}
function calculateRelativePos(x, y) {
return {
x: x / getScreenWidth(),
y: y / getScreenHeight(),
};
}
// ****************************************************************************
// ****************************************************************************
type Props = {
isFloating: boolean,
fileInfo: FileListItem,
@@ -131,6 +76,7 @@ export default function FileRenderFloating(props: Props) {
const mainFilePlaying = !isFloating && primaryUri && isURIEqual(uri, primaryUri);
const [fileViewerRect, setFileViewerRect] = useState();
const [desktopPlayStartTime, setDesktopPlayStartTime] = useState();
const [wasDragging, setWasDragging] = useState(false);
const [doNavigate, setDoNavigate] = useState(false);
const [playNextUrl, setPlayNextUrl] = useState(true);
@@ -139,7 +85,10 @@ export default function FileRenderFloating(props: Props) {
x: -25,
y: window.innerHeight - 400,
});
const relativePosRef = React.useRef({ x: 0, y: 0 });
const [relativePos, setRelativePos] = useState({
x: 0,
y: 0,
});
const navigateUrl =
playingUri &&
@@ -154,49 +103,93 @@ export default function FileRenderFloating(props: Props) {
? __("It looks like you deleted or moved this file. We're rebuilding it now. It will only take a few seconds.")
: __('Loading');
function restoreToRelativePosition() {
const newX = Math.round(relativePosRef.current.x * getScreenWidth());
const newY = Math.round(relativePosRef.current.y * getScreenHeight());
setPosition(clampRectToScreen(newX, newY, getFloatingPlayerRect()));
function getScreenWidth() {
if (document && document.documentElement) {
return document.documentElement.clientWidth;
} else {
return window.innerWidth;
}
}
const clampToScreenOnResize = React.useCallback(
debounce(() => {
restoreToRelativePosition();
}, DEBOUNCE_WINDOW_RESIZE_HANDLER_MS),
[]
);
function getScreenHeight() {
if (document && document.documentElement) {
return document.documentElement.clientHeight;
} else {
return window.innerHeight;
}
}
// ???
const clampToScreen = React.useCallback((pos) => {
const ESTIMATED_SCROLL_BAR_PX = 50;
const FLOATING_PLAYER_CLASS = 'content__viewer--floating';
const fpPlayerElem = document.querySelector(`.${FLOATING_PLAYER_CLASS}`);
if (fpPlayerElem) {
if (pos.x + fpPlayerElem.getBoundingClientRect().width > getScreenWidth() - ESTIMATED_SCROLL_BAR_PX) {
pos.x = getScreenWidth() - fpPlayerElem.getBoundingClientRect().width - ESTIMATED_SCROLL_BAR_PX;
}
if (pos.y + fpPlayerElem.getBoundingClientRect().height > getScreenHeight()) {
pos.y = getScreenHeight() - fpPlayerElem.getBoundingClientRect().height;
}
}
}, []);
// Updated 'relativePos' based on persisted 'position':
const stringifiedPosition = JSON.stringify(position);
useEffect(() => {
const jsonPosition = JSON.parse(stringifiedPosition);
setRelativePos({
x: jsonPosition.x / getScreenWidth(),
y: jsonPosition.y / getScreenHeight(),
});
}, [stringifiedPosition]);
// Ensure player is within screen when 'isFloating' changes.
useEffect(() => {
const jsonPosition = JSON.parse(stringifiedPosition);
if (isFloating) {
// When the player begins floating, remove the comment source
// so that it doesn't try to resize again in case of going back
// to the origin's comment section and fail to position correctly
if (isComment && playingUri) clearSecondarySource(playingUri.uri);
}
}, [isFloating, isComment, clearSecondarySource, playingUri]);
// Initial update for relativePosRef:
useEffect(() => {
relativePosRef.current = calculateRelativePos(position.x, position.y);
}, []); // eslint-disable-line react-hooks/exhaustive-deps
// Ensure player is within screen when 'isFloating' changes.
useEffect(() => {
if (isFloating) {
restoreToRelativePosition();
let pos = { x: jsonPosition.x, y: jsonPosition.y };
clampToScreen(pos);
if (pos.x !== position.x || pos.y !== position.y) {
setPosition({ x: pos.x, y: pos.y });
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isFloating]);
}, [
clampToScreen,
clearSecondarySource,
isComment,
isFloating,
playingUri,
position.x,
position.y,
setPosition,
stringifiedPosition,
]);
// Listen to main-window resizing and adjust the fp position accordingly:
useEffect(() => {
if (isFloating) {
window.addEventListener('resize', clampToScreenOnResize);
return () => window.removeEventListener('resize', clampToScreenOnResize);
}
}, [isFloating, clampToScreenOnResize]);
const handleMainWindowResize = debounce(() => {
let newPos = {
x: Math.round(relativePos.x * getScreenWidth()),
y: Math.round(relativePos.y * getScreenHeight()),
};
clampToScreen(newPos);
setPosition({ x: newPos.x, y: newPos.y });
}, DEBOUNCE_WINDOW_RESIZE_HANDLER_MS);
window.addEventListener('resize', handleMainWindowResize);
return () => window.removeEventListener('resize', handleMainWindowResize);
// 'relativePos' is needed in the dependency list to avoid stale closure.
// Otherwise, this could just be changed to a one-time effect.
}, [clampToScreen, relativePos.x, relativePos.y, setPosition]);
const handleResize = React.useCallback(() => {
const element = mainFilePlaying
@@ -241,6 +234,18 @@ export default function FileRenderFloating(props: Props) {
};
}, [handleResize]);
useEffect(() => {
// @if TARGET='app'
setDesktopPlayStartTime(Date.now());
// @endif
return () => {
// @if TARGET='app'
setDesktopPlayStartTime(undefined);
// @endif
};
}, [uri]);
useEffect(() => {
if (isFloating) {
doFetchRecommendedContent(uri, mature);
@@ -290,26 +295,24 @@ export default function FileRenderFloating(props: Props) {
}
function handleDragMove(e, ui) {
setWasDragging(true);
const { x, y } = position;
const newX = ui.x;
const newY = ui.y;
// Mark as dragging if the position changed and we were not dragging before.
if (!wasDragging && (newX !== x || newY !== y)) {
setWasDragging(true);
}
const newX = x + ui.deltaX;
const newY = y + ui.deltaY;
setPosition({
x: newX,
y: newY,
});
}
function handleDragStop(e, ui) {
function handleDragStop(e) {
if (wasDragging) {
e.stopPropagation();
setWasDragging(false);
}
let newPos = { x: ui.x, y: ui.y };
if (newPos.x !== position.x || newPos.y !== position.y) {
newPos = clampRectToScreen(newPos.x, newPos.y, getFloatingPlayerRect());
setPosition(newPos);
relativePosRef.current = calculateRelativePos(newPos.x, newPos.y);
setRelativePos({
x: position.x / getScreenWidth(),
y: position.y / getScreenHeight(),
});
}
}
@@ -331,7 +334,6 @@ export default function FileRenderFloating(props: Props) {
'content__viewer--inline': !isFloating,
'content__viewer--secondary': isComment,
'content__viewer--theater-mode': !isFloating && videoTheaterMode,
'content__viewer--disable-click': wasDragging,
})}
style={
!isFloating && fileViewerRect
@@ -361,7 +363,13 @@ export default function FileRenderFloating(props: Props) {
)}
{isReadyToPlay ? (
<FileRender className="draggable" uri={uri} />
<FileRender
className="draggable"
uri={uri}
// @if TARGET='app'
desktopPlayStartTime={desktopPlayStartTime}
// @endif
/>
) : (
<>
{collectionId && !canViewFile ? (
+10 -10
View File
@@ -1,17 +1,17 @@
import { connect } from 'react-redux';
import { doPlayUri, doSetPlayingUri, doSetPrimaryUri } from 'redux/actions/content';
import { selectThumbnailForUri, makeSelectClaimForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
import { makeSelectThumbnailForUri, makeSelectClaimForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
import { makeSelectFileInfoForUri } from 'redux/selectors/file_info';
import * as SETTINGS from 'constants/settings';
import * as COLLECTIONS_CONSTS from 'constants/collections';
import { selectCostInfoForUri } from 'lbryinc';
import { makeSelectCostInfoForUri } from 'lbryinc';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectClientSetting } from 'redux/selectors/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { withRouter } from 'react-router';
import {
makeSelectIsPlaying,
selectShouldObscurePreviewForUri,
selectInsufficientCreditsForUri,
makeSelectShouldObscurePreview,
makeSelectInsufficientCreditsForUri,
makeSelectFileRenderModeForUri,
} from 'redux/selectors/content';
import FileRenderInitiator from './view';
@@ -23,13 +23,13 @@ const select = (state, props) => {
const collectionId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID);
return {
claimThumbnail: selectThumbnailForUri(state, props.uri),
claimThumbnail: makeSelectThumbnailForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
obscurePreview: selectShouldObscurePreviewForUri(state, props.uri),
obscurePreview: makeSelectShouldObscurePreview(props.uri)(state),
isPlaying: makeSelectIsPlaying(props.uri)(state),
insufficientCredits: selectInsufficientCreditsForUri(state, props.uri),
autoplay: selectClientSetting(state, SETTINGS.AUTOPLAY_MEDIA),
costInfo: selectCostInfoForUri(state, props.uri),
insufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY_MEDIA)(state),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
+2 -2
View File
@@ -6,14 +6,14 @@ import { makeSelectFileRenderModeForUri, selectPrimaryUri } from 'redux/selector
import { withRouter } from 'react-router';
import { doAnalyticsView } from 'redux/actions/app';
import FileRenderInline from './view';
import { selectCostInfoForUri } from 'lbryinc';
import { makeSelectCostInfoForUri } from 'lbryinc';
const select = (state, props) => ({
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
isPlaying: selectPrimaryUri(state) === props.uri,
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
costInfo: selectCostInfoForUri(state, props.uri),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
});
+9 -12
View File
@@ -3,30 +3,27 @@ import React from 'react';
import DateTime from 'component/dateTime';
import FileViewCount from 'component/fileViewCount';
import FileActions from 'component/fileActions';
import ClaimPreviewReset from 'component/claimPreviewReset';
type Props = {
uri: string,
livestream?: boolean,
activeViewers?: number,
isLive?: boolean,
};
function FileSubtitle(props: Props) {
const { uri, livestream = false, isLive = false } = props;
const { uri, livestream = false, activeViewers, isLive = false } = props;
return (
<>
<div className="media__subtitle--between">
<div className="file__viewdate">
{livestream ? <span>{__('Right now')}</span> : <DateTime uri={uri} show={DateTime.SHOW_DATE} />}
<div className="media__subtitle--between">
<div className="file__viewdate">
{livestream ? <span>{__('Right now')}</span> : <DateTime uri={uri} show={DateTime.SHOW_DATE} />}
<FileViewCount uri={uri} livestream={livestream} isLive={isLive} />
</div>
<FileActions uri={uri} hideRepost={livestream} livestream={livestream} />
<FileViewCount uri={uri} livestream={livestream} activeViewers={activeViewers} isLive={isLive} />
</div>
{livestream && isLive && <ClaimPreviewReset uri={uri} />}
</>
<FileActions uri={uri} hideRepost={livestream} livestream={livestream} />
</div>
);
}
+2 -2
View File
@@ -1,9 +1,9 @@
import { connect } from 'react-redux';
import { selectTitleForUri } from 'redux/selectors/claims';
import { makeSelectTitleForUri } from 'redux/selectors/claims';
import FileTitleSection from './view';
const select = (state, props) => ({
title: selectTitleForUri(state, props.uri),
title: makeSelectTitleForUri(props.uri)(state),
});
export default connect(select)(FileTitleSection);
+10 -7
View File
@@ -1,18 +1,21 @@
import { connect } from 'react-redux';
import { doFetchSubCount, selectSubCountForUri } from 'lbryinc';
import { selectTitleForUri, selectClaimForUri } from 'redux/selectors/claims';
import { selectInsufficientCreditsForUri } from 'redux/selectors/content';
import { doFetchSubCount, makeSelectSubCountForUri } from 'lbryinc';
import { makeSelectTitleForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
import { makeSelectInsufficientCreditsForUri } from 'redux/selectors/content';
import { makeSelectViewersForId } from 'redux/selectors/livestream';
import FileTitleSection from './view';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
const claim = makeSelectClaimForUri(props.uri)(state);
const viewers = claim && makeSelectViewersForId(claim.claim_id)(state);
const channelClaimId = claim && claim.signing_channel ? claim.signing_channel.claim_id : undefined;
const channelUri = claim && claim.signing_channel ? claim.signing_channel.canonical_url : undefined;
const subCount = channelUri && selectSubCountForUri(state, channelUri);
const subCount = channelUri && makeSelectSubCountForUri(channelUri)(state);
return {
isInsufficientCredits: selectInsufficientCreditsForUri(state, props.uri),
title: selectTitleForUri(state, props.uri),
viewers,
isInsufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
channelClaimId,
subCount,
};
Loaded 100 of 351 files, more files were not shown because too many files have changed in this diff. Show more