Compare commits

..
Author SHA1 Message Date
zeppi 097052a468 check channels and populate notifications and download queue 2022-05-11 16:32:11 -04:00
133 changed files with 1962 additions and 3120 deletions

No files matched your search

+7 -6
View File
@@ -16,7 +16,7 @@ COMMENT_SERVER_NAME=Odysee
SEARCH_SERVER_API=https://lighthouse.odysee.com/search
SOCKETY_SERVER_API=wss://sockety.odysee.com/ws
THUMBNAIL_CDN_URL=https://image-processor.vanwanet.com/optimize/
WELCOME_VERSION=1.2
WELCOME_VERSION=1.1
# STRIPE
# STRIPE_PUBLIC_KEY='pk_test_NoL1JWL7i1ipfhVId5KfDZgo'
@@ -26,15 +26,16 @@ MATOMO_URL=https://analytics.lbry.com/
MATOMO_ID=4
# OG
OG_TITLE_SUFFIX=| lbry.tv
OG_HOMEPAGE_TITLE=lbry.tv
OG_TITLE_SUFFIX=| lbry.com
OG_HOMEPAGE_TITLE=lbry.com
OG_IMAGE_URL=
SITE_CANONICAL_URL=https://lbry.tv
SITE_CANONICAL_URL=https://lbry.com
# UI
## Custom Site info
DOMAIN=lbry.tv
URL=https://lbry.tv
DOMAIN=lbry.com
CLOUD_DOMAIN=odysee.com
URL=https://lbry.com
SITE_TITLE=LBRY
SITE_NAME=LBRY
SITE_DESCRIPTION=Meet LBRY, an open, free, and community-controlled content wonderland.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
-23
View File
@@ -3,29 +3,6 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.53.4] - [2022-06-10]
## Added
- Add top in language category for non-english on homepage ([#7585](https://github.com/lbryio/lbry-desktop/pull/7585))
- Auto hosting in settings and hosting first run page ([#7598](https://github.com/lbryio/lbry-desktop/pull/7598))
### Changed
- Updated lbry-sdk to [0.107.2](https://github.com/lbryio/lbry-sdk/releases/tag/v0.107.2)
## Fixed
- Better handle empty collections ([#7571](https://github.com/lbryio/lbry-desktop/pull/7571))
- Better handle thumbnails in uploads/collections ([#7574](https://github.com/lbryio/lbry-desktop/pull/7574))
- Work towards supporting collections of any claim type ([#7578](https://github.com/lbryio/lbry-desktop/pull/7578))
- Improve handling of downed custom servers on startup ([#7593](https://github.com/lbryio/lbry-desktop/pull/7593))
- Hide watch progress in related if being played ([#7606](https://github.com/lbryio/lbry-desktop/pull/7606))
- IPC disk space calls wait for daemon ready; refresh on vis. component load ([#7610](https://github.com/lbryio/lbry-desktop/pull/7610))
## [0.53.3] - [2022-04-27]
## Fixed
- Reverted lbry.tv changes that broke production login ([#7569](https://github.com/lbryio/lbry-desktop/pull/7569))
- Reverted lbry.tv changes that broke login ([#7570](https://github.com/lbryio/lbry-desktop/pull/7570))
## [0.53.2] - [2022-04-26]
### Changed
+1
View File
@@ -21,6 +21,7 @@ const config = {
WELCOME_VERSION: process.env.WELCOME_VERSION,
DOMAIN: process.env.DOMAIN,
SHARE_DOMAIN_URL: process.env.SHARE_DOMAIN_URL,
CLOUD_DOMAIN: process.env.CLOUD_DOMAIN,
URL: process.env.URL,
THUMBNAIL_CDN_URL: process.env.THUMBNAIL_CDN_URL,
SITE_TITLE: process.env.SITE_TITLE,
-4
View File
@@ -29,10 +29,6 @@
"from": "./static/font",
"to": "static/font",
"filter": ["**/*"]
},
{
"from": "./static/app-update.yml",
"to": "app-update.yml"
}
],
"publish": [
+14 -51
View File
@@ -22,7 +22,6 @@ import { diskSpaceLinux, diskSpaceWindows, diskSpaceMac } from '../ui/util/disks
const { download } = require('electron-dl');
const remote = require('@electron/remote/main');
const os = require('os');
const sudo = require('sudo-prompt');
remote.initialize();
const filePath = path.join(process.resourcesPath, 'static', 'upgradeDisabled');
@@ -34,7 +33,6 @@ try {
upgradeDisabled = false;
}
autoUpdater.autoDownload = !upgradeDisabled;
autoUpdater.allowPrerelease = false;
// This is set to true if an auto update has been downloaded through the Electron
// auto-update system and is ready to install. If the user declined an update earlier,
@@ -52,9 +50,11 @@ let showingAutoUpdateCloseAlert = false;
// https://www.electronjs.org/docs/latest/api/auto-updater#autoupdatercheckforupdates
let keepCheckingForUpdates = true;
let downloadUpgradeInitiated = false;
let downloadUpgradeItem;
// Auto updater doesn't support Linux installations (only trough AppImages)
// this is why, for that case, we download a full executable (.deb package)
// as a fallback support. This variable will be used to prevent
// multiple downloads when auto updater isn't supported.
let downloadUpgradeInProgress = false;
// Keep a global reference, if you don't, they will be closed automatically when the JavaScript
// object is garbage collected.
@@ -323,78 +323,41 @@ ipcMain.on('get-disk-space', async (event) => {
rendererWindow.webContents.send('send-disk-space', { diskSpace });
} catch (e) {
rendererWindow.webContents.send('send-disk-space', { error: e.message || e });
console.log('Failed to get disk space', e);
}
});
ipcMain.on('cancel-download-upgrade', () => {
if (downloadUpgradeItem) {
// Cancel the download and execute the onCancel
// callback set in the options.
downloadUpgradeItem.cancel();
console.log('Failed to start LbryFirst', e);
}
});
ipcMain.on('download-upgrade', async (event, params) => {
// Prevent downloading multiple times.
if (downloadUpgradeInitiated || downloadUpgradeItem) {
if (downloadUpgradeInProgress) {
return;
}
const { url, options } = params;
const dir = fs.mkdtempSync(app.getPath('temp') + path.sep);
downloadUpgradeInitiated = true;
// Grab the download item's handler to allow
// cancelling the operation if required.
options.onStarted = function(downloadItem) {
downloadUpgradeItem = downloadItem;
};
options.onCancel = function() {
downloadUpgradeItem = undefined;
downloadUpgradeInitiated = false;
};
options.onProgress = function(p) {
rendererWindow.webContents.send('download-progress-update', p);
};
options.directory = dir;
options.onCompleted = function(c) {
downloadUpgradeInitiated = false;
downloadUpgradeItem = undefined;
downloadUpgradeInProgress = false;
rendererWindow.webContents.send('download-update-complete', c);
};
const win = BrowserWindow.getFocusedWindow();
downloadUpgradeInProgress = true;
await download(win, url, options).catch(e => console.log('e', e));
});
ipcMain.on('upgrade', (event, installerPath) => {
// what to do if no shutdown in a long time?
console.log('Update downloaded to', installerPath);
console.log('The app will close and you will be prompted to install the latest version of LBRY.');
console.log('After the install is complete, please reopen the app.');
// Prevent .deb package from opening with archive manager (Ubuntu >= 20)
if (process.platform === 'linux' && !process.env.APPIMAGE) {
sudo.exec(`dpkg -i ${installerPath}`, { name: app.name }, (err, stdout, stderr) => {
if (err || stderr) {
rendererWindow.webContents.send('upgrade-installing-error');
return;
}
// Re-launch the application when the installation finishes.
app.relaunch();
app.quit();
});
return;
}
app.on('quit', () => {
console.log('Launching upgrade installer at', installerPath);
// This gets triggered called after *all* other quit-related events, so
// we'll only get here if we're fully prepared and quitting for real.
shell.openPath(installerPath);
});
// what to do if no shutdown in a long time?
console.log('Update downloaded to', installerPath);
console.log('The app will close and you will be prompted to install the latest version of LBRY.');
console.log('After the install is complete, please reopen the app.');
app.quit();
});
+1 -4
View File
@@ -155,10 +155,7 @@ Lbryio.authenticate = (domain, language) => {
.then(
status =>
new Promise((res, rej) => {
const appId =
domain && domain !== 'lbry.tv'
? (domain.replace(/[.]/gi, '') + status.installation_id).slice(0, 66)
: status.installation_id;
const appId = status.installation_id;
Lbryio.call(
'user',
'new',
+1
View File
@@ -67,6 +67,7 @@ declare type GenericMetadata = {
languages?: Array<string>,
tags?: Array<string>,
locations?: Array<Location>,
release_time?: number, // this shouldn't be here, but... fixme?
};
declare type ChannelMetadata = GenericMetadata & {
+2 -2
View File
@@ -8,6 +8,6 @@ declare type WalletServerDetails = {
};
declare type DiskSpace = {
total: number,
free: number,
total: string,
free: string,
};
-1
View File
@@ -22,7 +22,6 @@ declare type RowDataItem = {
channelIds?: Array<string>,
limitClaimsPerChannel?: number,
pageSize?: number,
languages?: Array<string>,
},
route?: string,
hideForUnauth?: boolean,
+3
View File
@@ -16,4 +16,7 @@ declare type SubscriptionState = {
following: Array<Following>,
loading: boolean,
firstRunCompleted: boolean,
downloadEnabledByUrl: any,
downloadQueue: Array<string>,
lastReleaseBySubUrl: any,
};
+3 -5
View File
@@ -1,6 +1,6 @@
{
"name": "lbry",
"version": "0.53.5-alpha.test7495a2",
"version": "0.53.2",
"description": "A browser for the LBRY network, a digital marketplace controlled by its users.",
"keywords": [
"lbry"
@@ -67,7 +67,6 @@
"remove-markdown": "^0.3.0",
"rss": "^1.2.2",
"source-map-explorer": "^2.5.2",
"sudo-prompt": "^9.2.1",
"tempy": "^0.6.0",
"videojs-logo": "^2.1.4"
},
@@ -239,11 +238,10 @@
"yarn": "^1.3"
},
"lbrySettings": {
"lbrynetDaemonVersion": "0.107.2",
"lbrynetDaemonVersion": "0.107.1",
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-OSNAME.zip",
"lbrynetDaemonDir": "static/daemon",
"lbrynetDaemonFileName": "lbrynet"
},
"packageManager": "yarn@3.2.0",
"stableVersion": "0.53.4"
"packageManager": "yarn@3.2.0"
}
+29 -26
View File
@@ -2206,6 +2206,13 @@
"Enabling a minimum amount to comment will force all comments to have tips associated with them. This can help prevent spam.": "Enabling a minimum amount to comment will force all comments to have tips associated with them. This can help prevent spam.",
"Comments containing these words will be blocked.": "Comments containing these words will be blocked.",
"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",
"Disk Space": "Disk Space",
"Data Hosting": "Data Hosting",
"Limit": "Limit",
"Limit Space Used": "Limit Space Used",
"Apply": "Apply",
"Limit in GB": "Limit in GB",
"If you set a limit, playing videos may exceed your limit until cleanup runs every 30 minutes.": "If you set a limit, playing videos may exceed your limit until cleanup runs every 30 minutes.",
"Enable Data Hosting": "Enable Data Hosting",
"Data over the limit will be deleted within 30 minutes. This will make the Yrbl cry a little bit.": "Data over the limit will be deleted within 30 minutes. This will make the Yrbl cry a little bit.",
"Choose %asset%": "Choose %asset%",
@@ -2221,6 +2228,13 @@
"Enable Prerelease Updates": "Enable Prerelease Updates",
"Enable Upgrade to Test Builds": "Enable Upgrade to Test Builds",
"Prereleases may break things and we may not be able to fix them for you.": "Prereleases may break things and we may not be able to fix them for you.",
"Limit (GB)": "Limit (GB)",
"Limit Hosting for Content you Use": "Limit Hosting for Content you Use",
"Allow (GB)": "Allow (GB)",
"Content Data Hosting helps to seed things that you watch and download.": "Content Data Hosting helps to seed things that you watch and download.",
"Network Data Hosting allows the p2p network to store blobs unrelated to your browsing.": "Network Data Hosting allows the p2p network to store blobs unrelated to your browsing.",
"Content: Limit (GB)": "Content: Limit (GB)",
"Network: Allow (GB)": "Network: Allow (GB)",
"A channel is required to repost on LBRY": "A channel is required to repost on LBRY",
"Admin": "Admin",
"Stickers": "Stickers",
@@ -2242,6 +2256,19 @@
"Move Up": "Move Up",
"Move Down": "Move Down",
"Trending for #Game": "Trending for #Game",
"Help the P2P data network by hosting data.": "Help the P2P data network by hosting data.",
"History hosting lets you choose how much storage to use helping content you've consumed.": "History hosting lets you choose how much storage to use helping content you've consumed.",
"Automatic hosting lets you delegate some amount of storage for the network to automatically download ad host.": "Automatic hosting lets you delegate some amount of storage for the network to automatically download ad host.",
"Playing videos may exceed your history hosting limit until cleanup runs every 30 minutes.": "Playing videos may exceed your history hosting limit until cleanup runs every 30 minutes.",
"History: Limit (GB)": "History: Limit (GB)",
"Automatic: Allow (GB)": "Automatic: Allow (GB)",
"Automatic hosting lets you delegate some amount of storage for the network to automatically download and host.": "Automatic hosting lets you delegate some amount of storage for the network to automatically download and host.",
"History Hosting": "History Hosting",
"Automatic Hosting": "Automatic Hosting",
"History Hosting lets you choose how much storage to use helping content you've consumed.": "History Hosting lets you choose how much storage to use helping content you've consumed.",
"Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.": "Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.",
"Help improve the P2P data network (and make LBRY happy) by hosting data.": "Help improve the P2P data network (and make LBRY happy) by hosting data.",
"Limit Hosting of Content History": "Limit Hosting of Content History",
"Remove custom comment server": "Remove custom comment server",
"Use Https": "Use Https",
"Server URL": "Server URL",
@@ -2288,31 +2315,7 @@
"Clear Views": "Clear Views",
"Show Video View Progress": "Show Video View Progress",
"Display view progress on thumbnail. This setting will not hide any blockchain activity or downloads.": "Display view progress on thumbnail. This setting will not hide any blockchain activity or downloads.",
"Content Hosting": "Content Hosting",
"Hosting": "Hosting",
"Viewed Hosting": "Viewed Hosting",
"Auto Hosting": "Auto Hosting",
"Help creators and improve the P2P data network by hosting content.": "Help creators and improve the P2P data network by hosting content.",
"I'm happy with my settings": "I'm happy with my settings",
"We've noticed you already have some settings.": "We've noticed you already have some settings.",
"You choose how much data to host.": "You choose how much data to host.",
"Go back": "Go back",
"Custom Hosting": "Custom Hosting",
"Automatic Hosting (GB)": "Automatic Hosting (GB)",
"* 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.": "* 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.",
"Help improve the P2P data network (and make LBRY users happy) by hosting data.": "Help improve the P2P data network (and make LBRY users happy) by hosting data.",
"View History Hosting lets you choose how much storage to use hosting content you've consumed.": "View History Hosting lets you choose how much storage to use hosting content you've consumed.",
"Automatic Hosting downloads a small portion of content active on the network.": "Automatic Hosting downloads a small portion of content active on the network.",
"Publishes --[legend, storage category]--": "Publishes",
"Auto Hosting --[legend, storage category]--": "Auto Hosting",
"View Hosting --[legend, storage category]--": "View Hosting",
"%spaceUsed% of %limit% GB": "%spaceUsed% of %limit% GB",
"%spaceUsed% of %limit% Free GB": "%spaceUsed% of %limit% Free GB",
"Disabled": "Disabled",
"Free --[legend, unused disk space]--": "Free",
"Top content in %language%": "Top content in %language%",
"Apply": "Apply",
"Installing, please wait...": "Installing, please wait...",
"There was an error during installation. Please, try again.": "There was an error during installation. Please, try again.",
"%anonymous%": "%anonymous%",
"Anon --[used in <%anonymous% Reposted>]--": "Anon",
"--end--": "--end--"
}
-3
View File
@@ -1,3 +0,0 @@
owner: lbryio
repo: lbry-desktop
provider: github
+1 -1
View File
@@ -19,7 +19,7 @@ const WATCHMAN_BACKEND_ENDPOINT = 'https://watchman.na-backend.odysee.com/report
if (isProduction) {
ElectronCookies.enable({
origin: 'https://lbry.tv',
origin: 'https://lbry.com',
});
}
+2 -3
View File
@@ -7,7 +7,6 @@ import { selectUnclaimedRewards } from 'redux/selectors/rewards';
import { doFetchChannelListMine, doFetchCollectionListMine, doResolveUris } from 'redux/actions/claims';
import { selectMyChannelUrls, selectMyChannelClaimIds } from 'redux/selectors/claims';
import * as SETTINGS from 'constants/settings';
import * as MODALS from 'constants/modal_types';
import { selectSubscriptions } from 'redux/selectors/subscriptions';
import {
makeSelectClientSetting,
@@ -25,7 +24,7 @@ import {
import { doGetWalletSyncPreference, doSetLanguage } from 'redux/actions/settings';
import { doSyncLoop } from 'redux/actions/sync';
import {
doOpenModal,
doDownloadUpgradeRequested,
doSignIn,
doGetAndPopulatePreferences,
doSetActiveChannel,
@@ -61,7 +60,7 @@ const perform = (dispatch) => ({
fetchCollectionListMine: () => dispatch(doFetchCollectionListMine()),
setLanguage: (language) => dispatch(doSetLanguage(language)),
signIn: () => dispatch(doSignIn()),
requestDownloadUpgrade: () => dispatch(doOpenModal(MODALS.UPGRADE)),
requestDownloadUpgrade: () => dispatch(doDownloadUpgradeRequested()),
updatePreferences: () => dispatch(doGetAndPopulatePreferences()),
getWalletSyncPref: () => dispatch(doGetWalletSyncPreference()),
syncLoop: (noInterval) => dispatch(doSyncLoop(noInterval)),
+2 -1
View File
@@ -143,6 +143,7 @@ function App(props: Props) {
const shouldMigrateLanguage = LANGUAGE_MIGRATIONS[language];
const hasActiveChannelClaim = activeChannelId !== undefined;
const isPersonalized = hasVerifiedEmail;
const renderFiledrop = isAuthenticated;
useEffect(() => {
if (userId) {
@@ -348,7 +349,7 @@ function App(props: Props) {
>
<Router />
<ModalRouter />
<FileDrop />
{renderFiledrop && <FileDrop />}
<FileRenderFloating />
{isEnhancedLayout && <Yrbl className="yrbl--enhanced" />}
@@ -1,21 +0,0 @@
import { connect } from 'react-redux';
import StorageViz from './view';
import {
selectViewBlobSpace,
selectViewHostingLimit,
selectAutoBlobSpace,
selectPrivateBlobSpace,
selectAutoHostingLimit,
} from 'redux/selectors/settings';
import { selectDiskSpace } from 'redux/selectors/app';
const select = (state) => ({
diskSpace: selectDiskSpace(state),
viewHostingLimit: selectViewHostingLimit(state),
autoHostingLimit: selectAutoHostingLimit(state),
viewBlobSpace: selectViewBlobSpace(state),
autoBlobSpace: selectAutoBlobSpace(state),
privateBlobSpace: selectPrivateBlobSpace(state),
});
export default connect(select)(StorageViz);
@@ -1,130 +0,0 @@
// @flow
import * as React from 'react';
import I18nMessage from 'component/i18nMessage';
import { ipcRenderer } from 'electron';
type Props = {
// --- select ---
diskSpace: DiskSpace, // KB
viewHostingLimit: number, // MB
autoHostingLimit: number,
viewBlobSpace: number,
autoBlobSpace: number,
privateBlobSpace: number,
};
function StorageViz(props: Props) {
const { diskSpace, viewHostingLimit, autoHostingLimit, viewBlobSpace, autoBlobSpace, privateBlobSpace } = props;
React.useEffect(() => {
ipcRenderer.send('get-disk-space');
}, []);
if (!diskSpace || !diskSpace.total) {
return (
<div className={'storage__wrapper'}>
<div className={'storage__bar'}>
<div className="help">{__('Cannot get disk space information.')}</div>
</div>
</div>
);
}
const totalMB = diskSpace && Math.floor(diskSpace.total / 1024);
const freeMB = diskSpace && Math.floor(diskSpace.free / 1024);
const otherMB = totalMB - (freeMB + viewBlobSpace + autoBlobSpace + privateBlobSpace);
const autoFree = autoHostingLimit - autoBlobSpace;
const viewFree = viewHostingLimit > 0 ? viewHostingLimit - viewBlobSpace : freeMB - autoFree;
const unallocFree = freeMB - viewFree - autoFree;
const viewLimit =
viewHostingLimit === 0
? freeMB - (autoHostingLimit - autoBlobSpace) + viewBlobSpace
: viewHostingLimit + viewBlobSpace;
const getPercent = (val, lim = totalMB) => (val / lim) * 100;
const getGB = (val) => (Number(val) / 1024).toFixed(2);
const otherPercent = getPercent(otherMB);
const privatePercent = getPercent(privateBlobSpace);
const autoLimitPercent = getPercent(autoHostingLimit);
const viewLimitPercent = getPercent(viewLimit);
const viewUsedPercentOfLimit = getPercent(viewBlobSpace, viewLimit);
const autoUsedPercentOfLimit = getPercent(autoBlobSpace, autoHostingLimit);
return (
<div className={'storage__wrapper'}>
<div className={'storage__bar'}>
<div className={'storage__other'} style={{ width: `${otherPercent}%` }} />
<div className={'storage__private'} style={{ width: `${privatePercent}%` }} />
<div className={'storage__auto'} style={{ width: `${autoLimitPercent}%` }}>
<div className={'storage__auto--used'} style={{ width: `${autoUsedPercentOfLimit}%` }} />
<div className={'storage__auto--free'} />
</div>
<div className={'storage__viewed'} style={{ width: `${viewLimitPercent}%` }}>
<div className={'storage__viewed--used'} style={{ width: `${viewUsedPercentOfLimit}%` }} />
<div className={'storage__viewed--free'} />
</div>
{viewHostingLimit !== 0 && <div style={{ 'background-color': 'unset' }} />}
</div>
<div className={'storage__legend-wrapper'}>
<div className={'storage__legend-item'}>
<div className={'storage__legend-item-swatch storage__legend-item-swatch--private'} />
<div className={'storage__legend-item-label'}>
<label>{__('Publishes --[legend, storage category]--')}</label>
<div className={'help'}>{`${getGB(privateBlobSpace)} GB`}</div>
</div>
</div>
<div className={'storage__legend-item'}>
<div className={'storage__legend-item-swatch storage__legend-item-swatch--auto'} />
<div className={'storage__legend-item-label'}>
<label>{__('Auto Hosting --[legend, storage category]--')}</label>
<div className={'help'}>
{autoHostingLimit === 0 ? (
__('Disabled')
) : (
<I18nMessage
tokens={{
spaceUsed: getGB(autoBlobSpace),
limit: getGB(autoHostingLimit),
}}
>
%spaceUsed% of %limit% GB
</I18nMessage>
)}
</div>
</div>
</div>
<div className={'storage__legend-item'}>
<div className={'storage__legend-item-swatch storage__legend-item-swatch--viewed'} />
<div className={'storage__legend-item-label'}>
<label>{__('View Hosting --[legend, storage category]--')}</label>
<div className={'help'}>
{viewHostingLimit === 1 ? (
__('Disabled')
) : (
<I18nMessage
tokens={{
spaceUsed: getGB(viewBlobSpace),
limit: viewHostingLimit !== 0 ? getGB(viewHostingLimit) : getGB(viewFree),
}}
>
%spaceUsed% of %limit% Free GB
</I18nMessage>
)}
</div>
</div>
</div>
{viewHostingLimit !== 0 && (
<div className={'storage__legend-item'}>
<div className={'storage__legend-item-swatch storage__legend-item-swatch--free'} />
<div className={'storage__legend-item-label'}>
<label>{__('Free --[legend, unused disk space]--')}</label>
<div className={'help'}>{`${getGB(unallocFree)} GB`}</div>
</div>
</div>
)}
</div>
</div>
);
}
export default StorageViz;
+1 -2
View File
@@ -6,7 +6,6 @@ import CreditAmount from 'component/common/credit-amount';
import DateTime from 'component/dateTime';
import YoutubeBadge from 'component/youtubeBadge';
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
import { formatNumber } from 'util/number';
type Props = {
claim: ChannelClaim,
@@ -75,7 +74,7 @@ function ChannelAbout(props: Props) {
</div>
<label>{__('Total Uploads')}</label>
<div className="media__info-text">{formatNumber(claim.meta.claims_in_channel || 0, 2, true)}</div>
<div className="media__info-text">{claim.meta.claims_in_channel}</div>
<label>{__('Last Updated')}</label>
<div className="media__info-text">
+12 -19
View File
@@ -110,11 +110,6 @@ function ClaimMenuList(props: Props) {
const [doShuffle, setDoShuffle] = React.useState(false);
const incognitoClaim = contentChannelUri && !contentChannelUri.includes('@');
const isChannel = !incognitoClaim && !contentSigningChannel;
// $FlowFixMe
const claimLength = claim && claim.value && claim.value.claims && claim.value.claims.length;
// $FlowFixMe
const claimCount = editedCollection ? editedCollection.items.length : claimLength;
const isEmptyCollection = (Number(claimCount) || 0) <= 0;
const { channelName } = parseURI(contentChannelUri);
const showDelete = claimIsMine || (fileInfo && (fileInfo.written_bytes > 0 || fileInfo.blobs_completed > 0));
const subscriptionLabel = repostedClaim
@@ -302,20 +297,18 @@ function ClaimMenuList(props: Props) {
{__('View List')}
</a>
</MenuItem>
{!isEmptyCollection && (
<MenuItem
className="comment__menu-option"
onSelect={() => {
if (!resolvedList) fetchItems();
setDoShuffle(true);
}}
>
<div className="menu__link">
<Icon aria-hidden icon={ICONS.SHUFFLE} />
{__('Shuffle Play')}
</div>
</MenuItem>
)}
<MenuItem
className="comment__menu-option"
onSelect={() => {
if (!resolvedList) fetchItems();
setDoShuffle(true);
}}
>
<div className="menu__link">
<Icon aria-hidden icon={ICONS.SHUFFLE} />
{__('Shuffle Play')}
</div>
</MenuItem>
{isMyCollection && (
<>
<MenuItem
+4 -3
View File
@@ -9,7 +9,7 @@ import * as COLLECTIONS_CONSTS from 'constants/collections';
import { isChannelClaim } from 'util/claim';
import { formatLbryUrlForWeb } from 'util/url';
import { formatClaimPreviewTitle } from 'util/formatAriaLabel';
import { formatNumber } from 'util/number';
import { toCompactNotation } from 'util/string';
import Tooltip from 'component/common/tooltip';
import FileThumbnail from 'component/fileThumbnail';
import UriIndicator from 'component/uriIndicator';
@@ -138,6 +138,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
indexInContainer,
channelSubCount,
swipeLayout = false,
lang,
showEdit,
dragHandleProps,
unavailableUris,
@@ -161,8 +162,8 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
if (channelSubCount === undefined) {
return <span />;
}
const formattedSubCount = formatNumber(channelSubCount, 2, true);
const formattedSubCountLocale = formatNumber(channelSubCount, 2, false);
const formattedSubCount = toCompactNotation(channelSubCount, lang, 10000);
const formattedSubCountLocale = Number(channelSubCount).toLocaleString();
return (
<div className="media__subtitle">
<Tooltip title={formattedSubCountLocale} followCursor placement="top">
+1 -2
View File
@@ -5,7 +5,6 @@ import DateTime from 'component/dateTime';
import Button from 'component/button';
import FileViewCountInline from 'component/fileViewCountInline';
import { parseURI } from 'util/lbryURI';
import { formatNumber } from 'util/number';
type Props = {
uri: string,
@@ -35,7 +34,7 @@ function ClaimPreviewSubtitle(props: Props) {
<>
{isChannel &&
type !== 'inline' &&
`${formatNumber(claimsInChannel, 2, true)} ${claimsInChannel === 1 ? __('upload') : __('uploads')}`}
`${claimsInChannel} ${claimsInChannel === 1 ? __('upload') : __('uploads')}`}
{!isChannel && (
<>
-6
View File
@@ -54,13 +54,9 @@ function CollectionActions(props: Props) {
const isMobile = useIsMobile();
const claimId = claim && claim.claim_id;
const webShareable = true; // collections have cost?
const isEmptyCollection = !firstItem;
const doPlay = React.useCallback(
(playUri) => {
if (!playUri) {
return;
}
const navigateUrl = formatLbryUrlForWeb(playUri);
push({
pathname: navigateUrl,
@@ -85,7 +81,6 @@ function CollectionActions(props: Props) {
icon={ICONS.PLAY}
label={__('Play')}
title={__('Play')}
disabled={isEmptyCollection}
onClick={() => {
doToggleShuffleList(collectionId, false);
doPlay(firstItem);
@@ -96,7 +91,6 @@ function CollectionActions(props: Props) {
icon={ICONS.SHUFFLE}
label={__('Shuffle Play')}
title={__('Shuffle Play')}
disabled={isEmptyCollection}
onClick={() => {
doToggleShuffleList(collectionId, true);
setDoShuffle(true);
-2
View File
@@ -23,7 +23,6 @@ import CollectionForm from './view';
import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
import { doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
import { doCollectionEdit } from 'redux/actions/collections';
import { doResetThumbnailStatus } from 'redux/actions/publish';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
@@ -53,7 +52,6 @@ const perform = (dispatch, ownProps) => ({
setActiveChannel: (claimId) => dispatch(doSetActiveChannel(claimId)),
setIncognito: (incognito) => dispatch(doSetIncognito(incognito)),
doCollectionEdit: (params) => dispatch(doCollectionEdit(ownProps.collectionId, params)),
resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()),
});
export default connect(select, perform)(CollectionForm);
+3 -10
View File
@@ -58,7 +58,6 @@ type Props = {
setActiveChannel: (string) => void,
setIncognito: (boolean) => void,
doCollectionEdit: (CollectionEditParams) => void,
resetThumbnailStatus: () => void,
};
function CollectionForm(props: Props) {
@@ -93,7 +92,6 @@ function CollectionForm(props: Props) {
setIncognito,
onDone,
doCollectionEdit,
resetThumbnailStatus,
} = props;
const activeChannelName = activeChannelClaim && activeChannelClaim.name;
let prefix = 'lbry://';
@@ -160,7 +158,7 @@ function CollectionForm(props: Props) {
}
function handleUpdateThumbnail(update: { [string]: string }) {
if (update.thumbnail_url !== undefined) {
if (update.thumbnail_url) {
setParam(update);
} else if (update.thumbnail_status) {
setThumbStatus(update.thumbnail_status);
@@ -311,10 +309,6 @@ function CollectionForm(props: Props) {
}
}, [uri, hasClaim]);
React.useEffect(() => {
resetThumbnailStatus();
}, [resetThumbnailStatus]);
return (
<>
<div className={classnames('main--contained', { 'card--disabled': disabled })}>
@@ -364,11 +358,10 @@ function CollectionForm(props: Props) {
/>
<fieldset-section>
<SelectThumbnail
thumbnail={params.thumbnail_url}
thumbnailError={thumbError}
thumbnailParam={params.thumbnail_url}
thumbnailParamError={thumbError}
thumbnailParamStatus={thumbStatus}
updateThumbnailParams={handleUpdateThumbnail}
usePublishFormMode
/>
</fieldset-section>
<FormField
@@ -33,7 +33,7 @@ function CollectionPreviewOverlay(props: Props) {
collectionItemUrls.map((item, index) => {
if (index < 2) {
return (
<div key={item} className="collection-preview__overlay-grid-items">
<div className="collection-preview__overlay-grid-items">
<FileThumbnail uri={item} key={item} />
</div>
);
+2 -2
View File
@@ -95,7 +95,7 @@ export default function CollectionsListMine(props: Props) {
{builtin.map((list: Collection) => {
const { items: itemUrls } = list;
return (
<React.Fragment key={list.name}>
<>
{Boolean(itemUrls && itemUrls.length) && (
<div className="claim-grid__wrapper" key={list.name}>
<h1 className="claim-grid__header">
@@ -124,7 +124,7 @@ export default function CollectionsListMine(props: Props) {
<ClaimList tileLayout key={list.name} uris={itemUrls.slice(0, 6)} collectionId={list.id} />
</div>
)}
</React.Fragment>
</>
);
})}
<div className="claim-grid__wrapper">
+1 -2
View File
@@ -8,7 +8,6 @@ import { FF_MAX_CHARS_IN_COMMENT } from 'constants/form-field';
import { SITE_NAME, ENABLE_COMMENT_REACTIONS } from 'config';
import React, { useEffect, useState } from 'react';
import { parseURI } from 'util/lbryURI';
import { formatNumber } from 'util/number';
import DateTime from 'component/dateTime';
import Button from 'component/button';
import Expandable from 'component/expandable';
@@ -385,7 +384,7 @@ function CommentView(props: Props) {
label={
numDirectReplies < 2
? __('Show reply')
: __('Show %count% replies', { count: formatNumber(numDirectReplies, 2, true) })
: __('Show %count% replies', { count: numDirectReplies })
}
button="link"
onClick={() => {
+2 -11
View File
@@ -9,7 +9,6 @@ import Button from 'component/button';
import ChannelThumbnail from 'component/channelThumbnail';
import { useHistory } from 'react-router';
import { useIsMobile } from 'effects/use-screensize';
import { formatNumber } from 'util/number';
type Props = {
myReacts: Array<string>,
@@ -110,11 +109,7 @@ export default function CommentReactions(props: Props) {
'comment__action--active': myReacts && myReacts.includes(REACTION_TYPES.LIKE),
})}
onClick={handleCommentLike}
label={
<span className="comment__reaction-count">
{formatNumber(getCountForReact(REACTION_TYPES.LIKE), 2, true)}
</span>
}
label={<span className="comment__reaction-count">{getCountForReact(REACTION_TYPES.LIKE)}</span>}
/>
<Button
title={__('Downvote')}
@@ -124,11 +119,7 @@ export default function CommentReactions(props: Props) {
'comment__action--active': myReacts && myReacts.includes(REACTION_TYPES.DISLIKE),
})}
onClick={handleCommentDislike}
label={
<span className="comment__reaction-count">
{formatNumber(getCountForReact(REACTION_TYPES.DISLIKE), 2, true)}
</span>
}
label={<span className="comment__reaction-count">{getCountForReact(REACTION_TYPES.DISLIKE)}</span>}
/>
{!shouldHide && ENABLE_CREATOR_REACTIONS && (canCreatorReact || creatorLiked) && (
+24
View File
@@ -2054,4 +2054,28 @@ export const icons = {
<path d="M12.5,23.24v-1A10.74,10.74,0,0,1,23.24,11.52" />
</g>
),
[ICONS.HOST]: buildIcon(
<g>
<path d="M9 22.5 12 9l3 13.5" />
<circle cx={12} cy={7.657} r={1.25} />
<path
fillRule="evenodd"
clipRule="evenodd"
d="M4 7.657c0-2.21.895-4.21 2.343-5.657l1.06 1.06A6.48 6.48 0 0 0 5.5 7.658a6.48 6.48 0 0 0 1.904 4.596l-1.06 1.06A7.975 7.975 0 0 1 4 7.658Zm13.657 5.657A7.975 7.975 0 0 0 20 7.657c0-2.21-.895-4.21-2.343-5.657l-1.06 1.06A6.48 6.48 0 0 1 18.5 7.658a6.48 6.48 0 0 1-1.904 4.596l1.06 1.06Z"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M7 7.657c0-1.38.56-2.63 1.464-3.536l1.061 1.061A3.49 3.49 0 0 0 8.5 7.657c0 .966.392 1.841 1.025 2.475l-1.06 1.06A4.984 4.984 0 0 1 7 7.657Zm8.536 3.535A4.984 4.984 0 0 0 17 7.657c0-1.38-.56-2.63-1.464-3.536l-1.061 1.061A3.49 3.49 0 0 1 15.5 7.657a3.49 3.49 0 0 1-1.025 2.475l1.06 1.06Z"
/>
<path d="M2 22h20" />
</g>
),
[ICONS.NO_HOST]: buildIcon(
<g>
<path d="M9 22.5 12 9l3 13.5" />
<circle cx={12} cy={7.657} r={1.25} />
<path d="M2 22h20" />
</g>
),
};
+13 -5
View File
@@ -4,7 +4,7 @@ import * as ICONS from 'constants/icons';
import React from 'react';
import classnames from 'classnames';
import Button from 'component/button';
import { formatNumber } from 'util/number';
import { formatNumberWithCommas } from 'util/number';
import NudgeFloating from 'component/nudgeFloating';
type Props = {
claim: StreamClaim,
@@ -18,8 +18,16 @@ type Props = {
};
function FileReactions(props: Props) {
const { claim, uri, doFetchReactions, doReactionLike, doReactionDislike, myReaction, likeCount, dislikeCount } =
props;
const {
claim,
uri,
doFetchReactions,
doReactionLike,
doReactionDislike,
myReaction,
likeCount,
dislikeCount,
} = props;
const claimId = claim && claim.claim_id;
const channel = claim && claim.signing_channel && claim.signing_channel.name;
@@ -51,7 +59,7 @@ function FileReactions(props: Props) {
className={classnames('button--file-action button-like', {
'button--file-action-active': myReaction === REACTION_TYPES.LIKE,
})}
label={<>{formatNumber(likeCount, 2, true)}</>}
label={<>{formatNumberWithCommas(likeCount, 0)}</>}
iconSize={18}
icon={likeIcon}
onClick={() => doReactionLike(uri)}
@@ -62,7 +70,7 @@ function FileReactions(props: Props) {
className={classnames('button--file-action button-dislike', {
'button--file-action-active': myReaction === REACTION_TYPES.DISLIKE,
})}
label={<>{formatNumber(dislikeCount, 2, true)}</>}
label={<>{formatNumberWithCommas(dislikeCount, 0)}</>}
iconSize={18}
icon={dislikeIcon}
onClick={() => doReactionDislike(uri)}
+2 -11
View File
@@ -1,25 +1,16 @@
import { connect } from 'react-redux';
import { doResolveUri } from 'redux/actions/claims';
import { makeSelectClaimForUri } from 'redux/selectors/claims';
import { selectPrimaryUri, makeSelectContentWatchedPercentageForUri } from 'redux/selectors/content';
import { makeSelectContentWatchedPercentageForUri } from 'redux/selectors/content';
import CardMedia from './view';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import * as SETTINGS from 'constants/settings';
const select = (state, props) => {
const claimUriBeingPlayed = selectPrimaryUri(state);
let isBeingPlayed = false;
if (claimUriBeingPlayed) {
const claim = makeSelectClaimForUri(props.uri)(state);
const claimBeingPlayed = makeSelectClaimForUri(claimUriBeingPlayed)(state);
isBeingPlayed = claim.claim_id === claimBeingPlayed.claim_id;
}
return {
watchedPercentage: makeSelectContentWatchedPercentageForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
showPercentage: !isBeingPlayed && makeSelectClientSetting(SETTINGS.PERSIST_WATCH_TIME)(state),
showPercentage: makeSelectClientSetting(SETTINGS.PERSIST_WATCH_TIME)(state),
};
};
+4 -4
View File
@@ -2,7 +2,7 @@
import React from 'react';
import HelpLink from 'component/common/help-link';
import Tooltip from 'component/common/tooltip';
import { formatNumber } from 'util/number';
import { toCompactNotation } from 'util/string';
type Props = {
claimId: ?string, // this
@@ -14,8 +14,8 @@ type Props = {
function FileViewCount(props: Props) {
const { claimId, uri, fetchViewCount, viewCount } = props; // claimId
const countCompact = formatNumber(Number(viewCount), 2, true);
const countFullResolution = formatNumber(Number(viewCount), 2, false);
const countCompact = toCompactNotation(viewCount);
const countFullResolution = Number(viewCount).toLocaleString();
React.useEffect(() => {
if (claimId) {
@@ -24,7 +24,7 @@ function FileViewCount(props: Props) {
}, [fetchViewCount, uri, claimId]);
return (
<Tooltip title={`${countFullResolution}`}>
<Tooltip label={countFullResolution}>
<span className="media__subtitle--centered">
{viewCount !== 1 ? __('%view_count% views', { view_count: countCompact }) : __('1 view')}
{<HelpLink href="https://lbry.com/faq/views" />}
+2 -8
View File
@@ -1,7 +1,4 @@
// @flow
// import 'scss/component/_header.scss'; // ody codesplits this; no.
import { ENABLE_UI_NOTIFICATIONS } from 'config';
import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button';
import * as ICONS from 'constants/icons';
import * as PAGES from 'constants/pages';
@@ -15,14 +12,11 @@ type HeaderMenuButtonProps = {
authenticated: boolean,
automaticDarkModeEnabled: boolean,
currentTheme: string,
user: ?User,
handleThemeToggle: (boolean, string) => void,
};
export default function HeaderMenuButtons(props: HeaderMenuButtonProps) {
const { automaticDarkModeEnabled, currentTheme, user, handleThemeToggle } = props;
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
const { automaticDarkModeEnabled, currentTheme, handleThemeToggle } = props;
return (
<div className="header__buttons">
@@ -39,7 +33,7 @@ export default function HeaderMenuButtons(props: HeaderMenuButtonProps) {
</MenuList>
</Menu>
{notificationsEnabled && <NotificationHeaderButton />}
<NotificationHeaderButton />
<Menu>
<Tooltip title={__('Settings')}>
@@ -1,14 +1,16 @@
import { connect } from 'react-redux';
import { selectUnseenNotificationCount } from 'redux/selectors/notifications';
import { doSeeAllNotifications } from 'redux/actions/notifications';
import { selectUnseenNotificationCount, selectUnseenLocalNotificationCount } from 'redux/selectors/notifications';
import { doLbryioSeeAllNotifications, doLocalSeeAllNotifications } from 'redux/actions/notifications';
import { selectUser } from 'redux/selectors/user';
import NotificationHeaderButton from './view';
const select = (state) => ({
unseenCount: selectUnseenNotificationCount(state),
unseenLocalCount: selectUnseenLocalNotificationCount(state),
user: selectUser(state),
});
export default connect(select, {
doSeeAllNotifications,
doLbryioSeeAllNotifications,
doLocalSeeAllNotifications,
})(NotificationHeaderButton);
+6 -10
View File
@@ -1,7 +1,4 @@
// @flow
// import 'scss/component/_header.scss'; // ody codesplits this; no. REMOVE THESE
import { ENABLE_UI_NOTIFICATIONS } from 'config';
import { useHistory } from 'react-router';
import * as ICONS from 'constants/icons';
import * as PAGES from 'constants/pages';
@@ -13,23 +10,22 @@ import Tooltip from 'component/common/tooltip';
type Props = {
unseenCount: number,
user: ?User,
doSeeAllNotifications: () => void,
unseenLocalCount: number,
doLbryioSeeAllNotifications: () => void,
doLocalSeeAllNotifications: () => void,
};
export default function NotificationHeaderButton(props: Props) {
const { unseenCount, user, doSeeAllNotifications } = props;
const { unseenCount, unseenLocalCount, doLbryioSeeAllNotifications, doLocalSeeAllNotifications } = props;
const { push } = useHistory();
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
function handleMenuClick() {
if (unseenCount > 0) doSeeAllNotifications();
if (unseenCount > 0) doLbryioSeeAllNotifications();
if (unseenLocalCount > 0) doLocalSeeAllNotifications();
push(`/$/${PAGES.NOTIFICATIONS}`);
}
if (!notificationsEnabled) return null;
return (
<Tooltip title={__('Notifications')}>
<Button onClick={handleMenuClick} className="header__navigationItem--icon">
-27
View File
@@ -1,27 +0,0 @@
import { connect } from 'react-redux';
import HostingSplash from './view';
import {
selectViewBlobSpace,
selectViewHostingLimit,
selectAutoBlobSpace,
selectAutoHostingLimit,
selectSaveBlobs,
} from 'redux/selectors/settings';
import { doSetDaemonSetting } from 'redux/actions/settings';
import { selectDiskSpace } from 'redux/selectors/app';
const select = (state) => ({
diskSpace: selectDiskSpace(state),
viewHostingLimit: selectViewHostingLimit(state),
autoHostingLimit: selectAutoHostingLimit(state),
viewBlobSpace: selectViewBlobSpace(state),
autoBlobSpace: selectAutoBlobSpace(state),
saveBlobs: selectSaveBlobs(state),
});
const perform = (dispatch) => ({
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
});
export default connect(select, perform)(HostingSplash);
-156
View File
@@ -1,156 +0,0 @@
// @flow
import React from 'react';
import Button from 'component/button';
import { FormField } from 'component/common/form-components/form-field';
import { Form } from 'component/common/form-components/form';
import { withRouter } from 'react-router-dom';
// $FlowFixMe cannot resolve ...
import image from 'static/img/yrblhappy.svg';
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
type SetDaemonSettingArg = boolean | string | number;
type Props = {
handleNextPage: () => void,
handleDone: () => void,
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
// --- select ---
diskSpace: DiskSpace, // KB
viewHostingLimit: number, // MB
autoHostingLimit: number,
viewBlobSpace: number,
autoBlobSpace: number,
privateBlobSpace: number,
saveBlobs: boolean,
};
const TWENTY_PERCENT = 0.2;
const TEN_PRECNT = 0.1;
function HostingSplash(props: Props) {
const {
handleNextPage,
diskSpace,
viewHostingLimit,
autoHostingLimit,
viewBlobSpace,
autoBlobSpace,
saveBlobs,
setDaemonSetting,
handleDone,
} = props;
const totalMB = diskSpace && Math.floor(diskSpace.total / 1024);
const freeMB = diskSpace && Math.floor(diskSpace.free / 1024);
const blobSpaceUsed = viewBlobSpace + autoBlobSpace;
const [hostingChoice, setHostingChoice] = React.useState('MANAGED');
function handleSubmit() {
if (hostingChoice === 'CUSTOM') {
handleNextPage();
} else {
handleAuto();
}
}
function getManagedLimitMB() {
const value =
freeMB > totalMB * TWENTY_PERCENT // lots of free space?
? blobSpaceUsed > totalMB * TEN_PRECNT // using more than 10%?
? (freeMB + blobSpaceUsed) / 2 // e.g. 40g used plus 30g free, knock back to 35g limit, freeing to 35g
: totalMB * TEN_PRECNT // let it go up to 10%
: (freeMB + blobSpaceUsed) / 2; // e.g. 40g used plus 10g free, knock back to 25g limit, freeing to 25g
return value > 10240 ? Math.floor(value / 1024) * 1024 : 0;
}
function getAutoLimit() {
// return floor of 10% of total
const totalGB = Math.floor(getManagedLimitMB() / 1024); // eg, 25GB
return Math.floor(totalGB / 10) * 1024; // eg, 2 GB -> 2048MB
}
function getViewedLimit() {
return getManagedLimitMB() - getAutoLimit();
}
function getManagedCopy() {
if (viewHostingLimit || autoHostingLimit || !saveBlobs) {
return __("I'm happy with my settings");
} else if (getManagedLimitMB() > 0) {
return __(`Host up to %percent% of my drive (%limit% GB)`, {
percent: `${Math.round((Math.floor(getManagedLimitMB() / 1024) / Math.floor(totalMB / 1024)) * 100)}%`,
limit: Math.floor(getManagedLimitMB() / 1024),
});
} else {
return __(`Not now, my disk is almost full.`);
}
}
function getManagedHelper() {
if (viewHostingLimit || autoHostingLimit || !saveBlobs) {
return __(`We've noticed you already have some settings.`);
} else if (getManagedLimitMB() > 0) {
return __(`Donate space without filling up your drive.`);
} else {
return __(`You can clear some space and check hosting settings later.`);
}
}
async function handleAuto() {
if (viewHostingLimit || autoHostingLimit || !saveBlobs) {
handleDone();
} else if (getManagedLimitMB() > 0) {
// limit to used // maybe move this to a single action function that doesn't live inside the component.
await setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, getViewedLimit());
await setDaemonSetting(DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB, getAutoLimit());
handleDone();
} else {
// running low on space
handleDone();
}
}
return (
<section className="main--contained">
<div className={'columns first-run__wrapper'}>
<div className={'first-run__left'}>
<div>
<h1 className="section__title--large">{__('Hosting')}</h1>
<h3 className="section__subtitle">
{__('Help creators and improve the P2P data network by hosting content.')}
</h3>
<fieldset>
<FormField
name={'managedhosting'}
type="radio"
checked={hostingChoice === 'MANAGED'}
label={getManagedCopy()}
helper={getManagedHelper()}
onChange={(e) => setHostingChoice('MANAGED')}
/>
<FormField
name={'customhosting'}
type="radio"
checked={hostingChoice === 'CUSTOM'}
label={<>{__('Custom')}</>}
helper={__(`You choose how much data to host.`)}
onChange={(e) => setHostingChoice('CUSTOM')}
/>
</fieldset>
</div>
<Form onSubmit={handleSubmit} className="section__body">
<div className={'card__actions'}>
<Button button="primary" label={hostingChoice === 'CUSTOM' ? __('Next') : __(`Let's go`)} type="submit" />
</div>
</Form>
</div>
<div className={'first-run__image-wrapper'}>
<img src={image} className="privacy-img" />
</div>
</div>
</section>
);
}
export default withRouter(HostingSplash);
@@ -1,3 +0,0 @@
import HostingSplashCustom from './view';
export default HostingSplashCustom;
-31
View File
@@ -1,31 +0,0 @@
// @flow
import React from 'react';
import Button from 'component/button';
import { Form } from 'component/common/form-components/form';
import SettingStorage from 'component/settingStorage';
import { withRouter } from 'react-router-dom';
type Props = {
handleNextPage: () => void,
handleGoBack: () => void,
};
function HostingSplashCustom(props: Props) {
const { handleNextPage, handleGoBack } = props;
return (
<section className="main--contained">
<div className={'first-run__wrapper'}>
<SettingStorage isWelcome />
<Form onSubmit={handleNextPage} className="section__body">
<div className={'card__actions'}>
<Button button="primary" label={__(`Let's go`)} type="submit" />
<Button button="link" label={__(`Go back`)} onClick={handleGoBack} />
</div>
</Form>
</div>
</section>
);
}
export default withRouter(HostingSplashCustom);
+1 -9
View File
@@ -1,11 +1,3 @@
import { connect } from 'react-redux';
import { selectRemoteVersion } from 'redux/selectors/app';
import LastReleaseChanges from './view';
const select = (state) => ({
releaseVersion: selectRemoteVersion(state),
});
const perform = {};
export default connect(select, perform)(LastReleaseChanges);
export default LastReleaseChanges;
+3 -4
View File
@@ -5,12 +5,11 @@ import Button from 'component/button';
import I18nMessage from 'component/i18nMessage';
type Props = {
releaseVersion: string,
hideReleaseVersion?: boolean,
};
const LastReleaseChanges = (props: Props) => {
const { hideReleaseVersion, releaseVersion } = props;
const { hideReleaseVersion } = props;
const [releaseTag, setReleaseTag] = useState('');
const [releaseChanges, setReleaseChanges] = useState('');
const [fetchingReleaseChanges, setFetchingReleaseChanges] = useState(false);
@@ -36,7 +35,7 @@ const LastReleaseChanges = (props: Props) => {
);
useEffect(() => {
const lastReleaseUrl = `https://api.github.com/repos/lbryio/lbry-desktop/releases/tags/${releaseVersion}`;
const lastReleaseUrl = 'https://api.github.com/repos/lbryio/lbry-desktop/releases/latest';
const options = {
method: 'GET',
headers: { Accept: 'application/vnd.github.v3+json' },
@@ -55,7 +54,7 @@ const LastReleaseChanges = (props: Props) => {
setFetchingReleaseChanges(false);
setFetchReleaseFailed(true);
});
}, [releaseVersion, setFetchingReleaseChanges, setReleaseTag, setReleaseChanges, setFetchReleaseFailed]);
}, []);
if (fetchingReleaseChanges) {
return <p>{__('Loading...')}</p>;
+8 -3
View File
@@ -1,10 +1,15 @@
import { connect } from 'react-redux';
import { doReadNotifications, doDeleteNotification } from 'redux/actions/notifications';
import {
doLbryioNotificationsMarkRead,
doLbryioDeleteNotification,
doLocalDeleteNotification,
} from 'redux/actions/notifications';
import Notification from './view';
const perform = (dispatch, ownProps) => ({
readNotification: () => dispatch(doReadNotifications([ownProps.notification.id])),
deleteNotification: () => dispatch(doDeleteNotification(ownProps.notification.id)),
readNotification: () => dispatch(doLbryioNotificationsMarkRead([ownProps.notification.id])),
deleteNotification: () => dispatch(doLbryioDeleteNotification(ownProps.notification.id)),
deleteLocalNotification: () => dispatch(doLocalDeleteNotification(ownProps.notification.id)),
});
export default connect(null, perform)(Notification);
+4 -4
View File
@@ -72,9 +72,9 @@ function PrivacyAgreement(props: Props) {
{__('No')} <span>😢</span>
</>
}
helper={__(
`* 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.`
)}
helper={__(`* 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.`)}
onChange={(e) => setShare(NONE)}
/>
{authenticated && (
@@ -92,7 +92,7 @@ function PrivacyAgreement(props: Props) {
)}
</fieldset>
<div className={'card__actions'}>
<Button button="primary" label={__(`Next`)} disabled={!share} type="submit" />
<Button button="primary" label={__(`Let's go`)} disabled={!share} type="submit" />
</div>
{share === NONE && (
<p className="help">
+1 -3
View File
@@ -1,6 +1,4 @@
// @flow
import { formatCredits } from 'util/format-credits';
type Props = {
uri: ?string,
isResolvingUri: boolean,
@@ -25,7 +23,7 @@ function BidHelpText(props: Props) {
bidHelpText = __(
'If you bid more than %amount% LBRY Credits, when someone navigates to %uri%, it will load your published content. However, you can get a longer version of this URL for any bid.',
{
amount: formatCredits(amountNeededForTakeover, 2, true),
amount: amountNeededForTakeover,
uri: uri,
}
);
+5 -9
View File
@@ -5,15 +5,11 @@ import { doUpdatePublishForm, doResetThumbnailStatus } from 'redux/actions/publi
import { doOpenModal } from 'redux/actions/app';
import PublishPage from './view';
const select = (state, props) => {
const publishFormFields = selectPublishFormValues(state);
return {
...publishFormFields,
thumbnail: props.thumbnail || publishFormFields.thumbnail,
fileInfos: selectFileInfosByOutpoint(state),
myClaimForUri: selectMyClaimForUri(state),
};
};
const select = (state) => ({
...selectPublishFormValues(state),
fileInfos: selectFileInfosByOutpoint(state),
myClaimForUri: selectMyClaimForUri(state),
});
const perform = (dispatch) => ({
updatePublishForm: (value) => dispatch(doUpdatePublishForm(value)),
+14 -22
View File
@@ -26,7 +26,6 @@ type Props = {
updatePublishForm: ({}) => void,
updateThumbnailParams: ({}) => void,
resetThumbnailStatus: () => void,
usePublishFormMode: boolean,
};
function SelectThumbnail(props: Props) {
@@ -43,10 +42,9 @@ function SelectThumbnail(props: Props) {
updateThumbnailParams,
thumbnailPath,
resetThumbnailStatus,
usePublishFormMode,
} = props;
const publishForm = usePublishFormMode || !updateThumbnailParams;
const publishForm = !updateThumbnailParams;
const thumbnail = publishForm ? props.thumbnail : thumbnailParam;
const thumbnailError = publishForm ? props.thumbnailError : props.thumbnailParamError;
@@ -69,10 +67,10 @@ function SelectThumbnail(props: Props) {
function handleThumbnailChange(e: SyntheticInputEvent<*>) {
const newThumbnail = e.target.value.replace(' ', '');
if (updateThumbnailParams) {
updateThumbnailParams({ thumbnail_url: newThumbnail });
}
if (updatePublishForm) {
} else {
updatePublishForm({ thumbnail: newThumbnail });
}
}
@@ -108,22 +106,16 @@ function SelectThumbnail(props: Props) {
style={{ display: 'none' }}
src={thumbnail}
alt={__('Thumbnail Preview')}
onError={() => {
if (updateThumbnailParams) {
updateThumbnailParams({ thumbnail_error: Boolean(thumbnail) });
}
if (publishForm) {
updatePublishForm({ thumbnailError: true });
}
}}
onLoad={() => {
if (updateThumbnailParams) {
updateThumbnailParams({ thumbnail_error: !isUrlInput });
}
if (publishForm) {
updatePublishForm({ thumbnailError: !isUrlInput });
}
}}
onError={() =>
publishForm
? updatePublishForm({ thumbnailError: true })
: updateThumbnailParams({ thumbnail_error: Boolean(thumbnail) })
}
onLoad={() =>
publishForm
? updatePublishForm({ thumbnailError: !isUrlInput })
: updateThumbnailParams({ thumbnail_error: !isUrlInput })
}
/>
</div>
);
@@ -163,7 +155,7 @@ function SelectThumbnail(props: Props) {
onFileChosen={(file) =>
openModal(MODALS.CONFIRM_THUMBNAIL_UPLOAD, {
file,
cb: (url) => updateThumbnailParams && updateThumbnailParams({ thumbnail_url: url }),
cb: (url) => !publishForm && updateThumbnailParams({ thumbnail_url: url }),
})
}
/>
+2 -3
View File
@@ -1,6 +1,6 @@
import { connect } from 'react-redux';
import { doSetDaemonSetting, doGetDaemonStatus, doCleanBlobs } from 'redux/actions/settings';
import { selectDaemonStatus, selectDaemonSettings, selectSettingDaemonSettings } from 'redux/selectors/settings';
import { selectDaemonStatus, selectDaemonSettings } from 'redux/selectors/settings';
import SettingWalletServer from './view';
import { selectDiskSpace } from 'redux/selectors/app';
@@ -8,13 +8,12 @@ const select = (state) => ({
daemonSettings: selectDaemonSettings(state),
daemonStatus: selectDaemonStatus(state),
diskSpace: selectDiskSpace(state),
isSetting: selectSettingDaemonSettings(state),
});
const perform = (dispatch) => ({
getDaemonStatus: () => dispatch(doGetDaemonStatus()),
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
cleanBlobs: () => dispatch(doCleanBlobs(false)),
cleanBlobs: () => dispatch(doCleanBlobs()),
});
export default connect(select, perform)(SettingWalletServer);
+152 -58
View File
@@ -4,35 +4,88 @@ import React from 'react';
import { FormField } from 'component/common/form';
import Button from 'component/button';
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
import { formatBytes } from 'util/format-bytes';
import { isTrulyANumber } from 'util/number';
import * as ICONS from 'constants/icons';
import * as KEYCODES from 'constants/keycodes';
import I18nMessage from 'component/i18nMessage';
const BYTES_PER_MB = 1048576;
const ENABLE_AUTOMATIC_HOSTING = false;
import { convertGbToMbStr, isValidHostingAmount } from 'util/hosting';
type Price = {
currency: string,
amount: number,
};
type SetDaemonSettingArg = boolean | string | number;
type DaemonStatus = {
disk_space: {
content_blobs_storage_used_mb: string,
published_blobs_storage_used_mb: string,
running: true,
seed_blobs_storage_used_mb: string,
total_used_mb: string,
},
};
type SetDaemonSettingArg = boolean | string | number | Price;
type DaemonSettings = {
download_dir: string,
share_usage_data: boolean,
max_key_fee?: Price,
max_connections_per_download?: number,
save_files: boolean,
save_blobs: boolean,
ffmpeg_path: string,
};
type Props = {
// --- select ---
daemonSettings: DaemonSettings,
daemonStatus: DaemonStatus,
// --- perform ---
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
cleanBlobs: () => string,
diskSpace?: DiskSpace,
getDaemonStatus: () => void,
isSetting: boolean,
};
function SettingDataHosting(props: Props) {
const { daemonSettings, setDaemonSetting, cleanBlobs, getDaemonStatus, isSetting } = props;
const { daemonSettings, daemonStatus, setDaemonSetting, cleanBlobs, diskSpace, getDaemonStatus } = props;
const networkLimitSetting = daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB] || 0;
const [networkBlobSpaceLimitGB, setNetworkBlobSpaceLimit] = React.useState(
networkLimitSetting ? String(networkLimitSetting / 1024) : 0
const { disk_space: blobSpace } = daemonStatus;
const contentSpaceUsed = Number(blobSpace.content_blobs_storage_used_mb);
const blobLimitSetting = daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB] || '0';
const [contentBlobSpaceLimitGB, setContentBlobSpaceLimit] = React.useState(
blobLimitSetting ? String(blobLimitSetting / 1024) : '10'
);
const [applying, setApplying] = React.useState(false);
const networkSpaceUsed = Number(blobSpace.seed_blobs_storage_used_mb);
const networkLimitSetting = daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB] || '0';
const [networkBlobSpaceLimitGB, setNetworkBlobSpaceLimit] = React.useState(
networkLimitSetting ? String(networkLimitSetting / 1024) : '0'
);
const [unlimited, setUnlimited] = React.useState(blobLimitSetting === '0');
React.useEffect(() => {
getDaemonStatus();
}, []);
function convertGbToMb(gb) {
return Number(gb) * 1024;
}
function handleContentLimitChange(gb) {
if (gb === '') {
setContentBlobSpaceLimit('');
} else if (gb === '0') {
setContentBlobSpaceLimit('0.01'); // setting 0 means unlimited.
} else {
if (isTrulyANumber(Number(gb))) {
setContentBlobSpaceLimit(gb);
}
}
}
function handleNetworkLimitChange(gb) {
if (gb === '') {
@@ -45,68 +98,109 @@ function SettingDataHosting(props: Props) {
}
}
function handleKeyDown(e) {
if (e.keyCode === KEYCODES.ESCAPE) {
e.preventDefault();
setNetworkBlobSpaceLimit(String(networkLimitSetting / 1024));
} else if (e.keyCode === KEYCODES.ENTER) {
e.preventDefault();
handleApply();
}
}
async function handleApply() {
setApplying(true);
if (unlimited) {
await setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, '0');
} else {
await setDaemonSetting(
DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB,
String(contentBlobSpaceLimitGB === '0.01' ? '1' : convertGbToMb(contentBlobSpaceLimitGB))
);
}
await setDaemonSetting(
DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB,
String(convertGbToMbStr(Number(networkBlobSpaceLimitGB)))
String(convertGbToMb(Number(networkBlobSpaceLimitGB)))
);
await cleanBlobs();
getDaemonStatus();
setApplying(false);
}
function validHostingAmount(amountString) {
const numberAmount = Number(amountString);
return amountString.length && ((numberAmount && String(numberAmount)) || numberAmount === 0);
}
return (
<>
<div className={'fieldset-section'}>
<FormField
name="network_blob_limit_gb"
type="number"
label={__(`Automatic Hosting (GB)`)}
disabled={!daemonSettings.save_blobs || isSetting}
onKeyDown={handleKeyDown}
inputButton={
<>
<Button
disabled={
// disabled if settings are equal or not valid amounts
String(networkLimitSetting) === convertGbToMbStr(networkBlobSpaceLimitGB) ||
!isValidHostingAmount(String(networkBlobSpaceLimitGB)) ||
isSetting ||
!daemonSettings.save_blobs
}
type="button"
button="alt"
onClick={handleApply}
aria-label={__('Apply')}
icon={ICONS.COMPLETE}
/>
<Button
disabled={
// disabled if settings are equal or not valid amounts
String(networkLimitSetting) === convertGbToMbStr(networkBlobSpaceLimitGB) ||
!isValidHostingAmount(String(networkBlobSpaceLimitGB)) ||
isSetting ||
!daemonSettings.save_blobs
}
type="button"
button="alt"
onClick={() => setNetworkBlobSpaceLimit(String(networkLimitSetting / 1024))}
aria-label={__('Reset')}
icon={ICONS.REMOVE}
/>
</>
type="checkbox"
name="save_blobs"
onChange={() => setDaemonSetting('save_blobs', !daemonSettings.save_blobs)}
checked={daemonSettings.save_blobs}
label={__('Enable Data Hosting')}
helper={
diskSpace && (
<I18nMessage
tokens={{
free: formatBytes(Number(diskSpace.free) * 1024, 0),
total: formatBytes(Number(diskSpace.total) * 1024, 0),
}}
>
%free% of %total% available
</I18nMessage>
)
}
onChange={(e) => handleNetworkLimitChange(e.target.value)}
value={networkBlobSpaceLimitGB}
/>
</div>
{daemonSettings.save_blobs && (
<div className={'fieldset-section'}>
<FormField
type="radio"
name="no_hosting_limit"
checked={unlimited}
label={__('Unlimited View Hosting')}
onChange={() => setUnlimited(true)}
/>
<FormField
type="radio"
name="set_hosting_limit"
checked={!unlimited}
onChange={() => setUnlimited(false)}
label={__('Choose View Hosting Limit')}
/>
{!unlimited && (
<FormField
name="content_blob_limit_gb"
type="number"
min={0}
onWheel={(e) => e.preventDefault()}
label={__(`View Hosting Limit (GB)`)}
onChange={(e) => handleContentLimitChange(e.target.value)}
value={Number(contentBlobSpaceLimitGB) <= Number('0.01') ? '0' : contentBlobSpaceLimitGB}
/>
)}
<div className={'help'}>{`Currently using ${formatBytes(contentSpaceUsed * BYTES_PER_MB)}`}</div>
</div>
)}
{daemonSettings.save_blobs && ENABLE_AUTOMATIC_HOSTING && (
<fieldset-section>
<FormField
name="network_blob_limit_gb"
type="number"
label={__(`Automatic Hosting (GB)`)}
onChange={(e) => handleNetworkLimitChange(e.target.value)}
value={networkBlobSpaceLimitGB}
/>
<div className={'help'}>{`Auto-hosting ${formatBytes(networkSpaceUsed * BYTES_PER_MB)}`}</div>
</fieldset-section>
)}
<div className={'card__actions'}>
<Button
disabled={
(unlimited && blobLimitSetting === '0') ||
(!unlimited &&
(blobLimitSetting === convertGbToMb(contentBlobSpaceLimitGB) || // &&
// networkLimitSetting === convertGbToMb(networkBlobSpaceLimitGB)
!validHostingAmount(String(contentBlobSpaceLimitGB)))) ||
applying
}
type="button"
button="primary"
onClick={handleApply}
label={__('Apply')}
/>
</div>
</>
-17
View File
@@ -1,17 +0,0 @@
import { connect } from 'react-redux';
import { doSetDaemonSetting, doGetDaemonStatus } from 'redux/actions/settings';
import { selectDaemonSettings } from 'redux/selectors/settings';
import SettingWalletServer from './view';
import { selectDiskSpace } from 'redux/selectors/app';
const select = (state) => ({
daemonSettings: selectDaemonSettings(state),
diskSpace: selectDiskSpace(state),
});
const perform = (dispatch) => ({
getDaemonStatus: () => dispatch(doGetDaemonStatus()),
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
});
export default connect(select, perform)(SettingWalletServer);
-34
View File
@@ -1,34 +0,0 @@
// @flow
import React from 'react';
import { FormField } from 'component/common/form';
type SetDaemonSettingArg = boolean | string | number;
type DaemonSettings = {
save_blobs: boolean,
};
type Props = {
// --- select ---
daemonSettings: DaemonSettings,
// --- perform ---
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
};
function SettingDataHosting(props: Props) {
const { daemonSettings, setDaemonSetting } = props;
return (
<>
<FormField
type="checkbox"
name="save_blobs"
onChange={() => setDaemonSetting('save_blobs', !daemonSettings.save_blobs)}
checked={daemonSettings.save_blobs}
/>
</>
);
}
export default SettingDataHosting;
-25
View File
@@ -1,25 +0,0 @@
import { connect } from 'react-redux';
import { doWalletStatus } from 'redux/actions/wallet';
import { doClearCache } from 'redux/actions/app';
import { doSetDaemonSetting, doClearDaemonSetting, doCleanBlobs } from 'redux/actions/settings';
import { selectDaemonSettings, selectDaemonStatus, selectSettingDaemonSettings } from 'redux/selectors/settings';
import SettingStorage from './view';
import { selectDiskSpace } from 'redux/selectors/app';
const select = (state) => ({
daemonSettings: selectDaemonSettings(state),
diskSpace: selectDiskSpace(state),
daemonStatus: selectDaemonStatus(state),
isSetting: selectSettingDaemonSettings(state),
});
const perform = (dispatch) => ({
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
clearDaemonSetting: (key) => dispatch(doClearDaemonSetting(key)),
clearCache: () => dispatch(doClearCache()),
cleanBlobs: () => dispatch(doCleanBlobs()),
updateWalletStatus: () => dispatch(doWalletStatus()),
});
export default connect(select, perform)(SettingStorage);
-94
View File
@@ -1,94 +0,0 @@
// @flow
import { SETTINGS_GRP } from 'constants/settings';
import React from 'react';
import Button from 'component/button';
import Card from 'component/common/card';
import SettingDataHosting from 'component/settingDataHosting';
import SettingViewHosting from 'component/settingViewHosting';
import SettingSaveBlobs from 'component/settingSaveBlobs';
import SettingsRow from 'component/settingsRow';
import AppStorageViz from 'component/appStorageVisualization';
import Spinner from 'component/spinner';
import classnames from 'classnames';
type DaemonSettings = {
save_blobs: boolean,
};
type Props = {
daemonSettings: DaemonSettings,
isSetting: boolean,
isWelcome?: boolean,
cleanBlobs: () => Promise<any>,
};
export default function SettingStorage(props: Props) {
const { daemonSettings, isSetting, isWelcome, cleanBlobs } = props;
const saveBlobs = daemonSettings && daemonSettings.save_blobs;
const [isCleaning, setCleaning] = React.useState(false);
// currently, it seems, blob space statistics are only updated during clean
React.useEffect(() => {
setCleaning(true);
cleanBlobs().then(() => {
setCleaning(false);
});
}, []);
return (
<>
<div className="card__title-section">
<h2 className={classnames('card__title', { 'section__title--large': isWelcome })}>
{isWelcome ? __('Custom Hosting') : __('Hosting')}
{(isSetting || isCleaning) && <Spinner type={'small'} />}
</h2>
</div>
<Card
id={SETTINGS_GRP.STORAGE}
isBodyList
body={
<>
<SettingsRow
title={__('Enable Data Hosting')}
subtitle={
<React.Fragment>
{__('Help improve the P2P data network (and make LBRY users happy) by hosting data.')}
</React.Fragment>
}
footer={<AppStorageViz />}
>
<SettingSaveBlobs />
</SettingsRow>
<SettingsRow
title={__('Viewed Hosting')}
multirow
disabled={!saveBlobs}
subtitle={
<React.Fragment>
{__("View History Hosting lets you choose how much storage to use hosting content you've consumed.")}{' '}
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />
</React.Fragment>
}
>
<SettingViewHosting disabled={!saveBlobs} />
</SettingsRow>
<SettingsRow
title={__('Auto Hosting')}
multirow
disabled={!saveBlobs}
subtitle={
<React.Fragment>
{__('Automatic Hosting downloads a small portion of content active on the network.')}{' '}
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />
</React.Fragment>
}
>
<SettingDataHosting />
</SettingsRow>
</>
}
/>
</>
);
}
+19
View File
@@ -10,6 +10,7 @@ import I18nMessage from 'component/i18nMessage';
import SettingAutoLaunch from 'component/settingAutoLaunch';
import SettingClosingBehavior from 'component/settingClosingBehavior';
import SettingCommentsServer from 'component/settingCommentsServer';
import SettingDataHosting from 'component/settingDataHosting';
import SettingShareUrl from 'component/settingShareUrl';
import SettingsRow from 'component/settingsRow';
import SettingWalletServer from 'component/settingWalletServer';
@@ -150,6 +151,24 @@ export default function SettingSystem(props: Props) {
checked={daemonSettings.save_files}
/>
</SettingsRow>
<SettingsRow
title={__('Data Hosting')}
multirow
subtitle={
<React.Fragment>
{__('Help improve the P2P data network (and make LBRY happy) by hosting data.')}{' '}
{__("View History Hosting lets you choose how much storage to use helping content you've consumed.")}{' '}
{/* {__( */}
{/* 'Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.' */}
{/* )}{' '} */}
{__('Playing videos may exceed your history hosting limit until cleanup runs every 30 minutes.')}
<br />
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />
</React.Fragment>
}
>
<SettingDataHosting />
</SettingsRow>
<SettingsRow
title={__('Share usage and diagnostic data')}
subtitle={
-20
View File
@@ -1,20 +0,0 @@
import { connect } from 'react-redux';
import { doSetDaemonSetting, doGetDaemonStatus, doCleanBlobs } from 'redux/actions/settings';
import { selectViewHostingLimit, selectViewBlobSpace, selectSettingDaemonSettings } from 'redux/selectors/settings';
import SettingViewHosting from './view';
import { selectDiskSpace } from 'redux/selectors/app';
const select = (state) => ({
viewHostingLimit: selectViewHostingLimit(state),
viewBlobSpace: selectViewBlobSpace(state),
diskSpace: selectDiskSpace(state),
isSetting: selectSettingDaemonSettings(state),
});
const perform = (dispatch) => ({
getDaemonStatus: () => dispatch(doGetDaemonStatus()),
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
cleanBlobs: () => dispatch(doCleanBlobs(false)),
});
export default connect(select, perform)(SettingViewHosting);
-182
View File
@@ -1,182 +0,0 @@
// @flow
import React from 'react';
import { FormField } from 'component/common/form';
import Button from 'component/button';
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
import { isTrulyANumber } from 'util/number';
import * as ICONS from 'constants/icons';
import * as KEYCODES from 'constants/keycodes';
import { convertGbToMbStr, isValidHostingAmount } from 'util/hosting';
type SetDaemonSettingArg = boolean | string | number;
type Props = {
// --- select ---
viewBlobSpace: number,
viewHostingLimit: number,
disabled?: boolean,
isSetting: boolean,
// --- perform ---
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
cleanBlobs: () => string,
getDaemonStatus: () => void,
diskSpace: DiskSpace,
};
const TWENTY_PERCENT = 0.2;
const TEN_PERCENT = 0.1;
const MINIMUM_VIEW_SETTING = '0.01';
function SettingViewHosting(props: Props) {
const {
diskSpace,
viewHostingLimit,
viewBlobSpace,
setDaemonSetting,
cleanBlobs,
getDaemonStatus,
disabled,
isSetting,
} = props;
// best effort to recommend a hosting amount default for the user
const totalMB = diskSpace && Math.floor(diskSpace.total / 1024);
const freeMB = diskSpace && Math.floor(diskSpace.free / 1024);
const getGB = (val) => (Number(val) / 1024).toFixed(2);
const recommendedSpace =
freeMB > totalMB * TWENTY_PERCENT // plenty of space?
? Math.ceil(Number(getGB(totalMB * TEN_PERCENT))) // 10% of total
: Math.ceil(Number(getGB(viewBlobSpace))); // current amount to avoid deleting
// daemon settings come in as 'number', but we manage them as 'String'.
const [contentBlobSpaceLimitGB, setContentBlobSpaceLimit] = React.useState(
viewHostingLimit === 0 ? String(recommendedSpace) : String(viewHostingLimit / 1024)
);
const [unlimited, setUnlimited] = React.useState(viewHostingLimit === 0);
function handleContentLimitChange(gb) {
if (gb === '') {
setContentBlobSpaceLimit('');
} else if (gb === '0') {
setContentBlobSpaceLimit(MINIMUM_VIEW_SETTING); // setting 0 means unlimited.
} else {
if (isTrulyANumber(Number(gb))) {
setContentBlobSpaceLimit(gb);
}
}
}
function getContentLimitValue() {
if (contentBlobSpaceLimitGB === '') {
return '';
} else if (Number(contentBlobSpaceLimitGB) <= Number(MINIMUM_VIEW_SETTING)) {
return '0';
} else {
return contentBlobSpaceLimitGB;
}
}
async function handleApply() {
if (unlimited) {
await setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, '0');
} else {
await setDaemonSetting(
DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB,
contentBlobSpaceLimitGB === MINIMUM_VIEW_SETTING ? '1' : convertGbToMbStr(contentBlobSpaceLimitGB)
);
}
await cleanBlobs();
getDaemonStatus();
}
function handleKeyDown(e) {
if (e.keyCode === KEYCODES.ESCAPE) {
e.preventDefault();
setContentBlobSpaceLimit(String(viewHostingLimit / 1024));
} else if (e.keyCode === KEYCODES.ENTER) {
e.preventDefault();
handleApply();
}
}
React.useEffect(() => {
// basically handle setUnlimited
if (unlimited && viewHostingLimit !== 0) {
handleApply();
}
}, [unlimited, viewHostingLimit]);
return (
<>
<div className={'fieldset-section'}>
<FormField
type="checkbox"
name="hosting_limit"
checked={unlimited}
disabled={disabled || isSetting}
label={__('Unlimited View Hosting')}
onChange={() => setUnlimited(!unlimited)}
/>
<FormField
name="content_blob_limit_gb"
type="number"
min={0}
onKeyDown={handleKeyDown}
inputButton={
<>
<Button
disabled={
// disabled if settings are equal or not valid amounts
(viewHostingLimit === 1 && contentBlobSpaceLimitGB <= MINIMUM_VIEW_SETTING) ||
(unlimited && viewHostingLimit === 0) ||
(!unlimited &&
(String(viewHostingLimit) === convertGbToMbStr(contentBlobSpaceLimitGB) ||
!isValidHostingAmount(String(contentBlobSpaceLimitGB)))) ||
(!unlimited &&
String(viewHostingLimit) ===
convertGbToMbStr(
contentBlobSpaceLimitGB || !isValidHostingAmount(String(contentBlobSpaceLimitGB))
)) ||
isSetting ||
disabled
}
type="button"
button="alt"
onClick={handleApply}
aria-label={__('Apply')}
icon={ICONS.COMPLETE}
/>
<Button
disabled={
// disabled if settings are equal or not valid amounts
(viewHostingLimit === 1 && contentBlobSpaceLimitGB <= MINIMUM_VIEW_SETTING) ||
(unlimited && viewHostingLimit === 0) ||
(!unlimited &&
String(viewHostingLimit) ===
convertGbToMbStr(
contentBlobSpaceLimitGB || !isValidHostingAmount(String(contentBlobSpaceLimitGB))
)) ||
isSetting ||
disabled
}
type="button"
button="alt"
onClick={() => setContentBlobSpaceLimit(String(viewHostingLimit / 1024))}
aria-label={__('Reset')}
icon={ICONS.REMOVE}
/>
</>
}
disabled={isSetting || disabled || unlimited}
onWheel={(e) => e.preventDefault()}
label={__(`View Hosting Limit (GB)`)}
onChange={(e) => handleContentLimitChange(e.target.value)}
value={getContentLimitValue()}
/>
</div>
</>
);
}
export default SettingViewHosting;
+1 -7
View File
@@ -1,9 +1,5 @@
import { connect } from 'react-redux';
import {
selectIsWalletReconnecting,
selectWalletRollbackToDefault,
selectWalletConnectingToDefault,
} from 'redux/selectors/wallet';
import { selectIsWalletReconnecting } from 'redux/selectors/wallet';
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
import {
doSetDaemonSetting,
@@ -19,8 +15,6 @@ const select = (state) => ({
customWalletServers: selectSavedWalletServers(state),
hasWalletServerPrefs: selectHasWalletServerPrefs(state),
walletReconnecting: selectIsWalletReconnecting(state),
walletRollbackToDefault: selectWalletRollbackToDefault(state),
walletReconnectingToDefault: selectWalletConnectingToDefault(state),
});
const perform = (dispatch) => ({
+8 -29
View File
@@ -30,8 +30,6 @@ type Props = {
hasWalletServerPrefs: boolean,
daemonStatus: DaemonStatus,
walletReconnecting: boolean,
walletRollbackToDefault: boolean,
walletReconnectingToDefault: boolean,
};
function SettingWalletServer(props: Props) {
@@ -44,12 +42,9 @@ function SettingWalletServer(props: Props) {
customWalletServers,
hasWalletServerPrefs,
walletReconnecting,
walletRollbackToDefault,
walletReconnectingToDefault,
} = props;
const [usingCustomServer, setUsingCustomServer] = useState(false);
const [showCustomServers, setShowCustomServers] = useState(false);
const [advancedMode, setAdvancedMode] = useState(false);
const walletStatus = daemonStatus && daemonStatus.wallet;
const activeWalletServers: ServerStatus = (walletStatus && walletStatus.servers) || [];
@@ -78,7 +73,7 @@ function SettingWalletServer(props: Props) {
useEffect(() => {
if (hasWalletServerPrefs) {
setUsingCustomServer(true);
setAdvancedMode(true);
}
}, []);
@@ -89,20 +84,8 @@ function SettingWalletServer(props: Props) {
return () => clearInterval(interval);
}, []);
useEffect(() => {
if (walletRollbackToDefault) {
doClear();
}
}, [walletRollbackToDefault]);
useEffect(() => {
if (usingCustomServer) {
setShowCustomServers(true);
}
}, [usingCustomServer]);
function doClear() {
setUsingCustomServer(false);
setAdvancedMode(false);
clearWalletServers();
}
@@ -129,7 +112,7 @@ function SettingWalletServer(props: Props) {
<FormField
type="radio"
name="default_wallet_servers"
checked={!usingCustomServer}
checked={!advancedMode}
label={__('Use official LBRY wallet servers')}
onChange={(e) => {
if (e.target.checked) {
@@ -140,9 +123,9 @@ function SettingWalletServer(props: Props) {
<FormField
type="radio"
name="custom_wallet_servers"
checked={usingCustomServer}
checked={advancedMode}
onChange={(e) => {
setUsingCustomServer(e.target.checked);
setAdvancedMode(e.target.checked);
if (e.target.checked && customWalletServers.length) {
setCustomWalletServers(stringifyServerParam(customWalletServers));
}
@@ -150,7 +133,7 @@ function SettingWalletServer(props: Props) {
label={__('Use custom wallet servers')}
/>
{showCustomServers && (
{advancedMode && (
<div>
{serverConfig &&
serverConfig.map((entry, index) => {
@@ -168,11 +151,7 @@ function SettingWalletServer(props: Props) {
{host}:{port}
</h3>
<span className="help">
{available
? __('Connected')
: walletReconnecting && !walletReconnectingToDefault
? __('Connecting...')
: __('Not connected')}
{available ? __('Connected') : walletReconnecting ? __('Connecting...') : __('Not connected')}
</span>
<Button
button="close"
+1 -3
View File
@@ -9,11 +9,10 @@ type Props = {
useVerticalSeparator?: boolean, // Show a separator line between Label and Value. Useful when there are multiple Values.
disabled?: boolean,
children?: React$Node,
footer?: React$Node,
};
export default function SettingsRow(props: Props) {
const { title, subtitle, multirow, useVerticalSeparator, disabled, children, footer } = props;
const { title, subtitle, multirow, useVerticalSeparator, disabled, children } = props;
return (
<div
className={classnames('card__main-actions settings__row', {
@@ -24,7 +23,6 @@ export default function SettingsRow(props: Props) {
<div className="settings__row--title">
<p>{title}</p>
{subtitle && <p className="settings__row--subtitle">{subtitle}</p>}
{footer && footer}
</div>
<div
className={classnames('settings__row--value', {
+2 -5
View File
@@ -7,7 +7,9 @@ import React from 'react';
import { useHistory } from 'react-router-dom';
import classnames from 'classnames';
import Button from 'component/button';
// @if TARGET='app'
import { IS_MAC } from 'component/app/view';
// @endif
import { useIsMediumScreen } from 'effects/use-screensize';
type SideNavLink = {
@@ -41,11 +43,6 @@ const SIDE_LINKS: Array<SideNavLink> = [
section: SETTINGS_GRP.SYSTEM,
icon: ICONS.SETTINGS,
},
{
title: 'Content Hosting',
section: SETTINGS_GRP.STORAGE,
icon: ICONS.PUBLISH,
},
];
export default function SettingsSideNavigation() {
+1 -22
View File
@@ -6,15 +6,13 @@ import * as KEYCODES from 'constants/keycodes';
import React from 'react';
import Button from 'component/button';
import classnames from 'classnames';
import Icon from 'component/common/icon';
import NotificationBubble from 'component/notificationBubble';
import DebouncedInput from 'component/common/debounced-input';
import I18nMessage from 'component/i18nMessage';
import ChannelThumbnail from 'component/channelThumbnail';
import { useIsMobile, isTouch } from 'effects/use-screensize';
import { IS_MAC } from 'component/app/view';
import { useHistory } from 'react-router';
import { DOMAIN, ENABLE_UI_NOTIFICATIONS } from 'config';
import { ENABLE_UI_NOTIFICATIONS } from 'config';
const FOLLOWED_ITEM_INITIAL_LIMIT = 10;
const touch = isTouch();
@@ -184,7 +182,6 @@ function SideNavigation(props: Props) {
];
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
const isAuthenticated = Boolean(email);
const [pulseLibrary, setPulseLibrary] = React.useState(false);
const [expandSubscriptions, setExpandSubscriptions] = React.useState(false);
@@ -357,23 +354,6 @@ function SideNavigation(props: Props) {
return () => window.removeEventListener('keydown', handleKeydown);
}, [sidebarOpen, setSidebarOpen, isAbsolute]);
const unAuthNudge =
DOMAIN === 'lbry.tv' ? null : (
<div className="navigation__auth-nudge">
<span>
<I18nMessage tokens={{ lbc: <Icon icon={ICONS.LBC} /> }}>
Sign up to earn %lbc% for you and your favorite creators.
</I18nMessage>
</span>
<Button
button="secondary"
label={__('Sign Up')}
navigate={`/$/${PAGES.AUTH}?src=sidenav_nudge`}
disabled={user === null}
/>{' '}
</div>
);
const helpLinks = (
<ul className="navigation__tertiary navigation-links--small">
<li className="navigation-link">
@@ -437,7 +417,6 @@ function SideNavigation(props: Props) {
{getSubscriptionSection()}
{getFollowedTagsSection()}
{!isAuthenticated && sidebarOpen && unAuthNudge}
</div>
)}
{(!canDisposeMenu || sidebarOpen) && shouldRenderLargeMenu && helpLinks}
+3 -7
View File
@@ -241,12 +241,8 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
return (
<div className="splash">
{!error && (
<>
<h1 className="splash__title">LBRY</h1>
<div className="splash__details">{details}</div>
</>
)}
<h1 className="splash__title">LBRY</h1>
<div className="splash__details">{details}</div>
{!animationHidden && !error && (
<css-doodle class="doodle">
@@ -294,7 +290,7 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
)}
{error && (
<Card
title={<h1 className="splash__error-title">{__('Error starting up')}</h1>}
title={__('Error starting up')}
subtitle={
<React.Fragment>
<p>
+1 -4
View File
@@ -5,7 +5,6 @@ import { parseURI } from 'util/lbryURI';
import Button from 'component/button';
import useHover from 'effects/use-hover';
import { useIsMobile } from 'effects/use-screensize';
import { ENABLE_UI_NOTIFICATIONS } from 'config';
type SubscriptionArgs = {
channelName: string,
@@ -34,7 +33,6 @@ export default function SubscribeButton(props: Props) {
doToast,
shrinkOnMobile = false,
notificationsDisabled,
user,
uri,
} = props;
@@ -42,7 +40,6 @@ export default function SubscribeButton(props: Props) {
const isMobile = useIsMobile();
let isHovering = useHover(buttonRef);
isHovering = isMobile ? true : isHovering;
const uiNotificationsEnabled = (user && user.experimental_ui) || ENABLE_UI_NOTIFICATIONS;
const { channelName: rawChannelName } = parseURI(uri);
@@ -119,7 +116,7 @@ export default function SubscribeButton(props: Props) {
);
}}
/>
{isSubscribed && uiNotificationsEnabled && (
{isSubscribed && (
<>
<Button
button="alt"
+1 -2
View File
@@ -1,6 +1,5 @@
// @flow
import * as PAGES from 'constants/pages';
import { DOMAIN } from 'config';
import React, { useState } from 'react';
import { FormField, Form } from 'component/common/form';
import Button from 'component/button';
@@ -95,7 +94,7 @@ function UserEmailNew(props: Props) {
title={__('Cloud Connect')}
subtitle={__('Connect your wallet to Odysee')}
actions={
<div className={classnames({ 'card--disabled': DOMAIN === 'lbry.tv' && IS_WEB })}>
<div>
<Form onSubmit={handleSubmit} className="section">
<FormField
autoFocus
+4 -4
View File
@@ -1,8 +1,8 @@
import { connect } from 'react-redux';
import { makeSelectClaimForUri, selectThumbnailForUri } from 'redux/selectors/claims';
import {
makeSelectPrevPlayableUrlFromCollectionAndUrl,
makeSelectNextPlayableUrlFromCollectionAndUrl,
makeSelectNextUrlForCollectionAndUrl,
makeSelectPreviousUrlForCollectionAndUrl,
} from 'redux/selectors/collections';
import * as SETTINGS from 'constants/settings';
import * as COLLECTIONS_CONSTS from 'constants/collections';
@@ -38,8 +38,8 @@ const select = (state, props) => {
let nextRecommendedUri;
let previousListUri;
if (collectionId) {
nextRecommendedUri = makeSelectNextPlayableUrlFromCollectionAndUrl(collectionId, uri)(state);
previousListUri = makeSelectPrevPlayableUrlFromCollectionAndUrl(collectionId, uri)(state);
nextRecommendedUri = makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state);
previousListUri = makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state);
} else {
const recommendedContent = selectRecommendedContentForUri(state, uri);
nextRecommendedUri = recommendedContent && recommendedContent[0];
+2 -2
View File
@@ -9,7 +9,7 @@ import HelpLink from 'component/common/help-link';
import Card from 'component/common/card';
import LbcSymbol from 'component/common/lbc-symbol';
import I18nMessage from 'component/i18nMessage';
import { formatCredits } from 'util/format-credits';
import { formatNumberWithCommas } from 'util/number';
type Props = {
balance: number,
@@ -64,7 +64,7 @@ const WalletBalance = (props: Props) => {
return (
<Card
title={<LbcSymbol postfix={formatCredits(totalBalance, 8)} isTitle />}
title={<LbcSymbol postfix={formatNumberWithCommas(totalBalance)} isTitle />}
subtitle={
totalLocked > 0 ? (
<I18nMessage tokens={{ lbc: <LbcSymbol /> }}>
+21 -20
View File
@@ -45,8 +45,6 @@ export const DOWNLOAD_UPGRADE = 'DOWNLOAD_UPGRADE';
export const UPGRADE_DOWNLOAD_STARTED = 'UPGRADE_DOWNLOAD_STARTED';
export const UPGRADE_DOWNLOAD_COMPLETED = 'UPGRADE_DOWNLOAD_COMPLETED';
export const UPGRADE_DOWNLOAD_PROGRESSED = 'UPGRADE_DOWNLOAD_PROGRESSED';
export const UPGRADE_INIT_INSTALL = 'UPGRADE_INIT_INSTALL';
export const UPGRADE_INSTALL_ERROR = 'UPGRADE_INSTALL_ERROR';
export const CHECK_UPGRADE_AVAILABLE = 'CHECK_UPGRADE_AVAILABLE';
export const CHECK_UPGRADE_START = 'CHECK_UPGRADE_START';
export const CHECK_UPGRADE_SUCCESS = 'CHECK_UPGRADE_SUCCESS';
@@ -105,7 +103,6 @@ export const WALLET_STATUS_START = 'WALLET_STATUS_START';
export const WALLET_STATUS_COMPLETED = 'WALLET_STATUS_COMPLETED';
export const WALLET_RESTART = 'WALLET_RESTART';
export const WALLET_RESTART_COMPLETED = 'WALLET_RESTART_COMPLETED';
export const WALLET_ROLLBACK_DEFAULT = 'WALLET_ROLLBACK_DEFAULT';
export const SET_TRANSACTION_LIST_FILTER = 'SET_TRANSACTION_LIST_FILTER';
export const UPDATE_CURRENT_HEIGHT = 'UPDATE_CURRENT_HEIGHT';
export const SET_DRAFT_TRANSACTION_AMOUNT = 'SET_DRAFT_TRANSACTION_AMOUNT';
@@ -251,7 +248,6 @@ export const SYNC_CLIENT_SETTINGS = 'SYNC_CLIENT_SETTINGS';
export const DAEMON_STATUS_RECEIVED = 'DAEMON_STATUS_RECEIVED';
export const SHARED_PREFERENCE_SET = 'SHARED_PREFERENCE_SET';
export const SAVE_CUSTOM_WALLET_SERVERS = 'SAVE_CUSTOM_WALLET_SERVERS';
export const SETTING_DAEMON_SETTINGS = 'SETTING_DAEMON_SETTINGS';
// User
export const AUTHENTICATION_STARTED = 'AUTHENTICATION_STARTED';
@@ -328,10 +324,11 @@ export const HAS_FETCHED_SUBSCRIPTIONS = 'HAS_FETCHED_SUBSCRIPTIONS';
export const CHECK_SUBSCRIPTION_STARTED = 'CHECK_SUBSCRIPTION_STARTED';
export const CHECK_SUBSCRIPTION_COMPLETED = 'CHECK_SUBSCRIPTION_COMPLETED';
export const CHECK_SUBSCRIPTIONS_SUBSCRIBE = 'CHECK_SUBSCRIPTIONS_SUBSCRIBE';
export const FETCH_SUBSCRIPTIONS_START = 'FETCH_SUBSCRIPTIONS_START';
export const FETCH_SUBSCRIPTIONS_FAIL = 'FETCH_SUBSCRIPTIONS_FAIL';
export const FETCH_SUBSCRIPTIONS_SUCCESS = 'FETCH_SUBSCRIPTIONS_SUCCESS';
export const SET_VIEW_MODE = 'SET_VIEW_MODE';
export const SUBSCRIPTION_DOWNLOAD_ADD = 'SUBSCRIPTION_DOWNLOAD_ADD';
export const SUBSCRIPTION_DOWNLOAD_REMOVE = 'SUBSCRIPTION_DOWNLOAD_REMOVE';
export const SUBSCRIPTION_RELEASE_UPDATE = 'SUBSCRIPTION_RELEASE_UPDATE';
export const SUBSCRIPTION_DOWNLOAD_TOGGLE = 'SUBSCRIPTION_DOWNLOAD_TOGGLE';
// Publishing
export const CLEAR_PUBLISH = 'CLEAR_PUBLISH';
@@ -348,19 +345,23 @@ export const MEDIA_PLAY = 'MEDIA_PLAY';
export const MEDIA_PAUSE = 'MEDIA_PAUSE';
// Notifications
export const NOTIFICATION_LIST_STARTED = 'NOTIFICATION_LIST_STARTED';
export const NOTIFICATION_LIST_COMPLETED = 'NOTIFICATION_LIST_COMPLETED';
export const NOTIFICATION_LIST_FAILED = 'NOTIFICATION_LIST_FAILED';
export const NOTIFICATION_CATEGORIES_COMPLETED = 'NOTIFICATION_CATEGORIES_COMPLETED';
export const NOTIFICATION_READ_STARTED = 'NOTIFICATION_READ_STARTED';
export const NOTIFICATION_READ_COMPLETED = 'NOTIFICATION_READ_COMPLETED';
export const NOTIFICATION_READ_FAILED = 'NOTIFICATION_READ_FAILED';
export const NOTIFICATION_SEEN_STARTED = 'NOTIFICATION_SEEN_STARTED';
export const NOTIFICATION_SEEN_COMPLETED = 'NOTIFICATION_SEEN_COMPLETED';
export const NOTIFICATION_SEEN_FAILED = 'NOTIFICATION_SEEN_FAILED';
export const NOTIFICATION_DELETE_STARTED = 'NOTIFICATION_DELETE_STARTED';
export const NOTIFICATION_DELETE_COMPLETED = 'NOTIFICATION_DELETE_COMPLETED';
export const NOTIFICATION_DELETE_FAILED = 'NOTIFICATION_DELETE_FAILED';
export const LBRYIO_NOTIFICATION_LIST_STARTED = 'NOTIFICATION_LIST_STARTED';
export const LBRYIO_NOTIFICATION_LIST_COMPLETED = 'NOTIFICATION_LIST_COMPLETED';
export const LBRYIO_NOTIFICATION_LIST_FAILED = 'NOTIFICATION_LIST_FAILED';
export const LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED = 'LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED';
export const LBRYIO_NOTIFICATION_READ_STARTED = 'LBRYIO_NOTIFICATION_READ_STARTED';
export const LBRYIO_NOTIFICATION_READ_COMPLETED = 'LBRYIO_NOTIFICATION_READ_COMPLETED';
export const LBRYIO_NOTIFICATION_READ_FAILED = 'LBRYIO_NOTIFICATION_READ_FAILED';
export const LBRYIO_NOTIFICATION_SEEN_STARTED = 'LBRYIO_NOTIFICATION_SEEN_STARTED';
export const LBRYIO_NOTIFICATION_SEEN_COMPLETED = 'LBRYIO_NOTIFICATION_SEEN_COMPLETED';
export const LBRYIO_NOTIFICATION_SEEN_FAILED = 'LBRYIO_NOTIFICATION_SEEN_FAILED';
export const LBRYIO_NOTIFICATION_DELETE_STARTED = 'LBRYIO_NOTIFICATION_DELETE_STARTED';
export const LBRYIO_NOTIFICATION_DELETE_COMPLETED = 'LBRYIO_NOTIFICATION_DELETE_COMPLETED';
export const LBRYIO_NOTIFICATION_DELETE_FAILED = 'LBRYIO_NOTIFICATION_DELETE_FAILED';
export const LOCAL_NOTIFICATION_DELETE = 'LBRYIO_NOTIFICATION_DELETE';
export const LOCAL_NOTIFICATION_ADD = 'LBRYIO_NOTIFICATION_ADD';
export const LOCAL_NOTIFICATION_SEEN = 'LBRYIO_NOTIFICATION_SEEN';
export const CREATE_TOAST = 'CREATE_TOAST';
export const DISMISS_TOAST = 'DISMISS_TOAST';
export const CREATE_ERROR = 'CREATE_ERROR';
+2
View File
@@ -186,3 +186,5 @@ export const MYSTERIES = 'Mysteries';
export const TECHNOLOGY = 'Technology';
export const EMOJI = 'Emoji';
export const STICKER = 'Sticker';
export const HOST = 'Host';
export const NO_HOST = 'NoHost';
-1
View File
@@ -53,5 +53,4 @@ export const SETTINGS_GRP = {
ACCOUNT: 'account',
CONTENT: 'content',
SYSTEM: 'system',
STORAGE: 'Storage',
};
+3 -7
View File
@@ -21,7 +21,6 @@ import {
doToggle3PAnalytics,
doUpdateDownloadProgress,
doNotifyUpdateAvailable,
doShowUpgradeInstallationError,
} from 'redux/actions/app';
import { isURIValid } from 'util/lbryURI';
import { setSearchApi } from 'redux/actions/search';
@@ -104,6 +103,8 @@ ipcRenderer.on('send-disk-space', (event, result) => {
}
});
ipcRenderer.send('get-disk-space');
// @if TARGET='app'
ipcRenderer.on('open-uri-requested', (event, url, newSession) => {
function handleError() {
app.store.dispatch(
@@ -133,10 +134,6 @@ autoUpdater.on('update-available', (e) => {
app.store.dispatch(doNotifyUpdateAvailable(e));
});
ipcRenderer.on('upgrade-installing-error', () => {
app.store.dispatch(doShowUpgradeInstallationError());
});
ipcRenderer.on('download-progress-update', (e, p) => {
app.store.dispatch(doUpdateDownloadProgress(Math.round(p.percent * 100)));
});
@@ -194,6 +191,7 @@ document.addEventListener('click', (event) => {
target = target.parentNode;
}
});
// @endif
document.addEventListener('dragover', (event) => {
event.preventDefault();
@@ -213,8 +211,6 @@ function AppWrapper() {
const enabled = makeSelectClientSetting(SETTINGS.ENABLE_PRERELEASE_UPDATES)(state);
if (enabled) {
autoUpdater.allowPrerelease = true;
} else {
autoUpdater.allowPrerelease = false;
}
}
}, [persistDone]);
+7 -12
View File
@@ -1,23 +1,15 @@
import { connect } from 'react-redux';
import { doStartUpgrade, doCancelUpgrade, doHideModal } from 'redux/actions/app';
import {
selectDownloadProgress,
selectDownloadComplete,
selectUpgradeDownloadPath,
selectUpgradeInitialized,
selectUpgradeFailedInstallation,
} from 'redux/selectors/app';
import { selectDownloadProgress, selectDownloadComplete, selectUpgradeDownloadPath } from 'redux/selectors/app';
import ModalDownloading from './view';
const select = (state) => ({
const select = state => ({
downloadProgress: selectDownloadProgress(state),
downloadComplete: selectDownloadComplete(state),
downloadItem: selectUpgradeDownloadPath(state),
upgradeInitialized: selectUpgradeInitialized(state),
failedInstallation: selectUpgradeFailedInstallation(state),
});
const perform = (dispatch) => ({
const perform = dispatch => ({
startUpgrade: () => dispatch(doStartUpgrade()),
cancelUpgrade: () => {
dispatch(doHideModal());
@@ -25,4 +17,7 @@ const perform = (dispatch) => ({
},
});
export default connect(select, perform)(ModalDownloading);
export default connect(
select,
perform
)(ModalDownloading);
+3 -22
View File
@@ -10,21 +10,11 @@ type Props = {
downloadItem: string,
startUpgrade: () => void,
cancelUpgrade: () => void,
upgradeInitialized: boolean,
failedInstallation: boolean,
};
class ModalDownloading extends React.PureComponent<Props> {
render() {
const {
downloadProgress,
downloadComplete,
downloadItem,
startUpgrade,
cancelUpgrade,
upgradeInitialized,
failedInstallation,
} = this.props;
const { downloadProgress, downloadComplete, downloadItem, startUpgrade, cancelUpgrade } = this.props;
return (
<Modal title={__('Downloading update')} isOpen contentLabel={__('Downloading update')} type="custom">
@@ -50,18 +40,9 @@ class ModalDownloading extends React.PureComponent<Props> {
</React.Fragment>
) : null}
{failedInstallation && <p>{__('There was an error during installation. Please, try again.')}</p>}
<div className="card__actions">
{downloadComplete ? (
<Button
disabled={upgradeInitialized}
button="primary"
label={__(upgradeInitialized ? 'Installing, please wait...' : 'Begin Upgrade')}
onClick={startUpgrade}
/>
) : null}
<Button disabled={upgradeInitialized} button="link" label={__('Cancel')} onClick={cancelUpgrade} />
{downloadComplete ? <Button button="primary" label={__('Begin Upgrade')} onClick={startUpgrade} /> : null}
<Button button="link" label={__('Cancel')} onClick={cancelUpgrade} />
</div>
</Modal>
);
+9 -4
View File
@@ -1,9 +1,8 @@
// @flow
import * as ICONS from 'constants/icons';
import * as PAGES from 'constants/pages';
import React from 'react';
import React, { Fragment } from 'react';
import { parseURI } from 'util/lbryURI';
import { formatNumber } from 'util/number';
import { YOUTUBE_STATUSES } from 'lbryinc';
import Page from 'component/page';
import SubscribeButton from 'component/subscribeButton';
@@ -37,6 +36,7 @@ const PAGE = {
ABOUT: 'about',
DISCUSSION: DISCUSSION_PAGE,
EDIT: 'edit',
SUBSCRIPTION: 'subscription',
};
type Props = {
@@ -94,7 +94,7 @@ function ChannelPage(props: Props) {
const { channelName } = parseURI(uri);
const { permanent_url: permanentUrl } = claim;
const claimId = claim.claim_id;
const formattedSubCount = formatNumber(subCount, 2, true);
const formattedSubCount = Number(subCount).toLocaleString();
const isBlocked = claim && blockedChannels.includes(claim.permanent_url);
const isMuted = claim && mutedChannels.includes(claim.permanent_url);
const isMyYouTubeChannel =
@@ -160,6 +160,9 @@ function ChannelPage(props: Props) {
case PAGE.DISCUSSION:
tabIndex = 3;
break;
case PAGE.SUBSCRIPTION:
tabIndex = 4;
break;
default:
tabIndex = 0;
break;
@@ -175,8 +178,10 @@ function ChannelPage(props: Props) {
search += `${PAGE_VIEW_QUERY}=${PAGE.LISTS}`;
} else if (newTabIndex === 2) {
search += `${PAGE_VIEW_QUERY}=${PAGE.ABOUT}`;
} else {
} else if (newTabIndex === 3) {
search += `${PAGE_VIEW_QUERY}=${PAGE.DISCUSSION}`;
} else {
search += `${PAGE_VIEW_QUERY}=${PAGE.SUBSCRIPTION}`;
}
push(`${url}${search}`);
+10 -4
View File
@@ -9,8 +9,13 @@ import {
} from 'redux/selectors/notifications';
import { doCommentReactList } from 'redux/actions/comments';
import { selectActiveChannelClaim } from 'redux/selectors/app';
import { doReadNotifications, doNotificationList, doSeeAllNotifications } from 'redux/actions/notifications';
import {
doLbryioNotificationsMarkRead,
doLbryioNotificationList,
doLbryioSeeAllNotifications,
} from 'redux/actions/notifications';
import NotificationsPage from './view';
import { selectUser } from 'redux/selectors/user';
const select = (state) => ({
notifications: selectNotifications(state),
@@ -20,11 +25,12 @@ const select = (state) => ({
unreadCount: selectUnreadNotificationCount(state),
unseenCount: selectUnseenNotificationCount(state),
activeChannel: selectActiveChannelClaim(state),
user: selectUser(state),
});
export default connect(select, {
doReadNotifications,
doNotificationList,
doSeeAllNotifications,
doLbryioNotificationsMarkRead,
doLbryioNotificationList,
doLbryioSeeAllNotifications,
doCommentReactList,
})(NotificationsPage);
+38 -14
View File
@@ -14,32 +14,38 @@ import { RULE } from 'constants/notifications';
type Props = {
notifications: Array<Notification>,
localNotifications: Array<Notification>,
notificationsFiltered: Array<Notification>,
notificationCategories: Array<NotificationCategory>,
fetching: boolean,
unreadCount: number,
unseenCount: number,
doSeeAllNotifications: () => void,
doReadNotifications: () => void,
doNotificationList: (?Array<string>) => void,
doLbryioSeeAllNotifications: () => void,
doLbryioNotificationsMarkRead: () => void,
doLbryioNotificationList: (?Array<string>) => void,
activeChannel: ?ChannelClaim,
doCommentReactList: (Array<string>) => Promise<any>,
user: User,
};
export default function NotificationsPage(props: Props) {
const {
notifications,
notificationsFiltered,
localNotifications,
fetching,
unreadCount,
unseenCount,
doSeeAllNotifications,
doReadNotifications,
doNotificationList,
doLbryioSeeAllNotifications,
doLbryioNotificationsMarkRead,
doLbryioNotificationList,
notificationCategories,
activeChannel,
doCommentReactList,
user,
} = props;
// const localCategories = [{ name: 'New Content', types: ['new_content'] }];
const legacyNotificationsEnabled = user && user.experimental_ui;
const initialFetchDone = useFetched(fetching);
const [name, setName] = usePersistedState('notifications--rule', NOTIFICATIONS.NOTIFICATION_NAME_ALL);
const isFiltered = name !== NOTIFICATIONS.NOTIFICATION_NAME_ALL;
@@ -81,9 +87,9 @@ export default function NotificationsPage(props: Props) {
React.useEffect(() => {
if (unseenCount > 0) {
doSeeAllNotifications();
doLbryioSeeAllNotifications();
}
}, [unseenCount, doSeeAllNotifications]);
}, [unseenCount, doLbryioSeeAllNotifications]);
const stringifiedNotificationCategories = JSON.stringify(notificationCategories);
React.useEffect(() => {
@@ -97,7 +103,7 @@ export default function NotificationsPage(props: Props) {
try {
const matchingCategory = arrayNotificationCategories.find((category) => category.name === name);
if (matchingCategory) {
doNotificationList(matchingCategory.types);
doLbryioNotificationList(matchingCategory.types);
}
} catch (e) {
console.error(e);
@@ -113,10 +119,18 @@ export default function NotificationsPage(props: Props) {
<div className="claim-list__alt-controls--wrap">
{fetching && <Spinner type="small" />}
{unreadCount > 0 && (
<Button icon={ICONS.EYE} onClick={doReadNotifications} button="secondary" label={__('Mark all as read')} />
{legacyNotificationsEnabled && unreadCount > 0 && (
<Button
icon={ICONS.EYE}
onClick={doLbryioNotificationsMarkRead}
button="secondary"
label={__('Mark all as read')}
/>
)}
{notificationCategories && (
{!legacyNotificationsEnabled && unreadCount > 0 && (
<Button icon={ICONS.EYE} onClick={() => alert('clear')} button="secondary" label={__('Mark all as read')} />
)}
{legacyNotificationsEnabled && notificationCategories && (
<FormField
className="notification__filter"
type="select"
@@ -135,7 +149,7 @@ export default function NotificationsPage(props: Props) {
)}
</div>
</div>
{list && list.length > 0 && !(isFiltered && fetching) ? (
{legacyNotificationsEnabled && list && list.length > 0 && !(isFiltered && fetching) && (
<div className="card">
<div className="notification_list">
{list.map((notification) => {
@@ -143,7 +157,17 @@ export default function NotificationsPage(props: Props) {
})}
</div>
</div>
) : (
)}
{!legacyNotificationsEnabled && localNotifications && localNotifications.length > 0 && (
<div className="card">
<div className="notification_list">
{localNotifications.map((notification) => {
return <Notification key={notification.id} notification={notification} local />;
})}
</div>
</div>
)}
{!(legacyNotificationsEnabled && list && list.length > 0 && !(isFiltered && fetching)) && (
<div className="main--empty">
{!fetching && (
<Yrbl
-2
View File
@@ -5,7 +5,6 @@ import SettingAccount from 'component/settingAccount';
import SettingAppearance from 'component/settingAppearance';
import SettingContent from 'component/settingContent';
import SettingSystem from 'component/settingSystem';
import SettingStorage from 'component/settingStorage';
type DaemonSettings = {
download_dir: string,
@@ -52,7 +51,6 @@ class SettingsPage extends React.PureComponent<Props> {
<SettingAccount />
<SettingContent />
<SettingSystem />
<SettingStorage />
</div>
)}
</Page>
+4 -20
View File
@@ -1,17 +1,14 @@
// @flow
import React from 'react';
import PrivacyAgreement from 'component/privacyAgreement';
import HostingSplash from 'component/hostingSplash';
import HostingSplashCustom from 'component/hostingSplashCustom';
import WelcomeSplash from 'component/welcomeSplash';
import Page from 'component/page';
import { useHistory } from 'react-router-dom';
const SPLASH_PAGE = 0;
const PRIVACY_PAGE = 1;
const HOSTING_PAGE = 2;
const HOSTING_ADVANCED = 3;
// const HOSTING_PAGE = 2;
// const WELCOME_PAGES = [SPLASH_PAGE, PRIVACY_PAGE];
type DaemonStatus = {
disk_space: {
content_blobs_storage_used_mb: string,
@@ -47,16 +44,6 @@ export default function Welcome(props: Props) {
const handleNextPage = () => {
if (welcomePage === SPLASH_PAGE) {
setWelcomePage(PRIVACY_PAGE);
} else if (welcomePage === PRIVACY_PAGE) {
setWelcomePage(HOSTING_PAGE);
} else if (welcomePage === HOSTING_PAGE) {
setWelcomePage(HOSTING_ADVANCED);
}
};
const handleGoBack = () => {
if (welcomePage >= 1) {
setWelcomePage(welcomePage - 1);
}
};
@@ -68,11 +55,8 @@ export default function Welcome(props: Props) {
return (
<Page noHeader noSideNavigation>
{welcomePage === SPLASH_PAGE && <WelcomeSplash handleNextPage={handleNextPage} />}
{welcomePage === PRIVACY_PAGE && <PrivacyAgreement handleNextPage={handleNextPage} />}
{welcomePage === HOSTING_PAGE && <HostingSplash handleNextPage={handleNextPage} handleDone={handleDone} />}
{welcomePage === HOSTING_ADVANCED && (
<HostingSplashCustom handleNextPage={handleDone} handleGoBack={handleGoBack} />
)}
{welcomePage === PRIVACY_PAGE && <PrivacyAgreement handleNextPage={handleDone} />}
{/* {welcomePage === HOSTING_PAGE && } */}
</Page>
);
}
-12
View File
@@ -1,12 +0,0 @@
import { connect } from 'react-redux';
import { selectYoutubeChannels } from 'redux/selectors/user';
import { doUserFetch } from 'redux/actions/user';
import CreatorDashboardPage from './view';
const select = state => ({
youtubeChannels: selectYoutubeChannels(state),
});
export default connect(select, {
doUserFetch,
})(CreatorDashboardPage);
-216
View File
@@ -1,216 +0,0 @@
// @flow
import { SITE_NAME, DOMAIN } from 'config';
import * as PAGES from 'constants/pages';
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
import React from 'react';
import Page from 'component/page';
import Button from 'component/button';
import Card from 'component/common/card';
import I18nMessage from 'component/i18nMessage';
import { Form, FormField } from 'component/common/form';
import { INVALID_NAME_ERROR } from 'constants/claim';
import { isNameValid } from 'util/lbryURI';
import { Lbryio } from 'lbryinc';
import { useHistory } from 'react-router';
import YoutubeTransferStatus from 'component/youtubeTransferStatus';
import Nag from 'component/common/nag';
import { getDefaultLanguage, sortLanguageMap } from 'util/default-languages';
const STATUS_TOKEN_PARAM = 'status_token';
const ERROR_MESSAGE_PARAM = 'error_message';
const NEW_CHANNEL_PARAM = 'new_channel';
type Props = {
youtubeChannels: ?Array<{ transfer_state: string, sync_status: string }>,
doUserFetch: () => void,
inSignUpFlow?: boolean,
doToggleInterestedInYoutubeSync: () => void,
};
export default function YoutubeSync(props: Props) {
const { youtubeChannels, doUserFetch, inSignUpFlow = false, doToggleInterestedInYoutubeSync } = props;
const {
location: { search, pathname },
push,
replace,
} = useHistory();
const urlParams = new URLSearchParams(search);
const statusToken = urlParams.get(STATUS_TOKEN_PARAM);
const errorMessage = urlParams.get(ERROR_MESSAGE_PARAM);
const newChannelParam = urlParams.get(NEW_CHANNEL_PARAM);
const [channel, setChannel] = React.useState('');
const [language, setLanguage] = React.useState(getDefaultLanguage());
const [nameError, setNameError] = React.useState(undefined);
const [acknowledgedTerms, setAcknowledgedTerms] = React.useState(false);
const [addingNewChannel, setAddingNewChannel] = React.useState(newChannelParam);
const hasYoutubeChannels = youtubeChannels && youtubeChannels.length > 0;
React.useEffect(() => {
const urlParamsInEffect = new URLSearchParams(search);
if (!urlParamsInEffect.get('reset_scroll')) {
urlParamsInEffect.append('reset_scroll', 'youtube');
}
replace(`?${urlParamsInEffect.toString()}`);
}, [pathname, search]);
React.useEffect(() => {
if (statusToken && !hasYoutubeChannels) {
doUserFetch();
}
}, [statusToken, hasYoutubeChannels, doUserFetch]);
React.useEffect(() => {
if (!newChannelParam) {
setAddingNewChannel(false);
}
}, [newChannelParam]);
function handleCreateChannel() {
Lbryio.call('yt', 'new', {
type: 'sync',
immediate_sync: true,
channel_language: language,
desired_lbry_channel_name: `@${channel}`,
return_url: `https://${DOMAIN}/$/${inSignUpFlow ? PAGES.AUTH : PAGES.YOUTUBE_SYNC}`,
}).then((ytAuthUrl) => {
// react-router isn't needed since it's a different domain
window.location.href = ytAuthUrl;
});
}
function handleChannelChange(e) {
const { value } = e.target;
setChannel(value);
if (!isNameValid(value)) {
setNameError(INVALID_NAME_ERROR);
} else {
setNameError();
}
}
function handleNewChannel() {
urlParams.append('new_channel', 'true');
push(`${pathname}?${urlParams.toString()}`);
setAddingNewChannel(true);
}
const Wrapper = (props: { children: any }) => {
return inSignUpFlow ? (
<>{props.children}</>
) : (
<Page noSideNavigation authPage>
{props.children}
</Page>
);
};
return (
<Wrapper>
<div className="main__channel-creation">
{hasYoutubeChannels && !addingNewChannel ? (
<YoutubeTransferStatus alwaysShow addNewChannel={handleNewChannel} />
) : (
<Card
title={__('Sync your YouTube channel to %site_name%', { site_name: 'LBRY' })}
subtitle={__('Get your YouTube videos in front of the %site_name% audience.', {
site_name: 'LBRY',
})}
actions={
<Form onSubmit={handleCreateChannel}>
<fieldset-group class="fieldset-group--smushed fieldset-group--disabled-prefix">
<fieldset-section>
<label htmlFor="auth_first_channel">
{nameError ? (
<span className="error__text">{nameError}</span>
) : (
__('Your %site_name% channel name', { site_name: 'LBRY' })
)}
</label>
<div className="form-field__prefix">@</div>
</fieldset-section>
<FormField
autoFocus
placeholder={__('channel')}
type="text"
name="yt_sync_channel"
className="form-field--short"
value={channel}
onChange={handleChannelChange}
/>
</fieldset-group>
<FormField
name="language_select"
type="select"
label={__('Channel language')}
onChange={(event) => setLanguage(event.target.value)}
value={language}
>
{sortLanguageMap(SUPPORTED_LANGUAGES).map(([langKey, langName]) => (
<option key={langKey} value={langKey}>
{langName}
</option>
))}
</FormField>
<FormField
type="checkbox"
name="yt_sync_terms"
checked={acknowledgedTerms}
onChange={() => setAcknowledgedTerms(!acknowledgedTerms)}
label={
<I18nMessage
tokens={{
terms: (
<Button button="link" label={__('these terms')} href="https://lbry.com/faq/youtube-terms" />
),
faq: (
<Button
button="link"
label={__('how the program works')}
href="https://lbry.com/faq/youtube"
/>
),
site_name: SITE_NAME,
}}
>
I want to sync my content to %site_name% and the LBRY network and agree to %terms%. I have also
read and understand %faq%.
</I18nMessage>
}
/>
<div className="section__actions">
<Button
button="primary"
type="submit"
disabled={nameError || !channel || !acknowledgedTerms}
label={__('Claim Now')}
/>
{inSignUpFlow && !errorMessage && (
<Button button="link" label={__('Skip')} onClick={() => doToggleInterestedInYoutubeSync()} />
)}
{errorMessage && <Button button="link" label={__('Skip')} navigate={`/$/${PAGES.REWARDS}`} />}
</div>
<div className="help--card-actions">
<I18nMessage
tokens={{
learn_more: <Button button="link" label={__('Learn more')} href="https://lbry.com/faq/youtube" />,
}}
>
This will verify you are an active YouTuber. Channel names cannot be changed once chosen, please be
extra careful. Additional instructions will be emailed to you after you verify your email on the
next page. %learn_more%.
</I18nMessage>
</div>
</Form>
}
nag={errorMessage && <Nag message={errorMessage} type="error" relative />}
/>
)}
</div>
</Wrapper>
);
}
+26 -16
View File
@@ -7,7 +7,7 @@ import * as MODALS from 'constants/modal_types';
import * as SETTINGS from 'constants/settings';
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
import * as SHARED_PREFERENCES from 'constants/shared_preferences';
import { DOMAIN } from 'config';
import { CLOUD_DOMAIN } from 'config';
import Lbry from 'lbry';
import { doFetchChannelListMine, doFetchCollectionListMine, doCheckPendingClaims } from 'redux/actions/claims';
import { selectClaimForUri, selectClaimIsMineForUri, selectMyChannelClaims } from 'redux/selectors/claims';
@@ -16,7 +16,7 @@ import { doClearSupport, doBalanceSubscribe } from 'redux/actions/wallet';
import { doClearPublish } from 'redux/actions/publish';
import { Lbryio } from 'lbryinc';
import { selectFollowedTagsList } from 'redux/selectors/tags';
import { doToast, doError, doNotificationList } from 'redux/actions/notifications';
import { doToast, doError, doLbryioNotificationList } from 'redux/actions/notifications';
import {
doFetchDaemonSettings,
@@ -28,6 +28,7 @@ import {
import {
selectIsUpgradeSkipped,
selectUpdateUrl,
selectUpgradeDownloadItem,
selectUpgradeDownloadPath,
selectAutoUpdateDeclined,
selectRemoteVersion,
@@ -84,15 +85,6 @@ export function doStartUpgrade() {
const upgradeDownloadPath = selectUpgradeDownloadPath(state);
ipcRenderer.send('upgrade', upgradeDownloadPath);
dispatch({
type: ACTIONS.UPGRADE_INIT_INSTALL,
});
};
}
export function doShowUpgradeInstallationError() {
return {
type: ACTIONS.UPGRADE_INSTALL_ERROR,
};
}
@@ -162,8 +154,25 @@ export function doAutoUpdateDeclined() {
}
export function doCancelUpgrade() {
ipcRenderer.send('cancel-download-upgrade');
return { type: ACTIONS.UPGRADE_CANCELLED };
return (dispatch, getState) => {
const state = getState();
const upgradeDownloadItem = selectUpgradeDownloadItem(state);
if (upgradeDownloadItem) {
/*
* Right now the remote reference to the download item gets garbage collected as soon as the
* the download is over (maybe even earlier), so trying to cancel a finished download may
* throw an error.
*/
try {
upgradeDownloadItem.cancel();
} catch (err) {
console.error(err); // eslint-disable-line no-console
}
}
dispatch({ type: ACTIONS.UPGRADE_CANCELLED });
};
}
export function doCheckUpgradeAvailable() {
@@ -327,11 +336,12 @@ export function doDaemonReady() {
}
},
undefined,
DOMAIN
CLOUD_DOMAIN
)
);
dispatch({ type: ACTIONS.DAEMON_READY });
// @if TARGET='app'
dispatch(doBalanceSubscribe());
dispatch(doSetAutoLaunch());
dispatch(doFindFFmpeg());
@@ -342,7 +352,7 @@ export function doDaemonReady() {
dispatch(doCheckUpgradeAvailable());
}
dispatch(doCheckUpgradeSubscribe());
ipcRenderer.send('get-disk-space');
// @endif
};
}
@@ -499,7 +509,7 @@ export function doSignIn() {
dispatch(doNotificationSocketConnect(notificationsEnabled));
if (notificationsEnabled) {
dispatch(doNotificationList());
dispatch(doLbryioNotificationList());
}
dispatch(doCheckPendingClaims());
+5 -5
View File
@@ -7,7 +7,7 @@ import Lbry from 'lbry';
import { parseURI, buildURI, isURIEqual } from 'util/lbryURI';
import { selectClaimsByUri, selectMyChannelClaims } from 'redux/selectors/claims';
import { doClaimSearch } from 'redux/actions/claims';
import { doToast, doSeeNotifications } from 'redux/actions/notifications';
import { doToast, doLbryioNotificationsMarkSeen } from 'redux/actions/notifications';
import {
selectMyReactsForComment,
selectOthersReactsForComment,
@@ -452,7 +452,7 @@ export function doCommentReact(commentId: string, type: string) {
}
if (notification && !notification.is_seen) {
dispatch(doSeeNotifications([notification.id]));
dispatch(doLbryioNotificationsMarkSeen([notification.id]));
}
const exclusiveTypes = {
@@ -593,7 +593,7 @@ export function doCommentCreate(
// send a notification
const notification = parent_id && makeSelectNotificationForCommentId(parent_id)(state);
if (notification && !notification.is_seen) dispatch(doSeeNotifications([notification.id]));
if (notification && !notification.is_seen) dispatch(doLbryioNotificationsMarkSeen([notification.id]));
if (!signatureData) {
return dispatch(doToast({ isError: true, message: __('Unable to verify your channel. Please try again.') }));
@@ -1197,7 +1197,7 @@ export function doFetchModBlockedList() {
if (blockedChannel.blocked_channel_name) {
const channelUri = buildURI({
channelName: blockedChannel.blocked_channel_name,
channelClaimId: blockedChannel.blocked_channel_id,
claimId: blockedChannel.blocked_channel_id,
});
if (!blockedList.find((blockedChannel) => isURIEqual(blockedChannel.channelUri, channelUri))) {
@@ -1215,7 +1215,7 @@ export function doFetchModBlockedList() {
if (blockedByMap !== undefined) {
const blockedByChannelUri = buildURI({
channelName: blockedChannel.blocked_by_channel_name,
channelClaimId: blockedChannel.blocked_by_channel_id,
claimId: blockedChannel.blocked_by_channel_id,
});
if (blockedByMap[channelUri]) {
+57 -17
View File
@@ -5,6 +5,7 @@ import { Lbryio } from 'lbryinc';
import { v4 as uuid } from 'uuid';
import {
selectNotifications,
selectNotificationsLocal,
selectNotificationsFiltered,
selectNotificationCategories,
} from 'redux/selectors/notifications';
@@ -45,12 +46,12 @@ export function doDismissError() {
};
}
export function doNotificationList(types?: Array<string>) {
export function doLbryioNotificationList(types?: Array<string>) {
return async (dispatch: Dispatch, getState: GetState) => {
const state = getState();
const notificationTypes = selectNotificationCategories(state);
dispatch({ type: ACTIONS.NOTIFICATION_LIST_STARTED });
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_LIST_STARTED });
let params: any = { is_app_readable: true };
if (types) {
@@ -62,7 +63,7 @@ export function doNotificationList(types?: Array<string>) {
const notificationCategories = await Lbryio.call('notification', 'categories');
if (notificationCategories) {
dispatch({
type: ACTIONS.NOTIFICATION_CATEGORIES_COMPLETED,
type: ACTIONS.LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED,
data: {
notificationCategories: notificationCategories.reverse(),
},
@@ -94,7 +95,7 @@ export function doNotificationList(types?: Array<string>) {
dispatch(doResolveUris(channelsToResolve));
dispatch({
type: ACTIONS.NOTIFICATION_LIST_COMPLETED,
type: ACTIONS.LBRYIO_NOTIFICATION_LIST_COMPLETED,
data: {
newNotifications: notifications,
filterRule: Boolean(types),
@@ -102,12 +103,12 @@ export function doNotificationList(types?: Array<string>) {
});
});
} catch (error) {
dispatch({ type: ACTIONS.NOTIFICATION_LIST_FAILED, data: { error } });
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_LIST_FAILED, data: { error } });
}
};
}
export function doReadNotifications(notificationsIds: Array<number>) {
export function doLbryioNotificationsMarkRead(notificationsIds: Array<number>) {
return (dispatch: Dispatch, getState: GetState) => {
const state = getState();
const notifications = selectNotifications(state);
@@ -127,36 +128,36 @@ export function doReadNotifications(notificationsIds: Array<number>) {
ids = Array.from(new Set([...getUnreadIds(notifications), ...getUnreadIds(notificationsFiltered)]));
}
dispatch({ type: ACTIONS.NOTIFICATION_READ_STARTED });
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_READ_STARTED });
return Lbryio.call('notification', 'edit', { notification_ids: ids.join(','), is_read: true })
.then(() => {
dispatch({ type: ACTIONS.NOTIFICATION_READ_COMPLETED, data: { notificationIds: ids } });
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_READ_COMPLETED, data: { notificationIds: ids } });
})
.catch((error) => {
dispatch({ type: ACTIONS.NOTIFICATION_READ_FAILED, data: { error } });
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_READ_FAILED, data: { error } });
});
};
}
export function doSeeNotifications(notificationIds: Array<string>) {
export function doLbryioNotificationsMarkSeen(notificationIds: Array<string>) {
return (dispatch: Dispatch) => {
dispatch({ type: ACTIONS.NOTIFICATION_SEEN_STARTED });
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_SEEN_STARTED });
return Lbryio.call('notification', 'edit', { notification_ids: notificationIds.join(','), is_seen: true })
.then(() => {
dispatch({
type: ACTIONS.NOTIFICATION_SEEN_COMPLETED,
type: ACTIONS.LBRYIO_NOTIFICATION_SEEN_COMPLETED,
data: {
notificationIds,
},
});
})
.catch((error) => {
dispatch({ type: ACTIONS.NOTIFICATION_SEEN_FAILED, data: { error } });
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_SEEN_FAILED, data: { error } });
});
};
}
export function doSeeAllNotifications() {
export function doLbryioSeeAllNotifications() {
return (dispatch: Dispatch, getState: GetState) => {
const state = getState();
const notifications = selectNotifications(state);
@@ -169,18 +170,57 @@ export function doSeeAllNotifications() {
const getUnseenIds = (list) => list.filter((n) => !n.is_seen).map((n) => n.id);
const unseenIds = Array.from(new Set([...getUnseenIds(notifications), ...getUnseenIds(notificationsFiltered)]));
dispatch(doSeeNotifications(unseenIds));
dispatch(doLbryioNotificationsMarkSeen(unseenIds));
};
}
export function doDeleteNotification(notificationId: number) {
export function doLbryioDeleteNotification(notificationId: number) {
return (dispatch: Dispatch) => {
Lbryio.call('notification', 'delete', { notification_ids: notificationId })
.then(() => {
dispatch({ type: ACTIONS.NOTIFICATION_DELETE_COMPLETED, data: { notificationId } });
dispatch({ type: ACTIONS.LBRYIO_NOTIFICATION_DELETE_COMPLETED, data: { notificationId } });
})
.catch(() => {
dispatch(doToast({ isError: true, message: __('Unable to delete this right now. Please try again later.') }));
});
};
}
export function doLocalAddNotification(notifications: Array<any>) {
return (dispatch: Dispatch) => {
dispatch({ type: ACTIONS.LOCAL_NOTIFICATION_ADD, data: { notifications } });
};
}
export function doLocalDeleteNotification(notificationId: number) {
return (dispatch: Dispatch) => {
dispatch({ type: ACTIONS.LOCAL_NOTIFICATION_DELETE, data: { notificationId } });
};
}
export function doLocalSeeNotification(notificationIds: Array<string>) {
return (dispatch: Dispatch) => {
dispatch({
type: ACTIONS.LOCAL_NOTIFICATION_SEEN,
data: {
notificationIds,
},
});
};
}
export function doLocalSeeAllNotifications() {
return (dispatch: Dispatch, getState: GetState) => {
const state = getState();
const notifications = selectNotificationsLocal(state);
if (!notifications) {
return;
}
const getUnseenIds = (list) => list.filter((n) => !n.is_seen).map((n) => n.id);
const unseenIds = Array.from(new Set([...getUnseenIds(notifications)]));
dispatch(doLbryioNotificationsMarkSeen(unseenIds));
};
}
+18 -44
View File
@@ -85,7 +85,7 @@ export function doClearDaemonSetting(key) {
});
}
if (key === DAEMON_SETTINGS.LBRYUM_SERVERS) {
dispatch(doWalletReconnect(true));
dispatch(doWalletReconnect());
}
});
Lbry.settings_get().then((settings) => {
@@ -104,62 +104,36 @@ export function doSetDaemonSetting(key, value, doNotDispatch = false) {
return (dispatch, getState) => {
const state = getState();
const ready = selectPrefsReady(state);
if (!ready) {
return dispatch(doAlertWaitingForSync());
}
dispatch({
type: ACTIONS.SETTING_DAEMON_SETTINGS,
data: {
val: true,
},
});
const newSettings = {
key,
value: !value && value !== false ? null : value,
};
Lbry.settings_set(newSettings)
.then((newSetting) => {
if (SDK_SYNC_KEYS.includes(key) && !doNotDispatch) {
dispatch({
type: ACTIONS.SHARED_PREFERENCE_SET,
data: { key: key, value: newSetting[key] },
});
}
// hardcoding this in lieu of a better solution
if (key === DAEMON_SETTINGS.LBRYUM_SERVERS) {
dispatch(doWalletReconnect());
// todo: add sdk reloadsettings() (or it happens automagically?)
}
})
.then(() => {
dispatch(doFetchDaemonSettings());
})
.then(() => {
Lbry.settings_set(newSettings).then((newSetting) => {
if (SDK_SYNC_KEYS.includes(key) && !doNotDispatch) {
dispatch({
type: ACTIONS.SETTING_DAEMON_SETTINGS,
data: {
val: false,
},
type: ACTIONS.SHARED_PREFERENCE_SET,
data: { key: key, value: newSetting[key] },
});
})
.catch((e) => {
console.log('error setting or fetching daemon setting', e.message);
dispatch({
type: ACTIONS.SETTING_DAEMON_SETTINGS,
data: {
val: false,
},
});
});
}
// hardcoding this in lieu of a better solution
if (key === DAEMON_SETTINGS.LBRYUM_SERVERS) {
dispatch(doWalletReconnect());
// todo: add sdk reloadsettings() (or it happens automagically?)
}
});
dispatch(doFetchDaemonSettings());
};
}
export function doCleanBlobs(fetchAfter = true) {
export function doCleanBlobs() {
return (dispatch) => {
return Lbry.blob_clean().then(() => {
if (fetchAfter) {
dispatch(doFetchDaemonSettings());
}
Lbry.blob_clean().then(() => {
dispatch(doFetchDaemonSettings());
return 'done';
});
};
+118 -1
View File
@@ -5,7 +5,17 @@ import { Lbryio } from 'lbryinc';
import { doClaimRewardType } from 'redux/actions/rewards';
import { parseURI } from 'util/lbryURI';
import { doAlertWaitingForSync } from 'redux/actions/app';
import { doToast } from 'redux/actions/notifications';
import { doLocalAddNotification, doToast } from 'redux/actions/notifications';
import { setUnion } from 'util/set-operations';
import { getNotificationFromClaim } from 'util/notifications';
import {
makeSelectNotificationsDisabled,
selectDownloadEnabledUrls,
makeSelectLastReleaseForUri,
selectSubscriptionUris,
} from 'redux/selectors/subscriptions';
import Lbry from '../../lbry';
type SubscriptionArgs = {
channelName: string,
@@ -85,3 +95,110 @@ export function doChannelUnsubscribe(subscription: SubscriptionArgs, followToast
return dispatch(doToggleSubscription(subscription, followToast, true));
};
}
export function doAddUriToDownloadQueue(uri: string) {
return (dispatch: Dispatch) => {
return dispatch(doAddUrisToDownloadQueue([uri]));
};
}
export function doAddUrisToDownloadQueue(uris: Array<string>) {
return (dispatch: Dispatch) => {
return dispatch({
type: ACTIONS.SUBSCRIPTION_DOWNLOAD_ADD,
data: uris,
});
};
}
export function doRemoveUriFromDownloadQueue(uri: string) {
return (dispatch: Dispatch) => {
return dispatch({
type: ACTIONS.SUBSCRIPTION_DOWNLOAD_REMOVE,
data: uri,
});
};
}
export function doUpdateLastReleasesForUri(entries: { [string]: number }) {
return (dispatch: Dispatch) => {
return dispatch({
type: ACTIONS.SUBSCRIPTION_RELEASE_UPDATE,
// data: entries = { [uri]: timestamp } >
data: entries,
});
};
}
export function doSubscriptionDownloadEnableForUri(uri: string, enable: boolean) {
return (dispatch: Dispatch) => {
return dispatch({
type: ACTIONS.SUBSCRIPTION_DOWNLOAD_TOGGLE,
data: { uri, enable },
});
};
}
export function doCheckChannelPublishes() {
// finish this
return async (dispatch: Dispatch, getState: GetState) => {
const state = getState();
// for sub in subs, if notify+ or download+, getnewpublishes()
const subs = new Set(selectSubscriptionUris(state));
const dls = new Set(selectDownloadEnabledUrls(state));
const channels = Array.from(setUnion(subs, dls));
for (const channelUri of channels) {
// $FlowFixMe
const hasNotify = !makeSelectNotificationsDisabled(channelUri)(state); // eslint-disable-line
const hasDownload = dls.has(channelUri);
const lastRelease = makeSelectLastReleaseForUri(channelUri)(state);
if (hasNotify || hasDownload) {
// getNewPublishes since ???
let lastTime = Math.floor(Date.now() / 1000);
const results = await Lbry.claim_search({
channel: channelUri,
release_time: `>${lastRelease}`,
order_by: ['release_time'],
});
const latest = results.items;
if (latest.length && latest[0].value && latest[0].value.release_time) {
lastTime = latest[0].value.release_time;
}
// dispatch release time update()
const notifications = [];
const downloads = [];
const releaseEntries = {}; // refactor to {} maybe
for (const claim of latest) {
if (hasNotify) {
const notification = getNotificationFromClaim(claim);
notifications.push(notification);
}
if (hasDownload) {
downloads.push(claim.permanent_url);
}
releaseEntries[channelUri] = lastTime;
}
dispatch(doLocalAddNotification(notifications));
dispatch(doAddUrisToDownloadQueue(downloads));
// dispatch last check for channelUri
dispatch(doUpdateLastReleasesForUri(releaseEntries));
}
}
// do download
};
}
export function doCheckChannelsSubscribe() {
return (dispatch: Dispatch) => {
dispatch(doCheckChannelPublishes());
setInterval(() => dispatch(doCheckChannelPublishes()), 10000);
};
}
export function doDownloadQueue() {
return (dispatch: Dispatch) => {
// for each download, trigger download,
// if downloading, back off
};
}
+3 -58
View File
@@ -9,42 +9,11 @@ import { doClaimRewardType, doRewardList } from 'redux/actions/rewards';
import { selectEmailToVerify, selectPhoneToVerify, selectUserCountryCode, selectUser } from 'redux/selectors/user';
import rewards from 'rewards';
import { Lbryio } from 'lbryinc';
import { DOMAIN } from 'config';
import { CLOUD_DOMAIN } from 'config';
import { getDefaultLanguage } from 'util/default-languages';
const AUTH_IN_PROGRESS = 'authInProgress';
export let sessionStorageAvailable = false;
export function doFetchInviteStatus(shouldCallRewardList = true) {
return (dispatch) => {
dispatch({
type: ACTIONS.USER_INVITE_STATUS_FETCH_STARTED,
});
Promise.all([Lbryio.call('user', 'invite_status'), Lbryio.call('user_referral_code', 'list')])
.then(([status, code]) => {
if (shouldCallRewardList) {
dispatch(doRewardList());
}
dispatch({
type: ACTIONS.USER_INVITE_STATUS_FETCH_SUCCESS,
data: {
invitesRemaining: status.invites_remaining ? status.invites_remaining : 0,
invitees: status.invitees,
referralLink: `${Lbryio.CONNECTION_STRING}user/refer?r=${code}`,
referralCode: code,
},
});
})
.catch((error) => {
dispatch({
type: ACTIONS.USER_INVITE_STATUS_FETCH_FAILURE,
data: { error },
});
});
};
}
export function doInstallNew(appVersion, os = null, firebaseToken = null, callbackForUsersWhoAreSharingData, domain) {
const payload = { app_version: appVersion, domain };
if (firebaseToken) {
@@ -53,7 +22,7 @@ export function doInstallNew(appVersion, os = null, firebaseToken = null, callba
Lbry.status().then((status) => {
payload.app_id =
domain && domain !== 'lbry.tv'
domain && domain !== 'lbry.com'
? (domain.replace(/[.]/gi, '') + status.installation_id).slice(0, 66)
: status.installation_id;
payload.node_id = status.lbry_id;
@@ -70,30 +39,6 @@ export function doInstallNew(appVersion, os = null, firebaseToken = null, callba
});
}
export function doInstallNewWithParams(
appVersion,
installationId,
nodeId,
lbrynetVersion,
os,
platform,
firebaseToken = null
) {
return () => {
const payload = { app_version: appVersion };
if (firebaseToken) {
payload.firebase_token = firebaseToken;
}
payload.app_id = installationId;
payload.node_id = nodeId;
payload.daemon_version = lbrynetVersion;
payload.operating_system = os;
payload.platform = platform;
Lbryio.call('install', 'new', payload);
};
}
// TODO: Call doInstallNew separately so we don't have to pass appVersion and os_system params?
export function doAuthenticate(
appVersion,
@@ -108,7 +53,7 @@ export function doAuthenticate(
dispatch({
type: ACTIONS.AUTHENTICATION_STARTED,
});
return Lbryio.authenticate(DOMAIN, getDefaultLanguage())
return Lbryio.authenticate(CLOUD_DOMAIN, getDefaultLanguage()) // lbry.tv
.then((user) => {
if (sessionStorageAvailable) window.sessionStorage.removeItem(AUTH_IN_PROGRESS);
Lbryio.getAuthToken().then((token) => {
+44 -53
View File
@@ -524,11 +524,10 @@ export function doSupportAbandonForClaim(claimId, claimType, keep, preview) {
};
}
export function doWalletReconnect(toDefaultServer = false) {
export function doWalletReconnect() {
return (dispatch, getState) => {
dispatch({
type: ACTIONS.WALLET_RESTART,
data: toDefaultServer,
});
let failed = false;
// this basically returns null when it's done. :(
@@ -546,24 +545,15 @@ export function doWalletReconnect(toDefaultServer = false) {
});
dispatch(
doToast({
message: __('Your servers were not available. Rolling back to the default server.'),
message: __('Your servers were not available. Check your url and port, or switch back to defaults.'),
isError: true,
})
);
dispatch({
type: ACTIONS.WALLET_ROLLBACK_DEFAULT,
});
}
}, FIFTEEN_SECONDS);
Lbry.wallet_reconnect().then(() => {
clearTimeout(walletTimeout);
if (failed) {
dispatch({
type: ACTIONS.WALLET_ROLLBACK_DEFAULT,
});
} else {
dispatch({ type: ACTIONS.WALLET_RESTART_COMPLETED });
}
if (!failed) dispatch({ type: ACTIONS.WALLET_RESTART_COMPLETED });
});
};
}
@@ -719,44 +709,45 @@ export const doCheckPendingTxs = () => (dispatch, getState) => {
};
// don't need hthis
export const doSendCashTip =
(tipParams, anonymous, userParams, claimId, stripeEnvironment, successCallback) => (dispatch) => {
Lbryio.call(
'customer',
'tip',
{
// round to fix issues with floating point numbers
amount: Math.round(100 * tipParams.tipAmount), // convert from dollars to cents
creator_channel_name: tipParams.tipChannelName, // creator_channel_name
creator_channel_claim_id: tipParams.channelClaimId,
tipper_channel_name: anonymous ? '' : userParams.activeChannelName,
tipper_channel_claim_id: anonymous ? '' : userParams.activeChannelId,
currency: 'USD',
anonymous: anonymous,
source_claim_id: claimId,
environment: stripeEnvironment,
},
'post'
)
.then((customerTipResponse) => {
dispatch(
doToast({
message: __("You sent $%tipAmount% as a tip to %tipChannelName%, I'm sure they appreciate it!", {
tipAmount: tipParams.tipAmount,
tipChannelName: tipParams.tipChannelName,
}),
})
);
export const doSendCashTip = (tipParams, anonymous, userParams, claimId, stripeEnvironment, successCallback) => (
dispatch
) => {
Lbryio.call(
'customer',
'tip',
{
// round to fix issues with floating point numbers
amount: Math.round(100 * tipParams.tipAmount), // convert from dollars to cents
creator_channel_name: tipParams.tipChannelName, // creator_channel_name
creator_channel_claim_id: tipParams.channelClaimId,
tipper_channel_name: anonymous ? '' : userParams.activeChannelName,
tipper_channel_claim_id: anonymous ? '' : userParams.activeChannelId,
currency: 'USD',
anonymous: anonymous,
source_claim_id: claimId,
environment: stripeEnvironment,
},
'post'
)
.then((customerTipResponse) => {
dispatch(
doToast({
message: __("You sent $%tipAmount% as a tip to %tipChannelName%, I'm sure they appreciate it!", {
tipAmount: tipParams.tipAmount,
tipChannelName: tipParams.tipChannelName,
}),
})
);
if (successCallback) successCallback(customerTipResponse);
})
.catch((error) => {
// show error message from Stripe if one exists (being passed from backend by Beamer's API currently)
dispatch(
doToast({
message: error.message || __('Sorry, there was an error in processing your payment!'),
isError: true,
})
);
});
};
if (successCallback) successCallback(customerTipResponse);
})
.catch((error) => {
// show error message from Stripe if one exists (being passed from backend by Beamer's API currently)
dispatch(
doToast({
message: error.message || __('Sorry, there was an error in processing your payment!'),
isError: true,
})
);
});
};
+2 -2
View File
@@ -1,6 +1,6 @@
import * as ACTIONS from 'constants/action_types';
import { getAuthToken } from 'util/saved-passwords';
import { doNotificationList } from 'redux/actions/notifications';
import { doLbryioNotificationList } from 'redux/actions/notifications';
import { SOCKETY_SERVER_API } from 'config';
const NOTIFICATION_WS_URL = `${SOCKETY_SERVER_API}/internal?id=`;
@@ -79,7 +79,7 @@ export const doNotificationSocketConnect = (enableNotifications) => (dispatch) =
switch (data.type) {
case 'pending_notification':
if (enableNotifications) {
dispatch(doNotificationList());
dispatch(doLbryioNotificationList());
}
break;
case 'swap-status':
+2 -15
View File
@@ -67,8 +67,6 @@ const defaultState: AppState = {
modalsAllowed: true,
hasClickedComment: false,
downloadProgress: undefined,
upgradeInitialized: false,
upgradeFailedInstallation: false,
upgradeDownloading: undefined,
upgradeDownloadComplete: undefined,
checkUpgradeTimer: undefined,
@@ -164,18 +162,6 @@ reducers[ACTIONS.UPGRADE_DOWNLOAD_STARTED] = (state) =>
upgradeDownloading: true,
});
reducers[ACTIONS.UPGRADE_INIT_INSTALL] = (state) =>
Object.assign({}, state, {
upgradeInitialized: true,
upgradeFailedInstallation: false,
});
reducers[ACTIONS.UPGRADE_INSTALL_ERROR] = (state) =>
Object.assign({}, state, {
upgradeInitialized: false,
upgradeFailedInstallation: true,
});
reducers[ACTIONS.CHANGE_MODALS_ALLOWED] = (state, action) =>
Object.assign({}, state, {
modalsAllowed: action.data.modalsAllowed,
@@ -341,9 +327,10 @@ reducers[ACTIONS.DISK_SPACE] = (state, action) => {
};
reducers[ACTIONS.SYNC_STATE_POPULATE] = (state, action) => {
const { allowAnalytics } = action.data;
const { welcomeVersion, allowAnalytics } = action.data;
return {
...state,
...(welcomeVersion !== undefined ? { welcomeVersion } : {}),
...(allowAnalytics !== undefined ? { allowAnalytics } : {}),
};
};
+46 -8
View File
@@ -4,6 +4,7 @@ import { handleActions } from 'util/redux-utils';
const defaultState: NotificationState = {
notifications: [],
localNotifications: [],
notificationsFiltered: [],
notificationCategories: undefined,
fetchingNotifications: false,
@@ -35,13 +36,13 @@ export default handleActions(
},
// Notifications
[ACTIONS.NOTIFICATION_LIST_STARTED]: (state, action) => {
[ACTIONS.LBRYIO_NOTIFICATION_LIST_STARTED]: (state) => {
return {
...state,
fetchingNotifications: true,
};
},
[ACTIONS.NOTIFICATION_LIST_COMPLETED]: (state, action) => {
[ACTIONS.LBRYIO_NOTIFICATION_LIST_COMPLETED]: (state, action) => {
const { filterRule, newNotifications } = action.data;
if (filterRule) {
return {
@@ -57,13 +58,13 @@ export default handleActions(
};
}
},
[ACTIONS.NOTIFICATION_LIST_FAILED]: (state, action) => {
[ACTIONS.LBRYIO_NOTIFICATION_LIST_FAILED]: (state) => {
return {
...state,
fetchingNotifications: false,
};
},
[ACTIONS.NOTIFICATION_CATEGORIES_COMPLETED]: (state, action) => {
[ACTIONS.LBRYIO_NOTIFICATION_CATEGORIES_COMPLETED]: (state, action) => {
const { notificationCategories } = action.data;
return {
@@ -71,7 +72,7 @@ export default handleActions(
notificationCategories,
};
},
[ACTIONS.NOTIFICATION_READ_COMPLETED]: (state, action) => {
[ACTIONS.LBRYIO_NOTIFICATION_READ_COMPLETED]: (state, action) => {
const { notifications, notificationsFiltered } = state;
const { notificationIds } = action.data;
@@ -94,12 +95,12 @@ export default handleActions(
notificationsFiltered: markIdsAsRead(notificationsFiltered, notificationIds),
};
},
[ACTIONS.NOTIFICATION_READ_FAILED]: (state, action) => {
[ACTIONS.LBRYIO_NOTIFICATION_READ_FAILED]: (state, action) => {
return {
...state,
};
},
[ACTIONS.NOTIFICATION_SEEN_COMPLETED]: (state, action) => {
[ACTIONS.LBRYIO_NOTIFICATION_SEEN_COMPLETED]: (state, action) => {
const { notifications, notificationsFiltered } = state;
const { notificationIds } = action.data;
@@ -118,7 +119,7 @@ export default handleActions(
notificationsFiltered: markIdsAsSeen(notificationsFiltered, notificationIds),
};
},
[ACTIONS.NOTIFICATION_DELETE_COMPLETED]: (state, action) => {
[ACTIONS.LBRYIO_NOTIFICATION_DELETE_COMPLETED]: (state, action) => {
const { notifications, notificationsFiltered } = state;
const { notificationId } = action.data;
@@ -133,6 +134,43 @@ export default handleActions(
};
},
[ACTIONS.LOCAL_NOTIFICATION_DELETE]: (state, action) => {
const { localNotifications } = state;
const { notificationId } = action.data;
const deleteId = (list, id) => {
return localNotifications.filter((n) => n.id !== id);
};
return {
...state,
localNotifications: deleteId(localNotifications, notificationId),
};
},
[ACTIONS.LOCAL_NOTIFICATION_ADD]: (state, action) => {
const { localNotifications } = state;
const { notifications } = action.data;
return localNotifications.concat(notifications);
},
[ACTIONS.LOCAL_NOTIFICATION_SEEN]: (state, action) => {
const { localNotifications } = state;
const { notificationIds } = action.data;
const markIdsAsSeen = (list, ids) => {
return list.map((n) => {
if (ids.includes(n.id)) {
return { ...n, is_seen: true };
}
return n;
});
};
return {
...state,
localNotifications: markIdsAsSeen(localNotifications, notificationIds),
};
},
// Errors
[ACTIONS.CREATE_ERROR]: (state: NotificationState, action: DoError) => {
const error: ErrorNotification = action.data;
Loaded 100 of 133 files, more files were not shown because too many files have changed in this diff. Show more