Compare commits
68
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e29af4652f | ||
|
|
5caa71d1fc | ||
|
|
cef9ade10e | ||
|
|
33e5318a29 | ||
|
|
8ecdaab6d4 | ||
|
|
9de2465e21 | ||
|
|
bef46257bc | ||
|
|
d410664d9a | ||
|
|
1f8c9fd24d | ||
|
|
64a2e908ae | ||
|
|
40e20dfc1b | ||
|
|
53425d8fe2 | ||
|
|
ca748fd16a | ||
|
|
ea7ed53bfe | ||
|
|
29c605de86 | ||
|
|
b56746475b | ||
|
|
94f64f8d25 | ||
|
|
04a6c735ac | ||
|
|
e9502410de | ||
|
|
bf87ac08db | ||
|
|
72310710af | ||
|
|
cce7cd43d8 | ||
|
|
080eee7d92 | ||
|
|
3058dbb4a6 | ||
|
|
b7d685b4ec | ||
|
|
e1ecf87df7 | ||
|
|
48c5f58a8e | ||
|
|
aa40a44ce3 | ||
|
|
8fb67d5980 | ||
|
|
67608dfc9c | ||
|
|
9fc600397c | ||
|
|
3d85cff0ef | ||
|
|
97fbc5e598 | ||
|
|
9375ada72a | ||
|
|
49c5180820 | ||
|
|
12097dbbba | ||
|
|
870992a6e4 | ||
|
|
eb1b412840 | ||
|
|
7c7c2aa053 | ||
|
|
f6961f91fe | ||
|
|
154b20c6c8 | ||
|
|
43af7ddc5f | ||
|
|
a574a5c1de | ||
|
|
c553ee46f6 | ||
|
|
71eedd20e1 | ||
|
|
3a4ff9d35d | ||
|
|
0106c1c361 | ||
|
|
830567b6ec | ||
|
|
8bd38114dd | ||
|
|
92ed44c0f2 | ||
|
|
bbea2887f2 | ||
|
|
ca2c6a6f8f | ||
|
|
ab87591501 | ||
|
|
24264a15b0 | ||
|
|
4f74ecfc47 | ||
|
|
703d1afc06 | ||
|
|
629b928c80 | ||
|
|
9a5f69f0eb | ||
|
|
fe72dcfc2c | ||
|
|
fe1a2eac33 | ||
|
|
2e048dc225 | ||
|
|
cbc3624664 | ||
|
|
6b37fd2eae | ||
|
|
d13397d4dd | ||
|
|
f370aa8db1 | ||
|
|
0e134a02d7 | ||
|
|
acbf262641 | ||
|
|
54b59dd946 |
No files matched your search
+1
-1
@@ -80,7 +80,7 @@ SIMPLE_SITE=false
|
||||
|
||||
ENABLE_COMMENT_REACTIONS=true
|
||||
ENABLE_FILE_REACTIONS=true
|
||||
ENABLE_CREATOR_REACTIONS=false
|
||||
ENABLE_CREATOR_REACTIONS=true
|
||||
ENABLE_NO_SOURCE_CLAIMS=false
|
||||
ENABLE_PREROLL_ADS=false
|
||||
CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS=4
|
||||
|
||||
+31
-2
@@ -5,7 +5,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## [Unreleased for Desktop]
|
||||
|
||||
## [0.52.1-alpha.4] - [2021-12-31]
|
||||
## [0.52.5] - [2022-02-25]
|
||||
|
||||
### Fixed
|
||||
|
||||
- New data hosting ux ([#7493](https://github.com/lbryio/lbry-desktop/pull/7493))
|
||||
- Fix markdown guide button ([#7485](https://github.com/lbryio/lbry-desktop/pull/7485))
|
||||
|
||||
## [0.52.4] - [2022-02-15]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed active channel ([#7481](https://github.com/lbryio/lbry-desktop/pull/7481))
|
||||
- Remove extra search button in header ([#7482](https://github.com/lbryio/lbry-desktop/pull/7482))
|
||||
|
||||
## [0.52.3] - [2022-02-15]
|
||||
|
||||
### Fixed
|
||||
- Fixed comment editing and pinning ([#7476](https://github.com/lbryio/lbry-desktop/pull/7476))
|
||||
- Fixed mac header ([#7479](https://github.com/lbryio/lbry-desktop/pull/7479))
|
||||
- Fixed markdown display and lbry url embedding ([#7474](https://github.com/lbryio/lbry-desktop/pull/7474))
|
||||
|
||||
## [0.52.2] - [2022-02-11]
|
||||
|
||||
### Added
|
||||
|
||||
@@ -14,6 +35,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Added duration overlays to ClaimPreview component ([#7420](https://github.com/lbryio/lbry-desktop/pull/7420))
|
||||
- Some Horizontal Scroll groundwork from _odysee team!_
|
||||
- Comment Emotes and Stickers and Mentions refactors from _odysee team!_ ([#7435](https://github.com/lbryio/lbry-desktop/pull/7435))
|
||||
- Seek forward and back from _odysee team!_ () ([#7460](https://github.com/lbryio/lbry-desktop/pull/7460))
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -21,13 +43,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Performance improvements in some selectors ([#7370](https://github.com/lbryio/lbry-desktop/pull/7370))
|
||||
- More Header refactoring from _odysee team!_ ([#7441](https://github.com/lbryio/lbry-desktop/pull/7441))
|
||||
- Header refactoring from _odysee team!_ ([#7440](https://github.com/lbryio/lbry-desktop/pull/7440))
|
||||
- Clearer data hosting ui _incomplete_ ([#7438](https://github.com/lbryio/lbry-desktop/pull/7438))
|
||||
- Data hosting ui _incomplete_ ([#7438](https://github.com/lbryio/lbry-desktop/pull/7438))
|
||||
- Updated c: control tags from _odysee team!_ ([#7433](https://github.com/lbryio/lbry-desktop/pull/7433))
|
||||
- Nav keycodes (alt+left) no longer navigate while textarea is focused ([#7458](https://github.com/lbryio/lbry-desktop/pull/7458))
|
||||
- Improved comment-server selection ui/ux ([#7455](https://github.com/lbryio/lbry-desktop/pull/7455))
|
||||
- Improved Data Hosting settings ([#7563](https://github.com/lbryio/lbry-desktop/pull/7563))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Several fallout bugs from recent changes
|
||||
|
||||
## [0.52.1]
|
||||
|
||||
### Skipped patch version
|
||||
|
||||
## [0.52.0] - [2021-12-31]
|
||||
|
||||
### Compatibility
|
||||
|
||||
@@ -116,3 +116,5 @@ New Releases are signed by [Jessop Breth](https://keybase.io/jessopb/key.asc).
|
||||
## Contact
|
||||
|
||||
The primary contact for this project is [@jessopb](https://github.com/jessopb).
|
||||
|
||||
## test
|
||||
@@ -10,6 +10,7 @@ import { TO_TRAY_WHEN_CLOSED } from 'constants/settings';
|
||||
import setupBarMenu from './menu/setupBarMenu';
|
||||
import * as PAGES from 'constants/pages';
|
||||
const remote = require('@electron/remote/main');
|
||||
const shell = require('electron').shell;
|
||||
function GetAppLangCode() {
|
||||
// https://www.electronjs.org/docs/api/locales
|
||||
// 1. Gets the user locale.
|
||||
@@ -190,6 +191,11 @@ export default appState => {
|
||||
});
|
||||
|
||||
window.webContents.setWindowOpenHandler((details) => {
|
||||
// Only open http and https links to prevent
|
||||
// security issues.
|
||||
if (['https:', 'http:'].includes(new URL(details.url).protocol)) {
|
||||
shell.openExternal(details.url);
|
||||
}
|
||||
return { action: 'deny' };
|
||||
});
|
||||
|
||||
|
||||
+83
-2
@@ -17,8 +17,12 @@ import startSandbox from './startSandbox';
|
||||
import installDevtools from './installDevtools';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { diskSpaceLinux, diskSpaceWindows, diskSpaceMac } from '../ui/util/diskspace';
|
||||
|
||||
const { download } = require('electron-dl');
|
||||
const remote = require('@electron/remote/main');
|
||||
const os = require('os');
|
||||
|
||||
remote.initialize();
|
||||
const filePath = path.join(process.resourcesPath, 'static', 'upgradeDisabled');
|
||||
let upgradeDisabled;
|
||||
@@ -39,6 +43,19 @@ let autoUpdateDownloaded = false;
|
||||
// that we show on Windows after you decline an upgrade and close the app later.
|
||||
let showingAutoUpdateCloseAlert = false;
|
||||
|
||||
// This is used to prevent downloading updates multiple times when
|
||||
// using the auto updater API.
|
||||
// As read in the documentation:
|
||||
// "Calling autoUpdater.checkForUpdates() twice will download the update two times."
|
||||
// https://www.electronjs.org/docs/latest/api/auto-updater#autoupdatercheckforupdates
|
||||
let keepCheckingForUpdates = true;
|
||||
|
||||
// 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.
|
||||
let rendererWindow;
|
||||
@@ -286,7 +303,35 @@ app.on('before-quit', () => {
|
||||
appState.isQuitting = true;
|
||||
});
|
||||
|
||||
ipcMain.on('get-disk-space', async (event) => {
|
||||
try {
|
||||
const { data_dir } = await Lbry.settings_get();
|
||||
let diskSpace;
|
||||
switch (os.platform()) {
|
||||
case 'linux':
|
||||
diskSpace = await diskSpaceLinux(data_dir);
|
||||
break;
|
||||
case 'darwin':
|
||||
diskSpace = await diskSpaceMac(data_dir);
|
||||
break;
|
||||
case 'win32':
|
||||
diskSpace = await diskSpaceWindows(data_dir);
|
||||
break;
|
||||
default:
|
||||
throw new Error('unknown platform');
|
||||
}
|
||||
rendererWindow.webContents.send('send-disk-space', { diskSpace });
|
||||
} catch (e) {
|
||||
rendererWindow.webContents.send('send-disk-space', { error: e.message || e });
|
||||
console.log('Failed to start LbryFirst', e);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('download-upgrade', async (event, params) => {
|
||||
if (downloadUpgradeInProgress) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { url, options } = params;
|
||||
const dir = fs.mkdtempSync(app.getPath('temp') + path.sep);
|
||||
options.onProgress = function(p) {
|
||||
@@ -294,9 +339,11 @@ ipcMain.on('download-upgrade', async (event, params) => {
|
||||
};
|
||||
options.directory = dir;
|
||||
options.onCompleted = function(c) {
|
||||
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));
|
||||
});
|
||||
|
||||
@@ -314,17 +361,51 @@ ipcMain.on('upgrade', (event, installerPath) => {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
ipcMain.on('check-for-updates', () => {
|
||||
ipcMain.on('check-for-updates', (event, autoDownload) => {
|
||||
// Prevent downloading the same update multiple times.
|
||||
if (!keepCheckingForUpdates) {
|
||||
return;
|
||||
}
|
||||
|
||||
keepCheckingForUpdates = false;
|
||||
autoUpdater.autoDownload = autoDownload;
|
||||
autoUpdater.checkForUpdates();
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
autoUpdateDownloaded = true;
|
||||
|
||||
// If this download was trigger by
|
||||
// autoUpdateAccepted it means, the user
|
||||
// wants to install the new update but
|
||||
// needed to downloaded the files first.
|
||||
if (appState.autoUpdateAccepted) {
|
||||
autoUpdater.quitAndInstall();
|
||||
}
|
||||
});
|
||||
|
||||
autoUpdater.on('update-not-available', () => {
|
||||
keepCheckingForUpdates = true;
|
||||
});
|
||||
|
||||
ipcMain.on('autoUpdateAccepted', () => {
|
||||
appState.autoUpdateAccepted = true;
|
||||
autoUpdater.quitAndInstall();
|
||||
|
||||
// quitAndInstall can only be called if the
|
||||
// update has been downloaded. Since the user
|
||||
// can disable auto updates, we have to make
|
||||
// sure it has been downloaded first.
|
||||
if (autoUpdateDownloaded) {
|
||||
autoUpdater.quitAndInstall();
|
||||
return;
|
||||
}
|
||||
|
||||
// If the update hasn't been downloaded,
|
||||
// start downloading it. After it's done, the
|
||||
// event 'update-downloaded' will be triggered,
|
||||
// where we will be able to resume the
|
||||
// update installation.
|
||||
autoUpdater.downloadUpdate();
|
||||
});
|
||||
|
||||
ipcMain.on('version-info-requested', () => {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as ACTIONS from 'constants/action_types';
|
||||
import { Lbryio } from 'lbryinc';
|
||||
import { selectClaimsByUri } from 'redux/selectors/claims';
|
||||
import { selectClaimForUri } from 'redux/selectors/claims';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function doFetchCostInfoForUri(uri) {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const claim = selectClaimsByUri(state)[uri];
|
||||
const claim = selectClaimForUri(state, uri);
|
||||
|
||||
if (!claim) return;
|
||||
|
||||
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
declare type CommentServerDetails = {
|
||||
name: string,
|
||||
url: string,
|
||||
}
|
||||
|
||||
declare type WalletServerDetails = {
|
||||
|
||||
};
|
||||
|
||||
declare type DiskSpace = {
|
||||
total: string,
|
||||
free: string,
|
||||
};
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lbry",
|
||||
"version": "0.52.2-alpha.1",
|
||||
"version": "0.52.5",
|
||||
"description": "A browser for the LBRY network, a digital marketplace controlled by its users.",
|
||||
"keywords": [
|
||||
"lbry"
|
||||
@@ -127,7 +127,7 @@
|
||||
"dotenv-defaults": "^2.0.1",
|
||||
"dotenv-webpack": "^1.8.0",
|
||||
"electron": "15.3.2",
|
||||
"electron-builder": "^22.9.1",
|
||||
"electron-builder": "^22.10.5",
|
||||
"electron-devtools-installer": "^3.1.1",
|
||||
"electron-is-dev": "^0.3.0",
|
||||
"electron-webpack": "^2.8.2",
|
||||
@@ -163,7 +163,7 @@
|
||||
"mammoth": "^1.4.16",
|
||||
"moment": "^2.22.0",
|
||||
"node-abi": "^2.5.1",
|
||||
"node-fetch": "^2.6.1",
|
||||
"node-fetch": "^2.6.7",
|
||||
"node-html-parser": "^5.1.0",
|
||||
"node-libs-browser": "^2.1.0",
|
||||
"node-loader": "^0.6.0",
|
||||
@@ -212,7 +212,7 @@
|
||||
"strip-markdown": "^3.0.3",
|
||||
"style-loader": "^0.23.1",
|
||||
"terser-webpack-plugin": "^4.2.3",
|
||||
"three-full": "^28.0.1",
|
||||
"three-full": "^28.0.2",
|
||||
"tiny-relative-date": "^1.3.0",
|
||||
"tree-kill": "^1.1.0",
|
||||
"unist-util-visit": "^2.0.3",
|
||||
|
||||
@@ -2269,5 +2269,27 @@
|
||||
"Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.": "Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.",
|
||||
"Help improve the P2P data network (and make LBRY happy) by hosting data.": "Help improve the P2P data network (and make LBRY happy) by hosting data.",
|
||||
"Limit Hosting of Content History": "Limit Hosting of Content History",
|
||||
"Remove custom comment server": "Remove custom comment server",
|
||||
"Use Https": "Use Https",
|
||||
"Server URL": "Server URL",
|
||||
"Use https": "Use https",
|
||||
"Custom Servers": "Custom Servers",
|
||||
"Add A Server": "Add A Server",
|
||||
"Autoplay Next is off.": "Autoplay Next is off.",
|
||||
"Shuffle is on.": "Shuffle is on.",
|
||||
"Shuffle is off.": "Shuffle is off.",
|
||||
"Loop is on.": "Loop is on.",
|
||||
"Loop is off.": "Loop is off.",
|
||||
"View History Hosting lets you choose how much storage to use helping content you've consumed.": "View History Hosting lets you choose how much storage to use helping content you've consumed.",
|
||||
"Clean Now": "Clean Now",
|
||||
"Enable Automatic Hosting": "Enable Automatic Hosting",
|
||||
"Download and serve arbitrary data on the network.": "Download and serve arbitrary data on the network.",
|
||||
"View History Hosting": "View History Hosting",
|
||||
"Disable automatic updates": "Disable automatic updates",
|
||||
"Preven't new updates to be downloaded automatically in the background (we will keep notifying you if there is an update)": "Preven't new updates to be downloaded automatically in the background (we will keep notifying you if there is an update)",
|
||||
"Unlimited View Hosting": "Unlimited View Hosting",
|
||||
"Choose View Hosting Limit": "Choose View Hosting Limit",
|
||||
"View Hosting Limit (GB)": "View Hosting Limit (GB)",
|
||||
"%free% of %total% available": "%free% of %total% available",
|
||||
"--end--": "--end--"
|
||||
}
|
||||
+3
-9
@@ -49,9 +49,6 @@ type Analytics = {
|
||||
readyState: number,
|
||||
}
|
||||
) => Promise<any>,
|
||||
adsFetchedEvent: () => void,
|
||||
adsReceivedEvent: (any) => void,
|
||||
adsErrorEvent: (any) => void,
|
||||
emailProvidedEvent: () => void,
|
||||
emailVerifiedEvent: () => void,
|
||||
rewardEligibleEvent: () => void,
|
||||
@@ -168,10 +165,7 @@ async function sendWatchmanData(body) {
|
||||
});
|
||||
|
||||
return response;
|
||||
} catch (err) {
|
||||
console.log('ERROR FROM WATCHMAN BACKEND');
|
||||
console.log(err);
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
const analytics: Analytics = {
|
||||
@@ -213,7 +207,7 @@ const analytics: Analytics = {
|
||||
startWatchmanIntervalIfNotRunning();
|
||||
}
|
||||
},
|
||||
videoStartEvent: (claimId, duration, poweredBy, passedUserId, canonicalUrl, passedPlayer, videoBitrate) => {
|
||||
videoStartEvent: (claimId, timeToStartVideo, poweredBy, passedUserId, canonicalUrl, passedPlayer, videoBitrate) => {
|
||||
// populate values for watchman when video starts
|
||||
userId = passedUserId;
|
||||
claimUrl = canonicalUrl;
|
||||
@@ -224,7 +218,7 @@ const analytics: Analytics = {
|
||||
bitrateAsBitsPerSecond = videoBitrate;
|
||||
|
||||
// sendPromMetric('time_to_start', duration);
|
||||
sendMatomoEvent('Media', 'TimeToStart', claimId, duration);
|
||||
sendMatomoEvent('Media', 'TimeToStart', claimId, timeToStartVideo);
|
||||
},
|
||||
error: (message) => {
|
||||
return new Promise((resolve) => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { doFetchAccessToken, doUserSetReferrer } from 'redux/actions/user';
|
||||
import { selectUser, selectAccessToken, selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
|
||||
import { doFetchChannelListMine, doFetchCollectionListMine, doResolveUris } from 'redux/actions/claims';
|
||||
import { selectMyChannelUrls } from 'redux/selectors/claims';
|
||||
import { selectMyChannelUrls, selectMyChannelClaimIds } from 'redux/selectors/claims';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
||||
import {
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
selectAutoUpdateDownloaded,
|
||||
selectModal,
|
||||
selectActiveChannelClaim,
|
||||
selectIsUpdateModalDisplayed,
|
||||
} from 'redux/selectors/app';
|
||||
import { doGetWalletSyncPreference, doSetLanguage } from 'redux/actions/settings';
|
||||
import { doSyncLoop } from 'redux/actions/sync';
|
||||
@@ -48,7 +49,9 @@ const select = (state) => ({
|
||||
syncFatalError: selectSyncFatalError(state),
|
||||
activeChannelClaim: selectActiveChannelClaim(state),
|
||||
myChannelUrls: selectMyChannelUrls(state),
|
||||
myChannelClaimIds: selectMyChannelClaimIds(state),
|
||||
subscriptions: selectSubscriptions(state),
|
||||
isUpdateModalDisplayed: selectIsUpdateModalDisplayed(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -76,6 +76,7 @@ type Props = {
|
||||
fetchModBlockedList: () => void,
|
||||
resolveUris: (Array<string>) => void,
|
||||
fetchModAmIList: () => void,
|
||||
isUpdateModalDisplayed: boolean,
|
||||
};
|
||||
|
||||
function App(props: Props) {
|
||||
@@ -111,6 +112,7 @@ function App(props: Props) {
|
||||
resolveUris,
|
||||
subscriptions,
|
||||
fetchModAmIList,
|
||||
isUpdateModalDisplayed,
|
||||
} = props;
|
||||
|
||||
const appRef = useRef();
|
||||
@@ -126,9 +128,9 @@ function App(props: Props) {
|
||||
const [upgradeNagClosed, setUpgradeNagClosed] = useState(false);
|
||||
const [resolvedSubscriptions, setResolvedSubscriptions] = useState(false);
|
||||
// const [retryingSync, setRetryingSync] = useState(false);
|
||||
const [langRenderKey, setLangRenderKey] = useState(0);
|
||||
const [sidebarOpen] = usePersistedState('sidebar', true);
|
||||
const showUpgradeButton =
|
||||
(autoUpdateDownloaded || (process.platform === 'linux' && isUpgradeAvailable)) && !upgradeNagClosed;
|
||||
const showUpgradeButton = (autoUpdateDownloaded || isUpgradeAvailable) && !upgradeNagClosed;
|
||||
// referral claiming
|
||||
const referredRewardAvailable = rewards && rewards.some((reward) => reward.reward_type === REWARDS.TYPE_REFEREE);
|
||||
const urlParams = new URLSearchParams(search);
|
||||
@@ -326,6 +328,11 @@ function App(props: Props) {
|
||||
}
|
||||
}, [sidebarOpen, isPersonalized, resolvedSubscriptions, subscriptions, resolveUris, setResolvedSubscriptions]);
|
||||
|
||||
useEffect(() => {
|
||||
// When language is changed or translations are fetched, we render.
|
||||
setLangRenderKey(Date.now());
|
||||
}, [language, languages]);
|
||||
|
||||
if (syncFatalError) {
|
||||
return <SyncFatalError />;
|
||||
}
|
||||
@@ -337,6 +344,7 @@ function App(props: Props) {
|
||||
[`${MAIN_WRAPPER_CLASS}--scrollbar`]: useCustomScrollbar,
|
||||
})}
|
||||
ref={appRef}
|
||||
key={langRenderKey}
|
||||
onContextMenu={(e) => openContextMenu(e)}
|
||||
>
|
||||
<Router />
|
||||
@@ -345,7 +353,7 @@ function App(props: Props) {
|
||||
<FileRenderFloating />
|
||||
{isEnhancedLayout && <Yrbl className="yrbl--enhanced" />}
|
||||
|
||||
{showUpgradeButton && (
|
||||
{showUpgradeButton && !isUpdateModalDisplayed && (
|
||||
<Nag
|
||||
message={__('An upgrade is available.')}
|
||||
actionText={__('Install Now')}
|
||||
|
||||
@@ -317,6 +317,7 @@ const ClaimPreview = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||
'claim-preview__wrapper--small': type === 'small',
|
||||
'claim-preview__active': active,
|
||||
})}
|
||||
key={uri}
|
||||
>
|
||||
<>
|
||||
{!hideRepostLabel && <ClaimRepostAuthor uri={uri} />}
|
||||
|
||||
@@ -9,7 +9,6 @@ import { doToggleTagFollowDesktop } from 'redux/actions/tags';
|
||||
import { makeSelectClientSetting, selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { selectMutedAndBlockedChannelIds } from 'redux/selectors/blocked';
|
||||
import { ENABLE_NO_SOURCE_CLAIMS } from 'config';
|
||||
import * as CS from 'constants/claim_search';
|
||||
|
||||
import ClaimListDiscover from './view';
|
||||
|
||||
@@ -68,8 +67,6 @@ function resolveSearchOptions(props) {
|
||||
let streamTypesParam;
|
||||
if (streamTypes) {
|
||||
streamTypesParam = streamTypes;
|
||||
} else if (!hasNoSource && streamTypes !== null) {
|
||||
streamTypesParam = [CS.FILE_VIDEO, CS.FILE_AUDIO];
|
||||
}
|
||||
|
||||
const options = {
|
||||
|
||||
@@ -273,12 +273,18 @@ function CollectionForm(props: Props) {
|
||||
|
||||
// on mount, if we get a collectionChannel, set it.
|
||||
React.useEffect(() => {
|
||||
if (hasClaim && !initialized) {
|
||||
if (collectionChannel) {
|
||||
setActiveChannel(collectionChannel);
|
||||
setIncognito(false);
|
||||
} else if (!collectionChannel && hasClaim) {
|
||||
setIncognito(true);
|
||||
if (!initialized) {
|
||||
if (hasClaim) {
|
||||
if (collectionChannel) {
|
||||
setActiveChannel(collectionChannel);
|
||||
setIncognito(false);
|
||||
} else if (!collectionChannel && hasClaim) {
|
||||
setIncognito(true);
|
||||
}
|
||||
} else {
|
||||
if (incognito) {
|
||||
setIncognito(true);
|
||||
}
|
||||
}
|
||||
setInitialized(true);
|
||||
}
|
||||
@@ -287,9 +293,10 @@ function CollectionForm(props: Props) {
|
||||
// every time activechannel or incognito changes, set it.
|
||||
React.useEffect(() => {
|
||||
if (initialized) {
|
||||
if (activeChannelId) {
|
||||
if (activeChannelId && !incognito) {
|
||||
setParam({ channel_id: activeChannelId });
|
||||
} else if (incognito) {
|
||||
}
|
||||
if (incognito) {
|
||||
setParam({ channel_id: undefined });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
selectTotalStakedAmountForChannelUri,
|
||||
selectStakedLevelForChannelUri,
|
||||
makeSelectClaimForUri,
|
||||
selectThumbnailForUri,
|
||||
selectHasChannels,
|
||||
selectMyClaimIdsRaw,
|
||||
} from 'redux/selectors/claims';
|
||||
import { doCommentUpdate, doCommentList } from 'redux/actions/comments';
|
||||
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { doClearPlayingUri } from 'redux/actions/content';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import {
|
||||
selectLinkedCommentAncestors,
|
||||
selectOthersReactsForComment,
|
||||
@@ -19,31 +21,34 @@ import { selectPlayingUri } from 'redux/selectors/content';
|
||||
import Comment from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
const { comment, uri } = props;
|
||||
const { comment_id, author_uri } = comment || {};
|
||||
|
||||
const activeChannelClaim = selectActiveChannelClaim(state);
|
||||
const activeChannelId = activeChannelClaim && activeChannelClaim.claim_id;
|
||||
const reactionKey = activeChannelId ? `${props.commentId}:${activeChannelId}` : props.commentId;
|
||||
const reactionKey = activeChannelId ? `${comment_id}:${activeChannelId}` : comment_id;
|
||||
|
||||
return {
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
thumbnail: props.authorUri && selectThumbnailForUri(state, props.authorUri),
|
||||
channelIsBlocked: props.authorUri && makeSelectChannelIsMuted(props.authorUri)(state),
|
||||
commentingEnabled: true,
|
||||
myChannelIds: selectMyClaimIdsRaw(state),
|
||||
claim: makeSelectClaimForUri(uri)(state),
|
||||
thumbnail: author_uri && selectThumbnailForUri(state, author_uri),
|
||||
channelIsBlocked: author_uri && makeSelectChannelIsMuted(author_uri)(state),
|
||||
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
||||
othersReacts: selectOthersReactsForComment(state, reactionKey),
|
||||
activeChannelClaim,
|
||||
hasChannels: selectHasChannels(state),
|
||||
playingUri: selectPlayingUri(state),
|
||||
stakedLevel: selectTotalStakedAmountForChannelUri(state, props.authorUri),
|
||||
stakedLevel: selectStakedLevelForChannelUri(state, author_uri),
|
||||
linkedCommentAncestors: selectLinkedCommentAncestors(state),
|
||||
totalReplyPages: makeSelectTotalReplyPagesForParentId(props.commentId)(state),
|
||||
totalReplyPages: makeSelectTotalReplyPagesForParentId(comment_id)(state),
|
||||
};
|
||||
};
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
|
||||
updateComment: (commentId, comment) => dispatch(doCommentUpdate(commentId, comment)),
|
||||
fetchReplies: (uri, parentId, page, pageSize, sortBy) =>
|
||||
dispatch(doCommentList(uri, parentId, page, pageSize, sortBy)),
|
||||
doToast: (options) => dispatch(doToast(options)),
|
||||
});
|
||||
const perform = {
|
||||
doClearPlayingUri,
|
||||
doCommentUpdate,
|
||||
fetchReplies: doCommentList,
|
||||
doToast,
|
||||
};
|
||||
|
||||
export default connect(select, perform)(Comment);
|
||||
@@ -12,7 +12,7 @@ import DateTime from 'component/dateTime';
|
||||
import Button from 'component/button';
|
||||
import Expandable from 'component/expandable';
|
||||
import MarkdownPreview from 'component/common/markdown-preview';
|
||||
import Tooltip from 'component/common/tooltip';
|
||||
import CommentBadge from 'component/common/comment-badge'; // have this?
|
||||
import ChannelThumbnail from 'component/channelThumbnail';
|
||||
import { Menu, MenuButton } from '@reach/menu-button';
|
||||
import Icon from 'component/common/icon';
|
||||
@@ -27,23 +27,21 @@ import CommentMenuList from 'component/commentMenuList';
|
||||
import UriIndicator from 'component/uriIndicator';
|
||||
import CreditAmount from 'component/common/credit-amount';
|
||||
import OptimizedImage from 'component/optimizedImage';
|
||||
import { getChannelFromClaim } from 'util/claim';
|
||||
import { parseSticker } from 'util/comments';
|
||||
import { useIsMobile } from 'effects/use-screensize';
|
||||
|
||||
const AUTO_EXPAND_ALL_REPLIES = false;
|
||||
|
||||
type Props = {
|
||||
comment: Comment,
|
||||
myChannelIds: ?Array<string>,
|
||||
clearPlayingUri: () => void,
|
||||
uri: string,
|
||||
claim: StreamClaim,
|
||||
author: ?string, // LBRY Channel Name, e.g. @channel
|
||||
authorUri: string, // full LBRY Channel URI: lbry://@channel#123...
|
||||
commentId: string, // sha256 digest identifying the comment
|
||||
message: string, // comment body
|
||||
timePosted: number, // Comment timestamp
|
||||
channelIsBlocked: boolean, // if the channel is blacklisted in the app
|
||||
claimIsMine: boolean, // if you control the claim which this comment was posted on
|
||||
commentIsMine: boolean, // if this comment was signed by an owned channel
|
||||
updateComment: (string, string) => void,
|
||||
doCommentUpdate: (string, string) => void,
|
||||
fetchReplies: (string, string, number, number, number) => void,
|
||||
totalReplyPages: number,
|
||||
commentModBlock: (string) => void,
|
||||
@@ -55,7 +53,6 @@ type Props = {
|
||||
isTopLevel?: boolean,
|
||||
threadDepth: number,
|
||||
hideActions?: boolean,
|
||||
isPinned: boolean,
|
||||
othersReacts: ?{
|
||||
like: number,
|
||||
dislike: number,
|
||||
@@ -64,11 +61,6 @@ type Props = {
|
||||
activeChannelClaim: ?ChannelClaim,
|
||||
playingUri: ?PlayingUri,
|
||||
stakedLevel: number,
|
||||
supportAmount: number,
|
||||
numDirectReplies: number,
|
||||
isModerator: boolean,
|
||||
isGlobalMod: boolean,
|
||||
isFiat: boolean,
|
||||
supportDisabled: boolean,
|
||||
setQuickReply: (any) => void,
|
||||
quickReply: any,
|
||||
@@ -76,19 +68,15 @@ type Props = {
|
||||
|
||||
const LENGTH_TO_COLLAPSE = 300;
|
||||
|
||||
function Comment(props: Props) {
|
||||
function CommentView(props: Props) {
|
||||
const {
|
||||
comment,
|
||||
myChannelIds,
|
||||
clearPlayingUri,
|
||||
claim,
|
||||
uri,
|
||||
author,
|
||||
authorUri,
|
||||
timePosted,
|
||||
message,
|
||||
channelIsBlocked,
|
||||
commentIsMine,
|
||||
commentId,
|
||||
updateComment,
|
||||
doCommentUpdate,
|
||||
fetchReplies,
|
||||
totalReplyPages,
|
||||
linkedCommentId,
|
||||
@@ -99,39 +87,61 @@ function Comment(props: Props) {
|
||||
isTopLevel,
|
||||
threadDepth,
|
||||
hideActions,
|
||||
isPinned,
|
||||
othersReacts,
|
||||
playingUri,
|
||||
stakedLevel,
|
||||
supportAmount,
|
||||
numDirectReplies,
|
||||
isModerator,
|
||||
isGlobalMod,
|
||||
isFiat,
|
||||
supportDisabled,
|
||||
setQuickReply,
|
||||
quickReply,
|
||||
} = props;
|
||||
|
||||
const {
|
||||
channel_url: authorUri,
|
||||
channel_name: author,
|
||||
channel_id: channelId,
|
||||
comment_id: commentId,
|
||||
comment: message,
|
||||
is_fiat: isFiat,
|
||||
is_global_mod: isGlobalMod,
|
||||
is_moderator: isModerator,
|
||||
is_pinned: isPinned,
|
||||
support_amount: supportAmount,
|
||||
replies: numDirectReplies,
|
||||
timestamp,
|
||||
} = comment;
|
||||
|
||||
const timePosted = timestamp * 1000;
|
||||
const commentIsMine = channelId && myChannelIds && myChannelIds.includes(channelId);
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const {
|
||||
push,
|
||||
replace,
|
||||
location: { pathname, search },
|
||||
} = useHistory();
|
||||
|
||||
const isLinkedComment = linkedCommentId && linkedCommentId === commentId;
|
||||
const isInLinkedCommentChain =
|
||||
linkedCommentId &&
|
||||
linkedCommentAncestors[linkedCommentId] &&
|
||||
linkedCommentAncestors[linkedCommentId].includes(commentId);
|
||||
const showRepliesOnMount = isInLinkedCommentChain || AUTO_EXPAND_ALL_REPLIES;
|
||||
|
||||
const [isReplying, setReplying] = React.useState(false);
|
||||
const [isEditing, setEditing] = useState(false);
|
||||
const [editedMessage, setCommentValue] = useState(message);
|
||||
const [charCount, setCharCount] = useState(editedMessage.length);
|
||||
const [showReplies, setShowReplies] = useState(false);
|
||||
const [page, setPage] = useState(0);
|
||||
const [showReplies, setShowReplies] = useState(showRepliesOnMount); // on mount
|
||||
const [page, setPage] = useState(showRepliesOnMount ? 1 : 0);
|
||||
const [advancedEditor] = usePersistedState('comment-editor-mode', false);
|
||||
const [displayDeadComment, setDisplayDeadComment] = React.useState(false);
|
||||
const likesCount = (othersReacts && othersReacts.like) || 0;
|
||||
const dislikesCount = (othersReacts && othersReacts.dislike) || 0;
|
||||
const totalLikesAndDislikes = likesCount + dislikesCount;
|
||||
const slimedToDeath = totalLikesAndDislikes >= 5 && dislikesCount / totalLikesAndDislikes > 0.8;
|
||||
const commentByOwnerOfContent = claim && claim.signing_channel && claim.signing_channel.permanent_url === authorUri;
|
||||
const contentChannelClaim = getChannelFromClaim(claim);
|
||||
const commentByOwnerOfContent = contentChannelClaim && contentChannelClaim.permanent_url === authorUri;
|
||||
const stickerFromMessage = parseSticker(message);
|
||||
|
||||
let channelOwnerOfContent;
|
||||
@@ -142,19 +152,6 @@ function Comment(props: Props) {
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// Auto-expand (limited to linked-comments for now, but can be for all)
|
||||
useEffect(() => {
|
||||
const isInLinkedCommentChain =
|
||||
linkedCommentId &&
|
||||
linkedCommentAncestors[linkedCommentId] &&
|
||||
linkedCommentAncestors[linkedCommentId].includes(commentId);
|
||||
|
||||
if (isInLinkedCommentChain || AUTO_EXPAND_ALL_REPLIES) {
|
||||
setShowReplies(true);
|
||||
setPage(1);
|
||||
}
|
||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
useEffect(() => {
|
||||
if (isEditing) {
|
||||
setCharCount(editedMessage.length);
|
||||
@@ -193,7 +190,7 @@ function Comment(props: Props) {
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
updateComment(commentId, editedMessage);
|
||||
doCommentUpdate(commentId, editedMessage);
|
||||
if (setQuickReply) setQuickReply({ ...quickReply, comment_id: commentId, comment: editedMessage });
|
||||
setEditing(false);
|
||||
}
|
||||
@@ -214,6 +211,34 @@ function Comment(props: Props) {
|
||||
replace(`${pathname}?${urlParams.toString()}`);
|
||||
}
|
||||
|
||||
// find a way to enable linked comments - probably use share url.
|
||||
// const linkedCommentRef = React.useCallback(
|
||||
// (node) => {
|
||||
// if (node !== null && window.pendingLinkedCommentScroll) {
|
||||
// const ROUGH_HEADER_HEIGHT = 125; // @see: --header-height
|
||||
// delete window.pendingLinkedCommentScroll;
|
||||
//
|
||||
// const mobileChatElem = document.querySelector('.MuiPaper-root .card--enable-overflow');
|
||||
// const drawerElem = document.querySelector('.MuiDrawer-root');
|
||||
// const elem = (isMobile && mobileChatElem) || window;
|
||||
//
|
||||
// if (elem) {
|
||||
// // $FlowFixMe
|
||||
// elem.scrollTo({
|
||||
// top:
|
||||
// node.getBoundingClientRect().top +
|
||||
// // $FlowFixMe
|
||||
// (mobileChatElem && drawerElem ? drawerElem.getBoundingClientRect().top * -1 : elem.scrollY) -
|
||||
// ROUGH_HEADER_HEIGHT,
|
||||
// left: 0,
|
||||
// behavior: 'smooth',
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// [isMobile]
|
||||
// );
|
||||
|
||||
return (
|
||||
<li
|
||||
className={classnames('comment', {
|
||||
@@ -225,7 +250,7 @@ function Comment(props: Props) {
|
||||
>
|
||||
<div
|
||||
className={classnames('comment__content', {
|
||||
[COMMENT_HIGHLIGHTED]: linkedCommentId && linkedCommentId === commentId,
|
||||
[COMMENT_HIGHLIGHTED]: isLinkedComment,
|
||||
'comment--slimed': slimedToDeath && !displayDeadComment,
|
||||
})}
|
||||
>
|
||||
@@ -240,21 +265,8 @@ function Comment(props: Props) {
|
||||
<div className="comment__body-container">
|
||||
<div className="comment__meta">
|
||||
<div className="comment__meta-information">
|
||||
{isGlobalMod && (
|
||||
<Tooltip title={__('Admin')}>
|
||||
<span className="comment__badge comment__badge--global-mod">
|
||||
<Icon icon={ICONS.BADGE_MOD} size={20} />
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
{isModerator && (
|
||||
<Tooltip title={__('Moderator')}>
|
||||
<span className="comment__badge comment__badge--mod">
|
||||
<Icon icon={ICONS.BADGE_MOD} size={20} />
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
{isGlobalMod && <CommentBadge label={__('Admin')} icon={ICONS.BADGE_MOD} />}
|
||||
{isModerator && <CommentBadge label={__('Moderator')} icon={ICONS.BADGE_MOD} />}
|
||||
|
||||
{!author ? (
|
||||
<span className="comment__author">{__('Anonymous')}</span>
|
||||
@@ -314,6 +326,7 @@ function Comment(props: Props) {
|
||||
charCount={charCount}
|
||||
onChange={handleEditMessageChanged}
|
||||
textAreaMaxLength={FF_MAX_CHARS_IN_COMMENT}
|
||||
handleSubmit={handleSubmit}
|
||||
/>
|
||||
<div className="section__actions section__actions--no-margin">
|
||||
<Button button="primary" type="submit" label={__('Done')} disabled={message === editedMessage} />
|
||||
@@ -358,6 +371,7 @@ function Comment(props: Props) {
|
||||
className="comment__action"
|
||||
onClick={handleCommentReply}
|
||||
icon={ICONS.REPLY}
|
||||
iconSize={isMobile && 12}
|
||||
/>
|
||||
)}
|
||||
{ENABLE_COMMENT_REACTIONS && <CommentReactions uri={uri} commentId={commentId} />}
|
||||
@@ -431,4 +445,4 @@ function Comment(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
export default Comment;
|
||||
export default CommentView;
|
||||
@@ -21,7 +21,6 @@ type Props = {
|
||||
// --- select ---
|
||||
claim: ?Claim,
|
||||
claimIsMine: boolean,
|
||||
contentChannelPermanentUrl: any,
|
||||
activeChannelClaim: ?ChannelClaim,
|
||||
playingUri: ?PlayingUri,
|
||||
moderationDelegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
|
||||
@@ -44,7 +43,6 @@ function CommentMenuList(props: Props) {
|
||||
commentIsMine,
|
||||
commentId,
|
||||
activeChannelClaim,
|
||||
contentChannelPermanentUrl,
|
||||
isTopLevel,
|
||||
isPinned,
|
||||
playingUri,
|
||||
@@ -62,6 +60,7 @@ function CommentMenuList(props: Props) {
|
||||
} = props;
|
||||
|
||||
const contentChannelClaim = getChannelFromClaim(claim);
|
||||
const contentChannelPermanentUrl = contentChannelClaim && contentChannelClaim.permanent_url;
|
||||
const activeModeratorInfo = activeChannelClaim && moderationDelegatorsById[activeChannelClaim.claim_id];
|
||||
const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl;
|
||||
const activeChannelIsAdmin = activeChannelClaim && activeModeratorInfo && activeModeratorInfo.global;
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
makeSelectClaimForUri,
|
||||
selectClaimIsMine,
|
||||
selectFetchingMyChannels,
|
||||
selectMyClaimIdsRaw,
|
||||
} from 'redux/selectors/claims';
|
||||
import {
|
||||
selectTopLevelCommentsForUri,
|
||||
@@ -22,12 +21,17 @@ import {
|
||||
} from 'redux/selectors/comments';
|
||||
import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
|
||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||
import { getChannelIdFromClaim } from 'util/claim';
|
||||
import CommentsList from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
const claim = selectClaimForUri(state, props.uri);
|
||||
const { uri } = props;
|
||||
|
||||
const claim = selectClaimForUri(state, uri);
|
||||
const channelId = getChannelIdFromClaim(claim);
|
||||
|
||||
const activeChannelClaim = selectActiveChannelClaim(state);
|
||||
const topLevelComments = selectTopLevelCommentsForUri(state, props.uri);
|
||||
const topLevelComments = selectTopLevelCommentsForUri(state, uri);
|
||||
|
||||
const resolvedComments =
|
||||
topLevelComments && topLevelComments.length > 0
|
||||
@@ -37,12 +41,12 @@ const select = (state, props) => {
|
||||
return {
|
||||
topLevelComments,
|
||||
resolvedComments,
|
||||
myChannelIds: selectMyClaimIdsRaw(state),
|
||||
allCommentIds: selectCommentIdsForUri(state, props.uri),
|
||||
pinnedComments: selectPinnedCommentsForUri(state, props.uri),
|
||||
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),
|
||||
totalComments: makeSelectTotalCommentsCountForUri(props.uri)(state),
|
||||
claim,
|
||||
allCommentIds: selectCommentIdsForUri(state, uri),
|
||||
pinnedComments: selectPinnedCommentsForUri(state, uri),
|
||||
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(uri)(state),
|
||||
totalComments: makeSelectTotalCommentsCountForUri(uri)(state),
|
||||
claimId: claim && claim.claim_id,
|
||||
channelId,
|
||||
claimIsMine: selectClaimIsMine(state, claim),
|
||||
isFetchingComments: selectIsFetchingComments(state),
|
||||
isFetchingCommentsById: selectIsFetchingCommentsById(state),
|
||||
@@ -55,12 +59,12 @@ const select = (state, props) => {
|
||||
};
|
||||
};
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
fetchTopLevelComments: (uri, page, pageSize, sortBy) => dispatch(doCommentList(uri, '', page, pageSize, sortBy)),
|
||||
fetchComment: (commentId) => dispatch(doCommentById(commentId)),
|
||||
fetchReacts: (commentIds) => dispatch(doCommentReactList(commentIds)),
|
||||
resetComments: (claimId) => dispatch(doCommentReset(claimId)),
|
||||
doResolveUris: (uris) => dispatch(doResolveUris(uris, true)),
|
||||
});
|
||||
const perform = {
|
||||
fetchTopLevelComments: doCommentList,
|
||||
fetchComment: doCommentById,
|
||||
fetchReacts: doCommentReactList,
|
||||
resetComments: doCommentReset,
|
||||
doResolveUris,
|
||||
};
|
||||
|
||||
export default connect(select, perform)(CommentsList);
|
||||
+153
-108
@@ -1,9 +1,8 @@
|
||||
// @flow
|
||||
import { COMMENT_HIGHLIGHTED } from 'constants/classnames';
|
||||
import { COMMENT_PAGE_SIZE_TOP_LEVEL, SORT_BY } from 'constants/comment';
|
||||
import { ENABLE_COMMENT_REACTIONS } from 'config';
|
||||
import { getChannelIdFromClaim } from 'util/claim';
|
||||
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
|
||||
import { getCommentsListTitle } from 'util/comments';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as REACTION_TYPES from 'constants/reactions';
|
||||
import Button from 'component/button';
|
||||
@@ -15,7 +14,6 @@ import debounce from 'util/debounce';
|
||||
import Empty from 'component/common/empty';
|
||||
import React, { useEffect } from 'react';
|
||||
import Spinner from 'component/spinner';
|
||||
import useFetched from 'effects/use-fetched';
|
||||
import usePersistedState from 'effects/use-persisted-state';
|
||||
|
||||
const DEBOUNCE_SCROLL_HANDLER_MS = 200;
|
||||
@@ -32,11 +30,12 @@ type Props = {
|
||||
allCommentIds: any,
|
||||
pinnedComments: Array<Comment>,
|
||||
topLevelComments: Array<Comment>,
|
||||
resolvedComments: Array<Comment>,
|
||||
topLevelTotalPages: number,
|
||||
uri: string,
|
||||
claim: ?Claim,
|
||||
claimId?: string,
|
||||
channelId?: string,
|
||||
claimIsMine: boolean,
|
||||
myChannels: ?Array<ChannelClaim>,
|
||||
isFetchingComments: boolean,
|
||||
isFetchingCommentsById: boolean,
|
||||
isFetchingReacts: boolean,
|
||||
@@ -47,25 +46,26 @@ type Props = {
|
||||
othersReactsById: ?{ [string]: { [REACTION_TYPES.LIKE | REACTION_TYPES.DISLIKE]: number } },
|
||||
activeChannelId: ?string,
|
||||
settingsByChannelId: { [channelId: string]: PerChannelSettings },
|
||||
fetchReacts: (Array<string>) => Promise<any>,
|
||||
commentsAreExpanded?: boolean,
|
||||
fetchTopLevelComments: (string, number, number, number) => void,
|
||||
fetchComment: (string) => void,
|
||||
resetComments: (string) => void,
|
||||
fetchTopLevelComments: (uri: string, parentId: string, page: number, pageSize: number, sortBy: number) => void,
|
||||
fetchComment: (commentId: string) => void,
|
||||
fetchReacts: (commentIds: Array<string>) => Promise<any>,
|
||||
resetComments: (claimId: string) => void,
|
||||
doResolveUris: (uris: Array<string>, returnCachedClaims: boolean) => void,
|
||||
};
|
||||
|
||||
function CommentList(props: Props) {
|
||||
export default function CommentList(props: Props) {
|
||||
const {
|
||||
allCommentIds,
|
||||
uri,
|
||||
pinnedComments,
|
||||
topLevelComments,
|
||||
resolvedComments,
|
||||
topLevelTotalPages,
|
||||
claim,
|
||||
claimId,
|
||||
channelId,
|
||||
claimIsMine,
|
||||
myChannels,
|
||||
isFetchingComments,
|
||||
isFetchingCommentsById,
|
||||
isFetchingReacts,
|
||||
linkedCommentId,
|
||||
totalComments,
|
||||
@@ -74,28 +74,33 @@ function CommentList(props: Props) {
|
||||
othersReactsById,
|
||||
activeChannelId,
|
||||
settingsByChannelId,
|
||||
fetchReacts,
|
||||
commentsAreExpanded,
|
||||
fetchTopLevelComments,
|
||||
fetchComment,
|
||||
fetchReacts,
|
||||
resetComments,
|
||||
doResolveUris,
|
||||
} = props;
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
const isMediumScreen = useIsMediumScreen();
|
||||
|
||||
const spinnerRef = React.useRef();
|
||||
const DEFAULT_SORT = ENABLE_COMMENT_REACTIONS ? SORT_BY.POPULARITY : SORT_BY.NEWEST;
|
||||
const [sort, setSort] = usePersistedState('comment-sort-by', DEFAULT_SORT);
|
||||
const [page, setPage] = React.useState(0);
|
||||
const fetchedCommentsOnce = useFetched(isFetchingComments);
|
||||
const fetchedReactsOnce = useFetched(isFetchingReacts);
|
||||
const fetchedLinkedComment = useFetched(isFetchingCommentsById);
|
||||
const hasDefaultExpansion = commentsAreExpanded || (!isMobile && !isMediumScreen);
|
||||
const [commentsToDisplay, setCommentsToDisplay] = React.useState(topLevelComments);
|
||||
const [didInitialPageFetch, setInitialPageFetch] = React.useState(false);
|
||||
const hasDefaultExpansion = commentsAreExpanded || !isMediumScreen || isMobile;
|
||||
const [expandedComments, setExpandedComments] = React.useState(hasDefaultExpansion);
|
||||
|
||||
const totalFetchedComments = allCommentIds ? allCommentIds.length : 0;
|
||||
const channelId = getChannelIdFromClaim(claim);
|
||||
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
|
||||
const moreBelow = page < topLevelTotalPages;
|
||||
const isResolvingComments = topLevelComments && resolvedComments.length !== topLevelComments.length;
|
||||
const alreadyResolved = !isResolvingComments && resolvedComments.length !== 0;
|
||||
const canDisplayComments = commentsToDisplay && commentsToDisplay.length === topLevelComments.length;
|
||||
const title = getCommentsListTitle(totalComments);
|
||||
|
||||
// Display comments immediately if not fetching reactions
|
||||
// If not, wait to show comments until reactions are fetched
|
||||
@@ -113,8 +118,8 @@ function CommentList(props: Props) {
|
||||
// Reset comments
|
||||
useEffect(() => {
|
||||
if (page === 0) {
|
||||
if (claim) {
|
||||
resetComments(claim.claim_id);
|
||||
if (claimId) {
|
||||
resetComments(claimId);
|
||||
}
|
||||
setPage(1);
|
||||
}
|
||||
@@ -128,7 +133,7 @@ function CommentList(props: Props) {
|
||||
fetchComment(linkedCommentId);
|
||||
}
|
||||
|
||||
fetchTopLevelComments(uri, page, COMMENT_PAGE_SIZE_TOP_LEVEL, sort);
|
||||
fetchTopLevelComments(uri, '', page, COMMENT_PAGE_SIZE_TOP_LEVEL, sort);
|
||||
}
|
||||
}, [fetchComment, fetchTopLevelComments, linkedCommentId, page, sort, uri]);
|
||||
|
||||
@@ -167,23 +172,17 @@ function CommentList(props: Props) {
|
||||
|
||||
// Scroll to linked-comment
|
||||
useEffect(() => {
|
||||
if (fetchedLinkedComment && fetchedCommentsOnce && fetchedReactsOnce) {
|
||||
const elems = document.getElementsByClassName(COMMENT_HIGHLIGHTED);
|
||||
if (elems.length > 0) {
|
||||
const ROUGH_HEADER_HEIGHT = 125; // @see: --header-height
|
||||
const linkedComment = elems[0];
|
||||
window.scrollTo({
|
||||
top: linkedComment.getBoundingClientRect().top + window.scrollY - ROUGH_HEADER_HEIGHT,
|
||||
left: 0,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}
|
||||
if (linkedCommentId) {
|
||||
window.pendingLinkedCommentScroll = true;
|
||||
} else {
|
||||
delete window.pendingLinkedCommentScroll;
|
||||
}
|
||||
}, [fetchedLinkedComment, fetchedCommentsOnce, fetchedReactsOnce]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// Infinite scroll
|
||||
useEffect(() => {
|
||||
function shouldFetchNextPage(page, topLevelTotalPages, window, document, yPrefetchPx = 1000) {
|
||||
function shouldFetchNextPage(page, topLevelTotalPages, yPrefetchPx = 1000) {
|
||||
if (!spinnerRef || !spinnerRef.current) return false;
|
||||
|
||||
const rect = spinnerRef.current.getBoundingClientRect(); // $FlowFixMe
|
||||
@@ -206,86 +205,67 @@ function CommentList(props: Props) {
|
||||
}
|
||||
|
||||
const handleCommentScroll = debounce(() => {
|
||||
if (hasDefaultExpansion && shouldFetchNextPage(page, topLevelTotalPages, window, document)) {
|
||||
if (shouldFetchNextPage(page, topLevelTotalPages)) {
|
||||
setPage(page + 1);
|
||||
setInitialPageFetch(true);
|
||||
}
|
||||
}, DEBOUNCE_SCROLL_HANDLER_MS);
|
||||
|
||||
if (!isFetchingComments && readyToDisplayComments && moreBelow && spinnerRef && spinnerRef.current) {
|
||||
if (shouldFetchNextPage(page, topLevelTotalPages, window, document, 0)) {
|
||||
setPage(page + 1);
|
||||
} else {
|
||||
window.addEventListener('scroll', handleCommentScroll);
|
||||
return () => window.removeEventListener('scroll', handleCommentScroll);
|
||||
if (!didInitialPageFetch) {
|
||||
handleCommentScroll();
|
||||
setInitialPageFetch(true);
|
||||
}
|
||||
|
||||
if (hasDefaultExpansion && !isFetchingComments && canDisplayComments && readyToDisplayComments && moreBelow) {
|
||||
const commentsInDrawer = Boolean(document.querySelector('.MuiDrawer-root .card--enable-overflow'));
|
||||
const scrollingElement = commentsInDrawer ? document.querySelector('.card--enable-overflow') : window;
|
||||
|
||||
if (scrollingElement) {
|
||||
scrollingElement.addEventListener('scroll', handleCommentScroll);
|
||||
|
||||
return () => scrollingElement.removeEventListener('scroll', handleCommentScroll);
|
||||
}
|
||||
}
|
||||
}, [hasDefaultExpansion, isFetchingComments, moreBelow, page, readyToDisplayComments, topLevelTotalPages]);
|
||||
}, [
|
||||
canDisplayComments,
|
||||
hasDefaultExpansion,
|
||||
didInitialPageFetch,
|
||||
isFetchingComments,
|
||||
isMobile,
|
||||
moreBelow,
|
||||
page,
|
||||
readyToDisplayComments,
|
||||
topLevelTotalPages,
|
||||
]);
|
||||
|
||||
const getCommentElems = (comments) => {
|
||||
return comments.map((comment) => (
|
||||
<CommentView
|
||||
isTopLevel
|
||||
threadDepth={3}
|
||||
key={comment.comment_id}
|
||||
uri={uri}
|
||||
authorUri={comment.channel_url}
|
||||
author={comment.channel_name}
|
||||
claimId={comment.claim_id}
|
||||
commentId={comment.comment_id}
|
||||
message={comment.comment}
|
||||
timePosted={comment.timestamp * 1000}
|
||||
claimIsMine={claimIsMine}
|
||||
commentIsMine={
|
||||
comment.channel_id && myChannels && myChannels.some(({ claim_id }) => claim_id === comment.channel_id)
|
||||
}
|
||||
linkedCommentId={linkedCommentId}
|
||||
isPinned={comment.is_pinned}
|
||||
supportAmount={comment.support_amount}
|
||||
numDirectReplies={comment.replies}
|
||||
isModerator={comment.is_moderator}
|
||||
isGlobalMod={comment.is_global_mod}
|
||||
isFiat={comment.is_fiat}
|
||||
/>
|
||||
));
|
||||
};
|
||||
// Wait to only display topLevelComments after resolved or else
|
||||
// other components will try to resolve again, like channelThumbnail
|
||||
useEffect(() => {
|
||||
if (!isResolvingComments) setCommentsToDisplay(topLevelComments);
|
||||
}, [isResolvingComments, topLevelComments]);
|
||||
|
||||
const sortButton = (label, icon, sortOption) => {
|
||||
return (
|
||||
<Button
|
||||
button="alt"
|
||||
label={label}
|
||||
icon={icon}
|
||||
iconSize={18}
|
||||
onClick={() => changeSort(sortOption)}
|
||||
className={classnames(`button-toggle`, {
|
||||
'button-toggle--active': sort === sortOption,
|
||||
})}
|
||||
/>
|
||||
);
|
||||
};
|
||||
// Batch resolve comment channel urls
|
||||
useEffect(() => {
|
||||
if (!topLevelComments || alreadyResolved) return;
|
||||
|
||||
const urisToResolve = [];
|
||||
topLevelComments.map(({ channel_url }) => channel_url !== undefined && urisToResolve.push(channel_url));
|
||||
|
||||
if (urisToResolve.length > 0) doResolveUris(urisToResolve, true);
|
||||
}, [alreadyResolved, doResolveUris, topLevelComments]);
|
||||
|
||||
const commentProps = { isTopLevel: true, threadDepth: 3, uri, claimIsMine, linkedCommentId };
|
||||
const actionButtonsProps = { totalComments, sort, changeSort, setPage };
|
||||
|
||||
return (
|
||||
<Card
|
||||
className="card--enable-overflow"
|
||||
title={
|
||||
(totalComments === 0 && __('Leave a comment')) ||
|
||||
(totalComments === 1 && __('1 comment')) ||
|
||||
__('%totalComments% comments', { totalComments })
|
||||
}
|
||||
titleActions={
|
||||
<>
|
||||
{totalComments > 1 && ENABLE_COMMENT_REACTIONS && (
|
||||
<span className="comment__sort">
|
||||
{sortButton(__('Best'), ICONS.BEST, SORT_BY.POPULARITY)}
|
||||
{sortButton(__('Controversial'), ICONS.CONTROVERSIAL, SORT_BY.CONTROVERSY)}
|
||||
{sortButton(__('New'), ICONS.NEW, SORT_BY.NEWEST)}
|
||||
</span>
|
||||
)}
|
||||
<Button button="alt" icon={ICONS.REFRESH} title={__('Refresh')} onClick={() => setPage(0)} />
|
||||
</>
|
||||
}
|
||||
title={!isMobile && title}
|
||||
titleActions={<CommentActionButtons {...actionButtonsProps} />}
|
||||
actions={
|
||||
<>
|
||||
{isMobile && <CommentActionButtons {...actionButtonsProps} />}
|
||||
|
||||
<CommentCreate uri={uri} />
|
||||
|
||||
{channelSettings && channelSettings.comments_enabled && !isFetchingComments && !totalComments && (
|
||||
@@ -294,15 +274,20 @@ function CommentList(props: Props) {
|
||||
|
||||
<ul
|
||||
className={classnames({
|
||||
comments: expandedComments,
|
||||
'comments--contracted': !expandedComments,
|
||||
comments: !isMediumScreen || expandedComments,
|
||||
'comments--contracted': isMediumScreen && !expandedComments,
|
||||
})}
|
||||
>
|
||||
{readyToDisplayComments && pinnedComments && getCommentElems(pinnedComments)}
|
||||
{readyToDisplayComments && topLevelComments && getCommentElems(topLevelComments)}
|
||||
{readyToDisplayComments && (
|
||||
<>
|
||||
{pinnedComments && <CommentElements comments={pinnedComments} {...commentProps} />}
|
||||
|
||||
{commentsToDisplay && <CommentElements comments={commentsToDisplay} {...commentProps} />}
|
||||
</>
|
||||
)}
|
||||
</ul>
|
||||
|
||||
{!hasDefaultExpansion && topLevelComments && Boolean(topLevelComments.length) && (
|
||||
{!hasDefaultExpansion && (
|
||||
<div className="card__bottom-actions--comments">
|
||||
{(!expandedComments || moreBelow) && (
|
||||
<Button
|
||||
@@ -323,7 +308,7 @@ function CommentList(props: Props) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(isFetchingComments || (hasDefaultExpansion && moreBelow)) && (
|
||||
{(isFetchingComments || (hasDefaultExpansion && moreBelow) || !canDisplayComments) && (
|
||||
<div className="main--empty" ref={spinnerRef}>
|
||||
<Spinner type="small" />
|
||||
</div>
|
||||
@@ -334,4 +319,64 @@ function CommentList(props: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
export default CommentList;
|
||||
type CommentProps = {
|
||||
comments: Array<Comment>,
|
||||
};
|
||||
|
||||
const CommentElements = (commentProps: CommentProps) => {
|
||||
const { comments, ...commentsProps } = commentProps;
|
||||
|
||||
return comments.map((comment) => <CommentView key={comment.comment_id} comment={comment} {...commentsProps} />);
|
||||
};
|
||||
|
||||
type ActionButtonsProps = {
|
||||
totalComments: number,
|
||||
sort: string,
|
||||
changeSort: (string) => void,
|
||||
setPage: (number) => void,
|
||||
};
|
||||
|
||||
const CommentActionButtons = (actionButtonsProps: ActionButtonsProps) => {
|
||||
const { totalComments, sort, changeSort, setPage } = actionButtonsProps;
|
||||
|
||||
const sortButtonProps = { activeSort: sort, changeSort };
|
||||
|
||||
return (
|
||||
<>
|
||||
{totalComments > 1 && ENABLE_COMMENT_REACTIONS && (
|
||||
<span className="comment__sort">
|
||||
<SortButton {...sortButtonProps} label={__('Best')} icon={ICONS.BEST} sortOption={SORT_BY.POPULARITY} />
|
||||
<SortButton
|
||||
{...sortButtonProps}
|
||||
label={__('Controversial')}
|
||||
icon={ICONS.CONTROVERSIAL}
|
||||
sortOption={SORT_BY.CONTROVERSY}
|
||||
/>
|
||||
<SortButton {...sortButtonProps} label={__('New')} icon={ICONS.NEW} sortOption={SORT_BY.NEWEST} />
|
||||
</span>
|
||||
)}
|
||||
|
||||
<Button button="alt" icon={ICONS.REFRESH} title={__('Refresh')} onClick={() => setPage(0)} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
type SortButtonProps = {
|
||||
activeSort: string,
|
||||
sortOption: string,
|
||||
changeSort: (string) => void,
|
||||
};
|
||||
|
||||
const SortButton = (sortButtonProps: SortButtonProps) => {
|
||||
const { activeSort, sortOption, changeSort, ...buttonProps } = sortButtonProps;
|
||||
|
||||
return (
|
||||
<Button
|
||||
{...buttonProps}
|
||||
className={classnames(`button-toggle`, { 'button-toggle--active': activeSort === sortOption })}
|
||||
button="alt"
|
||||
iconSize={18}
|
||||
onClick={() => changeSort(sortOption)}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doResolveUris } from 'redux/actions/claims';
|
||||
import { makeSelectClaimIsMine, selectMyChannelClaims, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectClaimIsMineForUri, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectIsFetchingCommentsByParentId, selectRepliesForParentId } from 'redux/selectors/comments';
|
||||
import CommentsReplies from './view';
|
||||
|
||||
@@ -14,9 +14,8 @@ const select = (state, props) => {
|
||||
return {
|
||||
fetchedReplies,
|
||||
resolvedReplies,
|
||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||
claimIsMine: selectClaimIsMineForUri(state, props.uri),
|
||||
userCanComment: true,
|
||||
myChannels: selectMyChannelClaims(state),
|
||||
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
// @flow
|
||||
import * as ICONS from 'constants/icons';
|
||||
import React from 'react';
|
||||
import Comment from 'component/comment';
|
||||
import Button from 'component/button';
|
||||
import Comment from 'component/comment';
|
||||
import React from 'react';
|
||||
import Spinner from 'component/spinner';
|
||||
|
||||
type Props = {
|
||||
fetchedReplies: Array<any>,
|
||||
fetchedReplies: Array<Comment>,
|
||||
resolvedReplies: Array<Comment>,
|
||||
uri: string,
|
||||
parentId: string,
|
||||
claimIsMine: boolean,
|
||||
myChannels: ?Array<ChannelClaim>,
|
||||
linkedCommentId?: string,
|
||||
commentingEnabled: boolean,
|
||||
userCanComment: boolean,
|
||||
threadDepth: number,
|
||||
numDirectReplies: number, // Total replies for parentId as reported by 'comment[replies]'. Includes blocked items.
|
||||
isFetchingByParentId: { [string]: boolean },
|
||||
onShowMore?: () => void,
|
||||
hasMore: boolean,
|
||||
supportDisabled: boolean,
|
||||
doResolveUris: (Array<string>) => void,
|
||||
onShowMore?: () => void,
|
||||
};
|
||||
|
||||
function CommentsReplies(props: Props) {
|
||||
@@ -26,102 +27,93 @@ function CommentsReplies(props: Props) {
|
||||
uri,
|
||||
parentId,
|
||||
fetchedReplies,
|
||||
resolvedReplies,
|
||||
claimIsMine,
|
||||
myChannels,
|
||||
linkedCommentId,
|
||||
commentingEnabled,
|
||||
userCanComment,
|
||||
threadDepth,
|
||||
numDirectReplies,
|
||||
isFetchingByParentId,
|
||||
onShowMore,
|
||||
hasMore,
|
||||
supportDisabled,
|
||||
doResolveUris,
|
||||
onShowMore,
|
||||
} = props;
|
||||
|
||||
const [isExpanded, setExpanded] = React.useState(true);
|
||||
const [commentsToDisplay, setCommentsToDisplay] = React.useState(fetchedReplies);
|
||||
const isResolvingReplies = fetchedReplies && resolvedReplies.length !== fetchedReplies.length;
|
||||
const alreadyResolved = !isResolvingReplies && resolvedReplies.length !== 0;
|
||||
const canDisplayComments = commentsToDisplay && commentsToDisplay.length === fetchedReplies.length;
|
||||
|
||||
function showMore() {
|
||||
if (onShowMore) {
|
||||
onShowMore();
|
||||
}
|
||||
}
|
||||
// Batch resolve comment channel urls
|
||||
React.useEffect(() => {
|
||||
if (!fetchedReplies || alreadyResolved) return;
|
||||
|
||||
// todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine
|
||||
function isMyComment(channelId: string) {
|
||||
if (myChannels != null && channelId != null) {
|
||||
for (let i = 0; i < myChannels.length; i++) {
|
||||
if (myChannels[i].claim_id === channelId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const urisToResolve = [];
|
||||
fetchedReplies.map(({ channel_url }) => channel_url !== undefined && urisToResolve.push(channel_url));
|
||||
|
||||
const displayedComments = fetchedReplies;
|
||||
if (urisToResolve.length > 0) doResolveUris(urisToResolve);
|
||||
}, [alreadyResolved, doResolveUris, fetchedReplies]);
|
||||
|
||||
return (
|
||||
Boolean(numDirectReplies) && (
|
||||
<div className="comment__replies-container">
|
||||
{Boolean(numDirectReplies) && !isExpanded && (
|
||||
// Wait to only display topLevelComments after resolved or else
|
||||
// other components will try to resolve again, like channelThumbnail
|
||||
React.useEffect(() => {
|
||||
if (!isResolvingReplies) setCommentsToDisplay(fetchedReplies);
|
||||
}, [isResolvingReplies, fetchedReplies]);
|
||||
|
||||
return !numDirectReplies ? null : (
|
||||
<div className="comment__replies-container">
|
||||
{!isExpanded ? (
|
||||
<div className="comment__actions--nested">
|
||||
<Button
|
||||
className="comment__action"
|
||||
label={__('Show Replies')}
|
||||
onClick={() => setExpanded(!isExpanded)}
|
||||
icon={isExpanded ? ICONS.UP : ICONS.DOWN}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="comment__replies">
|
||||
<Button className="comment__threadline" aria-label="Hide Replies" onClick={() => setExpanded(false)} />
|
||||
|
||||
<ul className="comments--replies">
|
||||
{!isResolvingReplies &&
|
||||
commentsToDisplay &&
|
||||
commentsToDisplay.length > 0 &&
|
||||
commentsToDisplay.map((comment) => (
|
||||
<Comment
|
||||
key={comment.comment_id}
|
||||
threadDepth={threadDepth}
|
||||
uri={uri}
|
||||
comment={comment}
|
||||
claimIsMine={claimIsMine}
|
||||
linkedCommentId={linkedCommentId}
|
||||
commentingEnabled={userCanComment}
|
||||
supportDisabled={supportDisabled}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
{isExpanded && fetchedReplies && hasMore && (
|
||||
<div className="comment__actions--nested">
|
||||
<Button
|
||||
button="link"
|
||||
label={__('Show more')}
|
||||
onClick={() => onShowMore && onShowMore()}
|
||||
className="button--uri-indicator"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{(isFetchingByParentId[parentId] || isResolvingReplies || !canDisplayComments) && (
|
||||
<div className="comment__replies-container">
|
||||
<div className="comment__actions--nested">
|
||||
<Button
|
||||
className="comment__action"
|
||||
label={__('Show Replies')}
|
||||
onClick={() => setExpanded(!isExpanded)}
|
||||
icon={isExpanded ? ICONS.UP : ICONS.DOWN}
|
||||
/>
|
||||
<Spinner type="small" />
|
||||
</div>
|
||||
)}
|
||||
{isExpanded && (
|
||||
<div>
|
||||
<div className="comment__replies">
|
||||
<Button className="comment__threadline" aria-label="Hide Replies" onClick={() => setExpanded(false)} />
|
||||
|
||||
<ul className="comments--replies">
|
||||
{displayedComments &&
|
||||
displayedComments.map((comment) => {
|
||||
return (
|
||||
<Comment
|
||||
threadDepth={threadDepth}
|
||||
uri={uri}
|
||||
authorUri={comment.channel_url}
|
||||
author={comment.channel_name}
|
||||
claimId={comment.claim_id}
|
||||
commentId={comment.comment_id}
|
||||
key={comment.comment_id}
|
||||
message={comment.comment}
|
||||
timePosted={comment.timestamp * 1000}
|
||||
claimIsMine={claimIsMine}
|
||||
commentIsMine={comment.channel_id && isMyComment(comment.channel_id)}
|
||||
linkedCommentId={linkedCommentId}
|
||||
commentingEnabled={commentingEnabled}
|
||||
supportAmount={comment.support_amount}
|
||||
numDirectReplies={comment.replies}
|
||||
isModerator={comment.is_moderator}
|
||||
isGlobalMod={comment.is_global_mod}
|
||||
supportDisabled={supportDisabled}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{isExpanded && fetchedReplies && hasMore && (
|
||||
<div className="comment__actions--nested">
|
||||
<Button button="link" label={__('Show more')} onClick={showMore} className="button--uri-indicator" />
|
||||
</div>
|
||||
)}
|
||||
{isFetchingByParentId[parentId] && (
|
||||
<div className="comment__replies-container">
|
||||
<div className="comment__actions--nested">
|
||||
<Spinner type="small" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// @flow
|
||||
import 'scss/component/_comment-badge.scss';
|
||||
|
||||
import classnames from 'classnames';
|
||||
import Icon from 'component/common/icon';
|
||||
import React from 'react';
|
||||
import Tooltip from 'component/common/tooltip';
|
||||
|
||||
const LABEL_TYPES = {
|
||||
ADMIN: 'Admin',
|
||||
MOD: 'Moderator',
|
||||
};
|
||||
|
||||
type Props = {
|
||||
icon: string,
|
||||
label: string,
|
||||
size?: number,
|
||||
};
|
||||
|
||||
export default function CommentBadge(props: Props) {
|
||||
const { icon, label, size = 20 } = props;
|
||||
|
||||
return (
|
||||
<Tooltip title={label} placement="top">
|
||||
<span
|
||||
className={classnames('comment__badge', {
|
||||
'comment__badge--globalMod': label === LABEL_TYPES.ADMIN,
|
||||
'comment__badge--mod': label === LABEL_TYPES.MOD,
|
||||
})}
|
||||
>
|
||||
<Icon icon={icon} size={size} />
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
// @flow
|
||||
import * as React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import remark from 'remark';
|
||||
import remarkAttr from 'remark-attr';
|
||||
import remarkStrip from 'strip-markdown';
|
||||
import remarkEmoji from 'remark-emoji';
|
||||
import remarkBreaks from 'remark-breaks';
|
||||
import remarkFrontMatter from 'remark-frontmatter';
|
||||
import reactRenderer from 'remark-react';
|
||||
import MarkdownLink from 'component/markdownLink';
|
||||
import defaultSchema from 'hast-util-sanitize/lib/github.json';
|
||||
import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS } from 'config';
|
||||
import { formattedLinks, inlineLinks } from 'util/remark-lbry';
|
||||
import { formattedTimestamp, inlineTimestamp } from 'util/remark-timestamp';
|
||||
import { formattedEmote, inlineEmote } from 'util/remark-emote';
|
||||
import ZoomableImage from 'component/zoomableImage';
|
||||
import { CHANNEL_STAKED_LEVEL_VIDEO_COMMENTS } from 'config';
|
||||
import Button from 'component/button';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import { parse } from 'node-html-parser';
|
||||
import * as React from 'react';
|
||||
import Button from 'component/button';
|
||||
import classnames from 'classnames';
|
||||
import defaultSchema from 'hast-util-sanitize/lib/github.json';
|
||||
import MarkdownLink from 'component/markdownLink';
|
||||
import OptimizedImage from 'component/optimizedImage';
|
||||
import reactRenderer from 'remark-react';
|
||||
import remark from 'remark';
|
||||
import remarkAttr from 'remark-attr';
|
||||
import remarkBreaks from 'remark-breaks';
|
||||
import remarkEmoji from 'remark-emoji';
|
||||
import remarkFrontMatter from 'remark-frontmatter';
|
||||
import remarkStrip from 'strip-markdown';
|
||||
import ZoomableImage from 'component/zoomableImage';
|
||||
import { parse } from 'node-html-parser';
|
||||
|
||||
const RE_EMOTE = /:\+1:|:-1:|:[\w-]+:/;
|
||||
|
||||
@@ -146,7 +146,7 @@ function isStakeEnoughForPreview(stakedLevel) {
|
||||
// ****************************************************************************
|
||||
// ****************************************************************************
|
||||
|
||||
const MarkdownPreview = (props: MarkdownProps) => {
|
||||
export default React.memo<MarkdownProps>(function MarkdownPreview(props: MarkdownProps) {
|
||||
const {
|
||||
content,
|
||||
strip,
|
||||
@@ -173,15 +173,10 @@ const MarkdownPreview = (props: MarkdownProps) => {
|
||||
if (lbrySrc && lbrySrc.startsWith('lbry://')) {
|
||||
return lbrySrc;
|
||||
}
|
||||
|
||||
return iframeHtml;
|
||||
})
|
||||
: '';
|
||||
|
||||
const initialQuote = strippedContent.split(' ').find((word) => word.length > 0 || word.charAt(0) === '>');
|
||||
let stripQuote;
|
||||
if (initialQuote && initialQuote.charAt(0) === '>') stripQuote = true;
|
||||
|
||||
const remarkOptions: Object = {
|
||||
sanitize: schema,
|
||||
fragment: React.Fragment,
|
||||
@@ -201,7 +196,7 @@ const MarkdownPreview = (props: MarkdownProps) => {
|
||||
div: React.Fragment,
|
||||
img: (imgProps) =>
|
||||
isStakeEnoughForPreview(stakedLevel) && !isEmote(imgProps.title, imgProps.src) ? (
|
||||
ZoomableImage
|
||||
<ZoomableImage {...imgProps} />
|
||||
) : (
|
||||
<SimpleImageLink src={imgProps.src} alt={imgProps.alt} title={imgProps.title} />
|
||||
),
|
||||
@@ -216,22 +211,10 @@ const MarkdownPreview = (props: MarkdownProps) => {
|
||||
};
|
||||
|
||||
// Strip all content and just render text
|
||||
if (strip || stripQuote) {
|
||||
if (strip) {
|
||||
// Remove new lines and extra space
|
||||
remarkOptions.remarkReactComponents.p = SimpleText;
|
||||
return stripQuote ? (
|
||||
<span dir="auto" className="markdown-preview">
|
||||
<blockquote>
|
||||
{
|
||||
remark()
|
||||
.use(remarkStrip)
|
||||
.use(remarkFrontMatter, ['yaml'])
|
||||
.use(reactRenderer, remarkOptions)
|
||||
.processSync(content).contents
|
||||
}
|
||||
</blockquote>
|
||||
</span>
|
||||
) : (
|
||||
return (
|
||||
<span dir="auto" className="markdown-preview">
|
||||
{
|
||||
remark()
|
||||
@@ -267,6 +250,4 @@ const MarkdownPreview = (props: MarkdownProps) => {
|
||||
}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MarkdownPreview;
|
||||
});
|
||||
@@ -24,6 +24,7 @@ import PdfViewer from 'component/viewers/pdfViewer';
|
||||
type Props = {
|
||||
uri: string,
|
||||
streamingUrl: string,
|
||||
embedded?: boolean,
|
||||
contentType: string,
|
||||
claim: StreamClaim,
|
||||
currentTheme: string,
|
||||
@@ -44,8 +45,9 @@ class FileRender extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { embedded } = this.props;
|
||||
window.addEventListener('keydown', this.escapeListener, true);
|
||||
analytics.playerLoadedEvent();
|
||||
analytics.playerLoadedEvent(embedded);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -144,12 +146,13 @@ class FileRender extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { renderMode, className } = this.props;
|
||||
const { embedded, renderMode, className } = this.props;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classnames('file-render', className, {
|
||||
'file-render--document': RENDER_MODES.TEXT_MODES.includes(renderMode),
|
||||
'file-render--embed': embedded,
|
||||
'file-render--video': renderMode === RENDER_MODES.VIDEO || renderMode === RENDER_MODES.AUDIO,
|
||||
})}
|
||||
>
|
||||
|
||||
@@ -122,7 +122,6 @@ const Header = (props: Props) => {
|
||||
|
||||
const userButtons = (hideWallet?: boolean, hideProfile?: boolean) => (
|
||||
<div className="header__menu--right">
|
||||
{isMobile && !authHeader && !canBackout && <WunderBar />}
|
||||
<Tooltip
|
||||
title={
|
||||
balance > 0
|
||||
@@ -141,11 +140,9 @@ const Header = (props: Props) => {
|
||||
className="button--file-action header__navigationItem--balance"
|
||||
label={hideBalance || Number(roundedBalance) === 0 ? __('Your Wallet') : roundedBalance}
|
||||
icon={ICONS.LBC}
|
||||
// @if TARGET='app'
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
// @endif
|
||||
/>
|
||||
</div>
|
||||
</Tooltip>
|
||||
@@ -200,11 +197,9 @@ const Header = (props: Props) => {
|
||||
// here use state.router.location.pathname
|
||||
if (history.location.pathname === '/') window.location.reload();
|
||||
}}
|
||||
// @if TARGET='app'
|
||||
onDoubleClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
// @endif
|
||||
{...homeButtonNavigationProps}
|
||||
>
|
||||
<Logo />
|
||||
@@ -213,14 +208,12 @@ const Header = (props: Props) => {
|
||||
|
||||
{!authHeader && (
|
||||
<div className="header__center">
|
||||
{/* @if TARGET='app' */}
|
||||
{!authHeader && (
|
||||
<div className="header__buttons">
|
||||
<NavigationButton isBackward history={history} />
|
||||
<NavigationButton isBackward={false} history={history} />
|
||||
</div>
|
||||
)}
|
||||
{/* @endif */}
|
||||
<WunderBar />
|
||||
<HeaderMenuButtons />
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,6 @@ import { selectHasChannels } from 'redux/selectors/claims';
|
||||
import { selectWalletIsEncrypted } from 'redux/selectors/wallet';
|
||||
import { doWalletStatus } from 'redux/actions/wallet';
|
||||
import { selectUser, selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import { selectLanguage } from 'redux/selectors/settings';
|
||||
|
||||
import SettingAccount from './view';
|
||||
|
||||
@@ -12,7 +11,6 @@ const select = (state) => ({
|
||||
walletEncrypted: selectWalletIsEncrypted(state),
|
||||
user: selectUser(state),
|
||||
hasChannels: selectHasChannels(state),
|
||||
language: selectLanguage(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { selectUser, selectPasswordSetSuccess, selectPasswordSetError } from 'redux/selectors/user';
|
||||
import { selectLanguage } from 'redux/selectors/settings';
|
||||
import { doUserPasswordSet, doClearPasswordEntry } from 'redux/actions/user';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import UserSignIn from './view';
|
||||
|
||||
const select = state => ({
|
||||
const select = (state) => ({
|
||||
user: selectUser(state),
|
||||
passwordSetSuccess: selectPasswordSetSuccess(state),
|
||||
passwordSetError: selectPasswordSetError(state),
|
||||
language: selectLanguage(state),
|
||||
});
|
||||
|
||||
export default connect(select, {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { connect } from 'react-redux';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { selectLanguage, makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import SettingAppearance from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
clock24h: makeSelectClientSetting(SETTINGS.CLOCK_24H)(state),
|
||||
searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state),
|
||||
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
|
||||
language: selectLanguage(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { connect } from 'react-redux';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { doSetAutoLaunch } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting, selectLanguage } from 'redux/selectors/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import SettingAutoLaunch from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
autoLaunch: makeSelectClientSetting(SETTINGS.AUTO_LAUNCH)(state),
|
||||
language: selectLanguage(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -7,11 +7,13 @@ import SettingCommentsServer from './view';
|
||||
const select = (state) => ({
|
||||
customServerEnabled: makeSelectClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_ENABLED)(state),
|
||||
customServerUrl: makeSelectClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_URL)(state),
|
||||
customCommentServers: makeSelectClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVERS)(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
setCustomServerEnabled: (val) => dispatch(doSetClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_ENABLED, val, true)),
|
||||
setCustomServerUrl: (url) => dispatch(doSetClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVER_URL, url, true)),
|
||||
setCustomServers: (servers) => dispatch(doSetClientSetting(SETTINGS.CUSTOM_COMMENTS_SERVERS, servers, true)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(SettingCommentsServer);
|
||||
@@ -0,0 +1,94 @@
|
||||
// @flow
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import Button from 'component/button';
|
||||
import { Form, FormField } from 'component/common/form';
|
||||
import { VALID_IPADDRESS_REGEX, VALID_HOSTNAME_REGEX, VALID_ENDPOINT_REGEX } from 'constants/protocol_regex';
|
||||
|
||||
type Props = {
|
||||
update: (CommentServerDetails) => void,
|
||||
onCancel: (boolean) => void,
|
||||
};
|
||||
|
||||
const isValidServerString = (serverString) => {
|
||||
const si = serverString.indexOf('/');
|
||||
const pi = serverString.indexOf(':');
|
||||
const path = si === -1 ? '' : serverString.slice(si);
|
||||
const hostMaybePort = si === -1 ? serverString : serverString.slice(0, si);
|
||||
const host = pi === -1 ? hostMaybePort : hostMaybePort.slice(0, pi);
|
||||
const port = pi === -1 ? '' : hostMaybePort.slice(pi + 1);
|
||||
const portInt = parseInt(port);
|
||||
|
||||
return (
|
||||
(host === 'localhost' || VALID_IPADDRESS_REGEX.test(host) || VALID_HOSTNAME_REGEX.test(host)) &&
|
||||
(!path || VALID_ENDPOINT_REGEX.test(path)) &&
|
||||
// eslint-disable-next-line
|
||||
(pi === -1 || (port && typeof portInt === 'number' && portInt === portInt))
|
||||
); // NaN !== NaN
|
||||
};
|
||||
|
||||
function ServerInputRow(props: Props) {
|
||||
const { update, onCancel } = props;
|
||||
const [nameString, setNameString] = useState('');
|
||||
const [hostString, setHostString] = useState('');
|
||||
const [useHttps, setUseHttps] = useState(true);
|
||||
|
||||
const getHostString = () => {
|
||||
return `${useHttps ? 'https://' : 'http://'}${hostString}`;
|
||||
};
|
||||
|
||||
const [validServerString, setValidServerString] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setValidServerString(isValidServerString(hostString));
|
||||
}, [hostString, validServerString, setValidServerString]);
|
||||
|
||||
function onSubmit() {
|
||||
const updateValue = { url: getHostString(), name: nameString };
|
||||
update(updateValue);
|
||||
setHostString('');
|
||||
setNameString('');
|
||||
}
|
||||
|
||||
return (
|
||||
<Form onSubmit={onSubmit}>
|
||||
<div className="setting-item-input">
|
||||
<FormField
|
||||
type="text"
|
||||
label={__('Name')}
|
||||
placeholder={'My Server'}
|
||||
value={nameString}
|
||||
onChange={(e) => setNameString(e.target.value)}
|
||||
/>
|
||||
<div className="fieldset-group fieldset-group--smushed fieldset-group--disabled-prefix fieldset-group--row">
|
||||
<div className={'fieldset-section'}>
|
||||
<label htmlFor="serverUrl">{__('URL')}</label>
|
||||
<div className="form-field__prefix">{`${useHttps ? 'https://' : 'http://'}`}</div>
|
||||
</div>
|
||||
<FormField
|
||||
type="text"
|
||||
placeholder={'code.freezepeach.fun'}
|
||||
value={hostString}
|
||||
onChange={(e) => setHostString(e.target.value)}
|
||||
name={'serverUrl'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="setting-item-input">
|
||||
<FormField
|
||||
label={'Use https'}
|
||||
name="use_https"
|
||||
type="checkbox"
|
||||
checked={useHttps}
|
||||
onChange={() => setUseHttps(!useHttps)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="section__actions setting-item-input">
|
||||
<Button type="submit" button="primary" label={__('Add')} disabled={!validServerString || !nameString} />
|
||||
<Button type="button" button="inverse" onClick={() => onCancel(false)} label={__('Cancel')} />
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
||||
export default ServerInputRow;
|
||||
@@ -1,70 +1,100 @@
|
||||
// @flow
|
||||
import { COMMENT_SERVER_NAME } from 'config';
|
||||
import { COMMENT_SERVER_API, COMMENT_SERVER_NAME } from 'config';
|
||||
import React from 'react';
|
||||
import Comments from 'comments';
|
||||
import { FormField } from 'component/common/form';
|
||||
|
||||
const DEBOUNCE_TEXT_INPUT_MS = 500;
|
||||
import ItemInputRow from './internal/input-radio-panel-addCommentServer';
|
||||
import Button from 'component/button';
|
||||
import { FormField } from 'component/common/form-components/form-field';
|
||||
|
||||
type Props = {
|
||||
customServerEnabled: boolean,
|
||||
customServerUrl: string,
|
||||
setCustomServerEnabled: (boolean) => void,
|
||||
setCustomServerUrl: (string) => void,
|
||||
setCustomServers: (Array<CommentServerDetails>) => void,
|
||||
customCommentServers: Array<CommentServerDetails>,
|
||||
};
|
||||
|
||||
const defaultServer = { name: COMMENT_SERVER_NAME, url: COMMENT_SERVER_API };
|
||||
function SettingCommentsServer(props: Props) {
|
||||
const { customServerEnabled, customServerUrl, setCustomServerEnabled, setCustomServerUrl } = props;
|
||||
const [url, setUrl] = React.useState(customServerUrl);
|
||||
const {
|
||||
customServerEnabled,
|
||||
customServerUrl,
|
||||
setCustomServerEnabled,
|
||||
setCustomServerUrl,
|
||||
customCommentServers,
|
||||
setCustomServers,
|
||||
} = props;
|
||||
const [addServer, setAddServer] = React.useState(false);
|
||||
|
||||
const customServersString = JSON.stringify(customCommentServers);
|
||||
|
||||
// "migrate" to make sure any currently set custom server is in saved list
|
||||
React.useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
Comments.setServerUrl(customServerEnabled ? url : undefined);
|
||||
if (url !== customServerUrl) {
|
||||
setCustomServerUrl(url);
|
||||
}
|
||||
}, DEBOUNCE_TEXT_INPUT_MS);
|
||||
// const servers = JSON.parse(customServersString);
|
||||
// if customServerUrl is not in servers, make sure it is.
|
||||
}, [customServerUrl, customServersString, setCustomServers]);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [url, customServerUrl, customServerEnabled, setCustomServerUrl]);
|
||||
const handleSelectServer = (serverItem: CommentServerDetails) => {
|
||||
if (serverItem.url !== COMMENT_SERVER_API) {
|
||||
Comments.setServerUrl(serverItem.url);
|
||||
setCustomServerUrl(serverItem.url);
|
||||
setCustomServerEnabled(true);
|
||||
} else {
|
||||
Comments.setServerUrl(undefined);
|
||||
setCustomServerEnabled(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddServer = (serverItem: CommentServerDetails) => {
|
||||
const newCustomServers = customCommentServers.slice();
|
||||
newCustomServers.push(serverItem);
|
||||
setCustomServers(newCustomServers);
|
||||
handleSelectServer(serverItem);
|
||||
setAddServer(false);
|
||||
};
|
||||
|
||||
const handleRemoveServer = (serverItem: CommentServerDetails) => {
|
||||
handleSelectServer(defaultServer);
|
||||
const newCustomServers = customCommentServers.slice().filter((server) => {
|
||||
return server.url !== serverItem.url;
|
||||
});
|
||||
setCustomServers(newCustomServers);
|
||||
};
|
||||
|
||||
const commentServerLabel = (serverDetails, onRemove) => (
|
||||
<span className={'compound-label'}>
|
||||
<span>{serverDetails.name}</span>
|
||||
<span className="compound-label__details">{serverDetails.url}</span>
|
||||
{onRemove && <Button button={'inverse'} label={__('Remove')} onClick={() => onRemove(serverDetails)} />}
|
||||
</span>
|
||||
);
|
||||
const commentServerRadio = (customServerEnabled, customServerUrl, onClick, onRemove, serverDetails) => (
|
||||
<FormField
|
||||
type="radio"
|
||||
checked={(!customServerEnabled && !onRemove) || (customServerEnabled && customServerUrl === serverDetails.url)}
|
||||
onClick={() => onClick(serverDetails)}
|
||||
label={commentServerLabel(serverDetails, onRemove)}
|
||||
name={`${serverDetails.name}${serverDetails.url}`}
|
||||
key={`${serverDetails.name}${serverDetails.url}`}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<fieldset-section>
|
||||
<FormField
|
||||
type="radio"
|
||||
name="use_default_comments_server"
|
||||
label={__('Default comments server (%name%)', { name: COMMENT_SERVER_NAME })}
|
||||
checked={!customServerEnabled}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
setCustomServerEnabled(false);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<FormField
|
||||
type="radio"
|
||||
name="use_custom_comments_server"
|
||||
label={__('Custom comments server')}
|
||||
checked={customServerEnabled}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
setCustomServerEnabled(true);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
{customServerEnabled && (
|
||||
<div className="section__body">
|
||||
<FormField
|
||||
type="text"
|
||||
placeholder="https://comment.mysite.com"
|
||||
value={url}
|
||||
onChange={(e) => setUrl(e.target.value)}
|
||||
/>
|
||||
<div className={'fieldset-section'}>
|
||||
{commentServerRadio(customServerEnabled, customServerUrl, handleSelectServer, null, defaultServer)}
|
||||
{customCommentServers.map((server) =>
|
||||
commentServerRadio(customServerEnabled, customServerUrl, handleSelectServer, handleRemoveServer, server)
|
||||
)}
|
||||
</div>
|
||||
<div className={'fieldset-section'}>
|
||||
{!addServer && (
|
||||
<div className="section__actions">
|
||||
<Button type="button" button="inverse" onClick={() => setAddServer(true)} label={__('Add A Server')} />
|
||||
</div>
|
||||
)}
|
||||
</fieldset-section>
|
||||
{addServer && <ItemInputRow update={handleAddServer} onCancel={setAddServer} />}
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { selectMyChannelUrls } from 'redux/selectors/claims';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { doSetPlayingUri } from 'redux/actions/content';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { selectShowMatureContent, selectLanguage, makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { selectShowMatureContent, makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
|
||||
import SettingContent from './view';
|
||||
@@ -19,7 +19,6 @@ const select = (state) => ({
|
||||
instantPurchaseEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state),
|
||||
instantPurchaseMax: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state),
|
||||
enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state),
|
||||
language: selectLanguage(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -99,6 +99,7 @@ export default function SettingContent(props: Props) {
|
||||
}
|
||||
setClientSetting(SETTINGS.HIDE_REPOSTS, !hideReposts);
|
||||
}}
|
||||
checked={hideReposts}
|
||||
/>
|
||||
</SettingsRow>
|
||||
<SettingsRow title={__('Show mature content')} subtitle={__(HELP.SHOW_MATURE)}>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doSetDaemonSetting, doGetDaemonStatus, doCleanBlobs } from 'redux/actions/settings';
|
||||
import { selectDaemonStatus, selectDaemonSettings } from 'redux/selectors/settings';
|
||||
import SettingWalletServer from './view';
|
||||
import { selectDiskSpace } from 'redux/selectors/app';
|
||||
|
||||
const select = (state) => ({
|
||||
daemonSettings: selectDaemonSettings(state),
|
||||
daemonStatus: selectDaemonStatus(state),
|
||||
diskSpace: selectDiskSpace(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
getDaemonStatus: () => dispatch(doGetDaemonStatus()),
|
||||
setDaemonSetting: (key, value) => dispatch(doSetDaemonSetting(key, value)),
|
||||
cleanBlobs: () => dispatch(doCleanBlobs()),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(SettingWalletServer);
|
||||
@@ -0,0 +1,210 @@
|
||||
// @flow
|
||||
|
||||
import React from 'react';
|
||||
import { FormField } from 'component/common/form';
|
||||
import Button from 'component/button';
|
||||
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
||||
import { formatBytes } from 'util/format-bytes';
|
||||
import { isTrulyANumber } from 'util/number';
|
||||
import I18nMessage from 'component/i18nMessage';
|
||||
const BYTES_PER_MB = 1048576;
|
||||
const ENABLE_AUTOMATIC_HOSTING = false;
|
||||
|
||||
type Price = {
|
||||
currency: string,
|
||||
amount: number,
|
||||
};
|
||||
|
||||
type DaemonStatus = {
|
||||
disk_space: {
|
||||
content_blobs_storage_used_mb: string,
|
||||
published_blobs_storage_used_mb: string,
|
||||
running: true,
|
||||
seed_blobs_storage_used_mb: string,
|
||||
total_used_mb: string,
|
||||
},
|
||||
};
|
||||
|
||||
type SetDaemonSettingArg = boolean | string | number | Price;
|
||||
|
||||
type DaemonSettings = {
|
||||
download_dir: string,
|
||||
share_usage_data: boolean,
|
||||
max_key_fee?: Price,
|
||||
max_connections_per_download?: number,
|
||||
save_files: boolean,
|
||||
save_blobs: boolean,
|
||||
ffmpeg_path: string,
|
||||
};
|
||||
|
||||
type Props = {
|
||||
// --- select ---
|
||||
daemonSettings: DaemonSettings,
|
||||
daemonStatus: DaemonStatus,
|
||||
// --- perform ---
|
||||
setDaemonSetting: (string, ?SetDaemonSettingArg) => void,
|
||||
cleanBlobs: () => string,
|
||||
diskSpace?: DiskSpace,
|
||||
getDaemonStatus: () => void,
|
||||
};
|
||||
|
||||
function SettingDataHosting(props: Props) {
|
||||
const { daemonSettings, daemonStatus, setDaemonSetting, cleanBlobs, diskSpace, getDaemonStatus } = props;
|
||||
|
||||
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 === '') {
|
||||
setNetworkBlobSpaceLimit('');
|
||||
} else {
|
||||
const numberGb = Number(gb);
|
||||
if (isTrulyANumber(numberGb)) {
|
||||
setNetworkBlobSpaceLimit(gb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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(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
|
||||
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>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default SettingDataHosting;
|
||||
@@ -0,0 +1,17 @@
|
||||
import SettingDisableAutoUpdates from './view';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { connect } from 'react-redux';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
|
||||
const select = (state) => {
|
||||
return {
|
||||
disableAutoUpdates: makeSelectClientSetting(SETTINGS.DISABLE_AUTO_UPDATES)(state),
|
||||
};
|
||||
};
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
setClientSetting: (value) => dispatch(doSetClientSetting(SETTINGS.DISABLE_AUTO_UPDATES, value)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(SettingDisableAutoUpdates);
|
||||
@@ -0,0 +1,26 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { FormField } from 'component/common/form';
|
||||
|
||||
type Props = {
|
||||
setClientSetting: (boolean) => void,
|
||||
disableAutoUpdates: boolean,
|
||||
};
|
||||
function SettingDisableAutoUpdates(props: Props) {
|
||||
const { setClientSetting, disableAutoUpdates } = props;
|
||||
return (
|
||||
<React.Fragment>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="autoupdates"
|
||||
onChange={() => {
|
||||
const newDisableAutoUpdates = !disableAutoUpdates;
|
||||
setClientSetting(newDisableAutoUpdates);
|
||||
}}
|
||||
checked={disableAutoUpdates}
|
||||
/>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
export default SettingDisableAutoUpdates;
|
||||
@@ -10,13 +10,7 @@ import {
|
||||
} from 'redux/actions/app';
|
||||
import { doSetDaemonSetting, doClearDaemonSetting, doFindFFmpeg } from 'redux/actions/settings';
|
||||
import { selectAllowAnalytics } from 'redux/selectors/app';
|
||||
import {
|
||||
selectDaemonSettings,
|
||||
selectDaemonStatus,
|
||||
selectFfmpegStatus,
|
||||
selectFindingFFmpeg,
|
||||
selectLanguage,
|
||||
} from 'redux/selectors/settings';
|
||||
import { selectDaemonSettings, selectFfmpegStatus, selectFindingFFmpeg } from 'redux/selectors/settings';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
|
||||
import SettingSystem from './view';
|
||||
@@ -28,8 +22,6 @@ const select = (state) => ({
|
||||
walletEncrypted: selectWalletIsEncrypted(state),
|
||||
isAuthenticated: selectUserVerifiedEmail(state),
|
||||
allowAnalytics: selectAllowAnalytics(state),
|
||||
language: selectLanguage(state),
|
||||
daemonStatus: selectDaemonStatus(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -10,17 +10,17 @@ import I18nMessage from 'component/i18nMessage';
|
||||
import SettingAutoLaunch from 'component/settingAutoLaunch';
|
||||
import SettingClosingBehavior from 'component/settingClosingBehavior';
|
||||
import SettingCommentsServer from 'component/settingCommentsServer';
|
||||
import SettingDataHosting from 'component/settingDataHosting';
|
||||
import SettingShareUrl from 'component/settingShareUrl';
|
||||
import SettingsRow from 'component/settingsRow';
|
||||
import SettingWalletServer from 'component/settingWalletServer';
|
||||
import Spinner from 'component/spinner';
|
||||
import { getPasswordFromCookie } from 'util/saved-passwords';
|
||||
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
||||
import { formatBytes } from 'util/format-bytes';
|
||||
import SettingEnablePrereleases from 'component/settingEnablePrereleases';
|
||||
import SettingDisableAutoUpdates from 'component/settingDisableAutoUpdates';
|
||||
|
||||
const IS_MAC = process.platform === 'darwin';
|
||||
const BYTES_PER_MB = 1048576;
|
||||
|
||||
type Price = {
|
||||
currency: string,
|
||||
@@ -39,16 +39,6 @@ type DaemonSettings = {
|
||||
ffmpeg_path: string,
|
||||
};
|
||||
|
||||
type DaemonStatus = {
|
||||
disk_space: {
|
||||
content_blobs_storage_used_mb: string,
|
||||
published_blobs_storage_used_mb: string,
|
||||
running: true,
|
||||
seed_blobs_storage_used_mb: string,
|
||||
total_used_mb: string,
|
||||
},
|
||||
};
|
||||
|
||||
type Props = {
|
||||
// --- select ---
|
||||
daemonSettings: DaemonSettings,
|
||||
@@ -67,7 +57,6 @@ type Props = {
|
||||
updateWalletStatus: () => void,
|
||||
confirmForgetPassword: ({}) => void,
|
||||
toggle3PAnalytics: (boolean) => void,
|
||||
daemonStatus: DaemonStatus,
|
||||
};
|
||||
|
||||
export default function SettingSystem(props: Props) {
|
||||
@@ -87,23 +76,10 @@ export default function SettingSystem(props: Props) {
|
||||
updateWalletStatus,
|
||||
confirmForgetPassword,
|
||||
toggle3PAnalytics,
|
||||
daemonStatus,
|
||||
} = props;
|
||||
|
||||
const [clearingCache, setClearingCache] = React.useState(false);
|
||||
const [storedPassword, setStoredPassword] = React.useState(false);
|
||||
const { disk_space } = daemonStatus;
|
||||
const contentSpaceUsed = Number(disk_space.content_blobs_storage_used_mb);
|
||||
const networkSpaceUsed = Number(disk_space.seed_blobs_storage_used_mb);
|
||||
const blobLimitSetting = daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB];
|
||||
const networkLimitSetting = daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB];
|
||||
const [contentBlobSpaceLimitGB, setContentBlobSpaceLimit] = React.useState(
|
||||
blobLimitSetting ? blobLimitSetting / 1024 : 0
|
||||
);
|
||||
const [networkBlobSpaceLimitGB, setNetworkBlobSpaceLimit] = React.useState(
|
||||
networkLimitSetting ? networkLimitSetting / 1024 : 0
|
||||
);
|
||||
const [limitSpace, setLimitSpace] = React.useState(Boolean(blobLimitSetting));
|
||||
const { available: ffmpegAvailable, which: ffmpegPath } = ffmpegStatus;
|
||||
|
||||
function onChangeEncryptWallet() {
|
||||
@@ -118,46 +94,6 @@ export default function SettingSystem(props: Props) {
|
||||
confirmForgetPassword({ callback: () => setStoredPassword(false) });
|
||||
}
|
||||
|
||||
function updateContentBlobLimitField(gb) {
|
||||
if (gb === 0) {
|
||||
setContentBlobSpaceLimit(0);
|
||||
} else if (!gb || !isNaN(gb)) {
|
||||
setContentBlobSpaceLimit(gb);
|
||||
}
|
||||
}
|
||||
|
||||
function updateNetworkBlobLimitField(gb) {
|
||||
if (gb === 0) {
|
||||
setNetworkBlobSpaceLimit(0);
|
||||
} else if (!gb || !isNaN(gb)) {
|
||||
setNetworkBlobSpaceLimit(gb);
|
||||
}
|
||||
}
|
||||
|
||||
function handleLimitSpace(value) {
|
||||
setLimitSpace(value);
|
||||
if (!value) {
|
||||
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(0));
|
||||
} else {
|
||||
const spaceLimitMB = contentBlobSpaceLimitGB * 1024;
|
||||
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(spaceLimitMB));
|
||||
}
|
||||
}
|
||||
|
||||
function handleSetContentBlobSpaceLimit() {
|
||||
const spaceLimitMB = contentBlobSpaceLimitGB * 1024;
|
||||
if (!isNaN(spaceLimitMB) && blobLimitSetting !== spaceLimitMB * 1024) {
|
||||
setDaemonSetting(DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB, String(spaceLimitMB));
|
||||
}
|
||||
}
|
||||
|
||||
function handleSetNetworkBlobSpaceLimit() {
|
||||
const spaceLimitMB = networkBlobSpaceLimitGB * 1024;
|
||||
if (!isNaN(spaceLimitMB) && blobLimitSetting !== spaceLimitMB * 1024) {
|
||||
setDaemonSetting(DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB, String(spaceLimitMB));
|
||||
}
|
||||
}
|
||||
|
||||
// Update ffmpeg variables
|
||||
React.useEffect(() => {
|
||||
const { available } = ffmpegStatus;
|
||||
@@ -221,95 +157,17 @@ export default function SettingSystem(props: Props) {
|
||||
subtitle={
|
||||
<React.Fragment>
|
||||
{__('Help improve the P2P data network (and make LBRY happy) by hosting data.')}{' '}
|
||||
{__("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.'
|
||||
)}{' '}
|
||||
{__("View History Hosting lets you choose how much storage to use helping content you've consumed.")}{' '}
|
||||
{/* {__( */}
|
||||
{/* 'Automatic Hosting lets you delegate some amount of storage for the network to automatically download and host.' */}
|
||||
{/* )}{' '} */}
|
||||
{__('Playing videos may exceed your history hosting limit until cleanup runs every 30 minutes.')}
|
||||
<br />
|
||||
<Button button="link" label={__('Learn more')} href="https://lbry.com/faq/host-content" />
|
||||
</React.Fragment>
|
||||
}
|
||||
>
|
||||
<fieldset-section>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="save_blobs"
|
||||
onChange={() => setDaemonSetting('save_blobs', !daemonSettings.save_blobs)}
|
||||
checked={daemonSettings.save_blobs}
|
||||
label={__('Enable Data Hosting')}
|
||||
/>
|
||||
</fieldset-section>
|
||||
{daemonSettings.save_blobs && (
|
||||
<fieldset-section>
|
||||
<div className={'settings__row-section-title'}>{__('History Hosting')}</div>
|
||||
<p className={'help'}>
|
||||
{`History Hosting using ${formatBytes(contentSpaceUsed * BYTES_PER_MB)} of ${
|
||||
daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB]
|
||||
? formatBytes(daemonSettings[DAEMON_SETTINGS.BLOB_STORAGE_LIMIT_MB] * BYTES_PER_MB)
|
||||
: 'Unlimited'
|
||||
}`}
|
||||
</p>
|
||||
</fieldset-section>
|
||||
)}
|
||||
{daemonSettings.save_blobs && (
|
||||
<fieldset-section>
|
||||
<FormField
|
||||
type="checkbox"
|
||||
name="limit_space_used"
|
||||
onChange={() => handleLimitSpace(!limitSpace)}
|
||||
checked={limitSpace}
|
||||
label={__('Limit Hosting of Content History')}
|
||||
/>
|
||||
</fieldset-section>
|
||||
)}
|
||||
|
||||
{daemonSettings.save_blobs && limitSpace && (
|
||||
<FormField
|
||||
name="content_blob_limit_gb"
|
||||
type="text"
|
||||
label={__(`Limit (GB)`)}
|
||||
disabled={!daemonSettings.save_blobs}
|
||||
onChange={(e) => updateContentBlobLimitField(e.target.value)}
|
||||
value={contentBlobSpaceLimitGB}
|
||||
inputButton={
|
||||
<Button
|
||||
disabled={isNaN(contentBlobSpaceLimitGB)}
|
||||
button="primary"
|
||||
label={__('Apply')}
|
||||
onClick={handleSetContentBlobSpaceLimit}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{daemonSettings.save_blobs && (
|
||||
<fieldset-section>
|
||||
<div className={'settings__row-section-title'}>{__('Automatic Hosting')}</div>
|
||||
<p className={'help'}>
|
||||
{`Automatic Hosting using ${formatBytes(networkSpaceUsed * BYTES_PER_MB)} of ${formatBytes(
|
||||
daemonSettings[DAEMON_SETTINGS.NETWORK_STORAGE_LIMIT_MB] * BYTES_PER_MB
|
||||
)}`}
|
||||
</p>
|
||||
</fieldset-section>
|
||||
)}
|
||||
{daemonSettings.save_blobs && (
|
||||
<FormField
|
||||
name="network_blob_limit_gb"
|
||||
type="text"
|
||||
label={__(`Allow (GB)`)}
|
||||
disabled={!daemonSettings.save_blobs}
|
||||
onChange={(e) => updateNetworkBlobLimitField(e.target.value)}
|
||||
value={networkBlobSpaceLimitGB}
|
||||
inputButton={
|
||||
<Button
|
||||
disabled={isNaN(networkBlobSpaceLimitGB)}
|
||||
button="primary"
|
||||
label={__('Apply')}
|
||||
onClick={handleSetNetworkBlobSpaceLimit}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<SettingDataHosting />
|
||||
</SettingsRow>
|
||||
<SettingsRow
|
||||
title={__('Share usage and diagnostic data')}
|
||||
@@ -365,6 +223,14 @@ export default function SettingSystem(props: Props) {
|
||||
>
|
||||
<SettingEnablePrereleases />
|
||||
</SettingsRow>
|
||||
<SettingsRow
|
||||
title={__('Disable automatic updates')}
|
||||
subtitle={__(
|
||||
"Preven't new updates to be downloaded automatically in the background (we will keep notifying you if there is an update)"
|
||||
)}
|
||||
>
|
||||
<SettingDisableAutoUpdates />
|
||||
</SettingsRow>
|
||||
<SettingsRow
|
||||
title={
|
||||
<span>
|
||||
@@ -504,7 +370,22 @@ export default function SettingSystem(props: Props) {
|
||||
</fieldset-section>
|
||||
</SettingsRow>
|
||||
|
||||
<SettingsRow title={__('Wallet server')} multirow>
|
||||
<SettingsRow
|
||||
title={__('Wallet server')}
|
||||
subtitle={
|
||||
<I18nMessage
|
||||
tokens={{
|
||||
learn_more: (
|
||||
<Button button="link" href="http://lbry.com/faq/wallet-servers" label={__('Learn More')} />
|
||||
),
|
||||
}}
|
||||
>
|
||||
Wallet servers are used to relay data to and from the LBRY blockchain. They also determine what
|
||||
content shows in trending or is blocked. %learn_more%
|
||||
</I18nMessage>
|
||||
}
|
||||
multirow
|
||||
>
|
||||
<SettingWalletServer />
|
||||
</SettingsRow>
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { connect } from 'react-redux';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { selectLanguage, makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
|
||||
import SettingUnauthenticated from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state),
|
||||
language: selectLanguage(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { FormField } from 'component/common/form';
|
||||
import Button from 'component/button';
|
||||
import I18nMessage from 'component/i18nMessage';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import ServerInputRow from './internal/inputRow';
|
||||
import { stringifyServerParam } from 'util/sync-settings';
|
||||
@@ -133,16 +132,6 @@ function SettingWalletServer(props: Props) {
|
||||
}}
|
||||
label={__('Use custom wallet servers')}
|
||||
/>
|
||||
<p className="help">
|
||||
<I18nMessage
|
||||
tokens={{
|
||||
learn_more: <Button button="link" href="http://lbry.com/faq/wallet-servers" label={__('Learn More')} />,
|
||||
}}
|
||||
>
|
||||
Wallet servers are used to relay data to and from the LBRY blockchain. They also determine what content
|
||||
shows in trending or is blocked. %learn_more%
|
||||
</I18nMessage>
|
||||
</p>
|
||||
|
||||
{advancedMode && (
|
||||
<div>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
||||
import { doClearPurchasedUriSuccess } from 'redux/actions/file';
|
||||
import { selectFollowedTags } from 'redux/selectors/tags';
|
||||
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
|
||||
import { selectHomepageData, selectLanguage } from 'redux/selectors/settings';
|
||||
import { selectHomepageData } from 'redux/selectors/settings';
|
||||
import { doSignOut } from 'redux/actions/app';
|
||||
import { selectUnseenNotificationCount } from 'redux/selectors/notifications';
|
||||
import { selectPurchaseUriSuccess } from 'redux/selectors/claims';
|
||||
@@ -13,7 +13,6 @@ import SideNavigation from './view';
|
||||
const select = (state) => ({
|
||||
subscriptions: selectSubscriptions(state),
|
||||
followedTags: selectFollowedTags(state),
|
||||
language: selectLanguage(state), // trigger redraw on language change
|
||||
email: selectUserVerifiedEmail(state),
|
||||
purchaseSuccess: selectPurchaseUriSuccess(state),
|
||||
unseenCount: selectUnseenNotificationCount(state),
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
selectHashChanged,
|
||||
} from 'redux/selectors/sync';
|
||||
import { doCheckSync, doGetSync } from 'redux/actions/sync';
|
||||
import { makeSelectClientSetting, selectLanguage } from 'redux/selectors/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { doSetWalletSyncPreference } from 'redux/actions/settings';
|
||||
import SyncToggle from './view';
|
||||
import { doGetAndPopulatePreferences } from 'redux/actions/app';
|
||||
@@ -20,7 +20,6 @@ const select = (state) => ({
|
||||
verifiedEmail: selectUserVerifiedEmail(state),
|
||||
getSyncError: selectGetSyncErrorMessage(state),
|
||||
getSyncPending: selectGetSyncIsPending(state),
|
||||
language: selectLanguage(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as SETTINGS from 'constants/settings';
|
||||
import { connect } from 'react-redux';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import { selectGetSyncErrorMessage } from 'redux/selectors/sync';
|
||||
import { makeSelectClientSetting, selectLanguage } from 'redux/selectors/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { doSetWalletSyncPreference } from 'redux/actions/settings';
|
||||
import { doOpenModal } from 'redux/actions/app';
|
||||
import SyncToggle from './view';
|
||||
@@ -11,7 +11,6 @@ const select = (state) => ({
|
||||
syncEnabled: makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state),
|
||||
verifiedEmail: selectUserVerifiedEmail(state),
|
||||
getSyncError: selectGetSyncErrorMessage(state),
|
||||
language: selectLanguage(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// ****************************************************************************
|
||||
// LbryVolumeBarClass
|
||||
// ****************************************************************************
|
||||
|
||||
import videojs from 'video.js';
|
||||
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
|
||||
const VIDEOJS_CONTROL_BAR_CLASS = 'ControlBar';
|
||||
const VIDEOJS_VOLUME_PANEL_CLASS = 'VolumePanel';
|
||||
const VIDEOJS_VOLUME_CONTROL_CLASS = 'VolumeControl';
|
||||
const VIDEOJS_VOLUME_BAR_CLASS = 'VolumeBar';
|
||||
|
||||
class LbryVolumeBarClass extends videojs.getComponent(VIDEOJS_VOLUME_BAR_CLASS) {
|
||||
constructor(player, options = {}) {
|
||||
super(player, options);
|
||||
}
|
||||
|
||||
static replaceExisting(player) {
|
||||
try {
|
||||
const volumeControl = player
|
||||
.getChild(VIDEOJS_CONTROL_BAR_CLASS)
|
||||
.getChild(VIDEOJS_VOLUME_PANEL_CLASS)
|
||||
.getChild(VIDEOJS_VOLUME_CONTROL_CLASS);
|
||||
const volumeBar = volumeControl.getChild(VIDEOJS_VOLUME_BAR_CLASS);
|
||||
volumeControl.removeChild(volumeBar);
|
||||
volumeControl.addChild(new LbryVolumeBarClass(player));
|
||||
} catch (error) {
|
||||
// In case it slips in 'Production', the original volume bar will be used and the site should still be working
|
||||
// (just not exactly the way we want).
|
||||
if (isDev) throw Error('\n\nvideojs.jsx: Volume Panel hierarchy changed?\n\n' + error);
|
||||
}
|
||||
}
|
||||
|
||||
handleMouseDown(event) {
|
||||
super.handleMouseDown(event);
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
handleMouseMove(event) {
|
||||
super.handleMouseMove(event);
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
export default LbryVolumeBarClass;
|
||||
@@ -0,0 +1,236 @@
|
||||
// @flow
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
|
||||
const TAP = {
|
||||
NONE: 'NONE',
|
||||
UNMUTE: 'UNMUTE',
|
||||
RETRY: 'RETRY',
|
||||
};
|
||||
|
||||
const setLabel = (controlBar, childName, label) => {
|
||||
const c = controlBar.getChild(childName);
|
||||
if (c) {
|
||||
c.controlText(label);
|
||||
}
|
||||
};
|
||||
|
||||
// $FlowFixMe
|
||||
const VideoJsEvents = ({
|
||||
tapToUnmuteRef,
|
||||
tapToRetryRef,
|
||||
setReload,
|
||||
videoTheaterMode,
|
||||
playerRef,
|
||||
autoplaySetting,
|
||||
replay,
|
||||
}: {
|
||||
tapToUnmuteRef: any, // DOM element
|
||||
tapToRetryRef: any, // DOM element
|
||||
setReload: any, // react hook
|
||||
videoTheaterMode: any, // dispatch function
|
||||
playerRef: any, // DOM element
|
||||
autoplaySetting: boolean,
|
||||
replay: boolean,
|
||||
}) => {
|
||||
// Override the player's control text. We override to:
|
||||
// 1. Add keyboard shortcut to the tool-tip.
|
||||
// 2. Override videojs' i18n and use our own (don't want to have 2 systems).
|
||||
//
|
||||
// Notes:
|
||||
// - For dynamic controls (e.g. play/pause), those unfortunately need to be
|
||||
// updated again at their event-listener level (that's just the way videojs
|
||||
// updates the text), hence the need to listen to 'play', 'pause' and 'volumechange'
|
||||
// on top of just 'loadstart'.
|
||||
// - videojs changes the MuteToggle text at 'loadstart', so this was chosen
|
||||
// as the listener to update static texts.
|
||||
|
||||
function resolveCtrlText(e) {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const ctrlBar = player.getChild('controlBar');
|
||||
switch (e.type) {
|
||||
case 'play':
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Pause (space)'));
|
||||
break;
|
||||
case 'pause':
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Play (space)'));
|
||||
break;
|
||||
case 'volumechange':
|
||||
ctrlBar
|
||||
.getChild('VolumePanel')
|
||||
.getChild('MuteToggle')
|
||||
.controlText(player.muted() || player.volume() === 0 ? __('Unmute (m)') : __('Mute (m)'));
|
||||
break;
|
||||
case 'fullscreenchange':
|
||||
setLabel(
|
||||
ctrlBar,
|
||||
'FullscreenToggle',
|
||||
player.isFullscreen() ? __('Exit Fullscreen (f)') : __('Fullscreen (f)')
|
||||
);
|
||||
break;
|
||||
case 'loadstart':
|
||||
// --- Do everything ---
|
||||
setLabel(ctrlBar, 'PlaybackRateMenuButton', __('Playback Rate (<, >)'));
|
||||
setLabel(ctrlBar, 'QualityButton', __('Quality'));
|
||||
setLabel(ctrlBar, 'PlayNextButton', __('Play Next (SHIFT+N)'));
|
||||
setLabel(ctrlBar, 'PlayPreviousButton', __('Play Previous (SHIFT+P)'));
|
||||
setLabel(ctrlBar, 'TheaterModeButton', videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||
setLabel(ctrlBar, 'AutoplayNextButton', autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off'));
|
||||
|
||||
resolveCtrlText({ type: 'play' });
|
||||
resolveCtrlText({ type: 'pause' });
|
||||
resolveCtrlText({ type: 'volumechange' });
|
||||
resolveCtrlText({ type: 'fullscreenchange' });
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw Error('Unexpected: ' + e.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onInitialPlay() {
|
||||
const player = playerRef.current;
|
||||
if (player && (player.muted() || player.volume() === 0)) {
|
||||
// The css starts as "hidden". We make it visible here without
|
||||
// re-rendering the whole thing.
|
||||
showTapButton(TAP.UNMUTE);
|
||||
} else {
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function onVolumeChange() {
|
||||
const player = playerRef.current;
|
||||
if (player && !player.muted()) {
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function onError() {
|
||||
const player = playerRef.current;
|
||||
showTapButton(TAP.RETRY);
|
||||
|
||||
// reattach initial play listener in case we recover from error successfully
|
||||
// $FlowFixMe
|
||||
player.one('play', onInitialPlay);
|
||||
|
||||
if (player && player.loadingSpinner) {
|
||||
player.loadingSpinner.hide();
|
||||
}
|
||||
}
|
||||
|
||||
// const onEnded = React.useCallback(() => {
|
||||
// if (!adUrl) {
|
||||
// showTapButton(TAP.NONE);
|
||||
// }
|
||||
// }, [adUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const controlBar = player.getChild('controlBar');
|
||||
controlBar
|
||||
.getChild('TheaterModeButton')
|
||||
.controlText(videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||
}
|
||||
}, [videoTheaterMode]);
|
||||
|
||||
// when user clicks 'Unmute' button, turn audio on and hide unmute button
|
||||
function unmuteAndHideHint() {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
player.muted(false);
|
||||
if (player.volume() === 0) {
|
||||
player.volume(1.0);
|
||||
}
|
||||
}
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
|
||||
function retryVideoAfterFailure() {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
setReload(Date.now());
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function showTapButton(tapButton) {
|
||||
const setButtonVisibility = (theRef, newState) => {
|
||||
// Use the DOM to control the state of the button to prevent re-renders.
|
||||
if (theRef.current) {
|
||||
const curState = theRef.current.style.visibility === 'visible';
|
||||
if (newState !== curState) {
|
||||
theRef.current.style.visibility = newState ? 'visible' : 'hidden';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
switch (tapButton) {
|
||||
case TAP.NONE:
|
||||
setButtonVisibility(tapToUnmuteRef, false);
|
||||
setButtonVisibility(tapToRetryRef, false);
|
||||
break;
|
||||
case TAP.UNMUTE:
|
||||
setButtonVisibility(tapToUnmuteRef, true);
|
||||
setButtonVisibility(tapToRetryRef, false);
|
||||
break;
|
||||
case TAP.RETRY:
|
||||
setButtonVisibility(tapToUnmuteRef, false);
|
||||
setButtonVisibility(tapToRetryRef, true);
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw new Error('showTapButton: unexpected ref');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const touchOverlay = player.getChild('TouchOverlay');
|
||||
const controlBar = player.getChild('controlBar') || touchOverlay.getChild('controlBar');
|
||||
const autoplayButton = controlBar.getChild('AutoplayNextButton');
|
||||
|
||||
if (autoplayButton) {
|
||||
const title = autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off');
|
||||
|
||||
autoplayButton.controlText(title);
|
||||
autoplayButton.setAttribute('aria-label', title);
|
||||
autoplayButton.setAttribute('aria-checked', autoplaySetting);
|
||||
}
|
||||
}
|
||||
}, [autoplaySetting]);
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (replay && player) {
|
||||
player.play();
|
||||
}
|
||||
}, [replay]);
|
||||
|
||||
function initializeEvents() {
|
||||
const player = playerRef.current;
|
||||
// Add various event listeners to player
|
||||
player.one('play', onInitialPlay);
|
||||
player.on('play', resolveCtrlText);
|
||||
player.on('pause', resolveCtrlText);
|
||||
player.on('loadstart', resolveCtrlText);
|
||||
player.on('fullscreenchange', resolveCtrlText);
|
||||
player.on('volumechange', resolveCtrlText);
|
||||
player.on('volumechange', onVolumeChange);
|
||||
player.on('error', onError);
|
||||
// player.on('ended', onEnded);
|
||||
}
|
||||
|
||||
return {
|
||||
retryVideoAfterFailure,
|
||||
unmuteAndHideHint,
|
||||
initializeEvents,
|
||||
};
|
||||
};
|
||||
|
||||
export default VideoJsEvents;
|
||||
@@ -0,0 +1,69 @@
|
||||
// @flow
|
||||
const VideoJsFunctions = ({
|
||||
source,
|
||||
sourceType,
|
||||
videoJsOptions,
|
||||
isAudio,
|
||||
}: {
|
||||
source: string,
|
||||
sourceType: string,
|
||||
videoJsOptions: Object,
|
||||
isAudio: boolean,
|
||||
}) => {
|
||||
function detectFileType() {
|
||||
// $FlowFixMe
|
||||
return new Promise(async (res, rej) => {
|
||||
try {
|
||||
const response = await fetch(source, { method: 'HEAD', cache: 'no-store' });
|
||||
|
||||
// Temp variables to hold results
|
||||
let finalType = sourceType;
|
||||
let finalSource = source;
|
||||
|
||||
// override type if we receive an .m3u8 (transcoded mp4)
|
||||
// do we need to check if explicitly redirected
|
||||
// or is checking extension only a safer method
|
||||
if (response && response.redirected && response.url && response.url.endsWith('m3u8')) {
|
||||
finalType = 'application/x-mpegURL';
|
||||
finalSource = response.url;
|
||||
}
|
||||
|
||||
// Modify video source in options
|
||||
videoJsOptions.sources = [
|
||||
{
|
||||
src: finalSource,
|
||||
type: finalType,
|
||||
},
|
||||
];
|
||||
|
||||
return res(videoJsOptions);
|
||||
} catch (error) {
|
||||
return rej(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: can remove this function as well
|
||||
// Create the video DOM element and wrapper
|
||||
function createVideoPlayerDOM(container: any) {
|
||||
if (!container) return;
|
||||
|
||||
// This seems like a poor way to generate the DOM for video.js
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.setAttribute('data-vjs-player', 'true');
|
||||
const el = document.createElement(isAudio ? 'audio' : 'video');
|
||||
el.className = 'video-js vjs-big-play-centered ';
|
||||
wrapper.appendChild(el);
|
||||
|
||||
container.appendChild(wrapper);
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
return {
|
||||
detectFileType,
|
||||
createVideoPlayerDOM,
|
||||
};
|
||||
};
|
||||
|
||||
export default VideoJsFunctions;
|
||||
@@ -0,0 +1,157 @@
|
||||
// @flow
|
||||
import * as OVERLAY from './overlays';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import isUserTyping from 'util/detect-typing';
|
||||
|
||||
const SEEK_STEP_5 = 5;
|
||||
const SEEK_STEP = 10; // time to seek in seconds
|
||||
|
||||
const videoPlaybackRates = [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 1.75, 2];
|
||||
|
||||
// check if active (clicked) element is part of video div, used for keyboard shortcuts (volume etc)
|
||||
function activeElementIsPartOfVideoElement() {
|
||||
const videoElementParent = document.getElementsByClassName('video-js-parent')[0];
|
||||
const activeElement = document.activeElement;
|
||||
return videoElementParent.contains(activeElement);
|
||||
}
|
||||
|
||||
function volumeUp(event, playerRef) {
|
||||
// dont run if video element is not active element (otherwise runs when scrolling using keypad)
|
||||
const videoElementIsActive = activeElementIsPartOfVideoElement();
|
||||
const player = playerRef.current;
|
||||
if (!player || !videoElementIsActive) return;
|
||||
event.preventDefault();
|
||||
player.volume(player.volume() + 0.05);
|
||||
OVERLAY.showVolumeverlay(player, Math.round(player.volume() * 100));
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function volumeDown(event, playerRef) {
|
||||
// dont run if video element is not active element (otherwise runs when scrolling using keypad)
|
||||
const videoElementIsActive = activeElementIsPartOfVideoElement();
|
||||
const player = playerRef.current;
|
||||
if (!player || !videoElementIsActive) return;
|
||||
event.preventDefault();
|
||||
player.volume(player.volume() - 0.05);
|
||||
OVERLAY.showVolumeverlay(player, Math.round(player.volume() * 100));
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function seekVideo(stepSize: number, playerRef, containerRef) {
|
||||
const player = playerRef.current;
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode || !player) return;
|
||||
const duration = videoNode.duration;
|
||||
const currentTime = videoNode.currentTime;
|
||||
const newDuration = currentTime + stepSize;
|
||||
if (newDuration < 0) {
|
||||
videoNode.currentTime = 0;
|
||||
} else if (newDuration > duration) {
|
||||
videoNode.currentTime = duration;
|
||||
} else {
|
||||
videoNode.currentTime = newDuration;
|
||||
}
|
||||
OVERLAY.showSeekedOverlay(player, Math.abs(stepSize), stepSize > 0);
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function toggleFullscreen(playerRef) {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
if (!player.isFullscreen()) {
|
||||
player.requestFullscreen();
|
||||
} else {
|
||||
player.exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMute(containerRef) {
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode) return;
|
||||
videoNode.muted = !videoNode.muted;
|
||||
}
|
||||
|
||||
function togglePlay(containerRef) {
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode) return;
|
||||
videoNode.paused ? videoNode.play() : videoNode.pause();
|
||||
}
|
||||
|
||||
function changePlaybackSpeed(shouldSpeedUp: boolean, playerRef) {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
const isSpeedUp = shouldSpeedUp;
|
||||
const rate = player.playbackRate();
|
||||
let rateIndex = videoPlaybackRates.findIndex((x) => x === rate);
|
||||
if (rateIndex >= 0) {
|
||||
rateIndex = isSpeedUp ? Math.min(rateIndex + 1, videoPlaybackRates.length - 1) : Math.max(rateIndex - 1, 0);
|
||||
const nextRate = videoPlaybackRates[rateIndex];
|
||||
|
||||
OVERLAY.showPlaybackRateOverlay(player, nextRate, isSpeedUp);
|
||||
player.userActive(true);
|
||||
player.playbackRate(nextRate);
|
||||
}
|
||||
}
|
||||
|
||||
const VideoJsKeyboardShorcuts = ({
|
||||
playNext,
|
||||
playPrevious,
|
||||
toggleVideoTheaterMode,
|
||||
}: {
|
||||
playNext: any, // function
|
||||
playPrevious: any, // function
|
||||
toggleVideoTheaterMode: any, // function
|
||||
}) => {
|
||||
function toggleTheaterMode(playerRef) {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
// TODO: have to fix this
|
||||
toggleVideoTheaterMode();
|
||||
if (player.isFullscreen()) {
|
||||
player.exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeyDown(e: KeyboardEvent, playerRef, containerRef) {
|
||||
const player = playerRef.current;
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode || !player || isUserTyping()) return;
|
||||
handleSingleKeyActions(e, playerRef, containerRef);
|
||||
handleShiftKeyActions(e, playerRef);
|
||||
}
|
||||
|
||||
function handleShiftKeyActions(e: KeyboardEvent, playerRef) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || !e.shiftKey) return;
|
||||
if (e.keyCode === KEYCODES.PERIOD) changePlaybackSpeed(true, playerRef);
|
||||
if (e.keyCode === KEYCODES.COMMA) changePlaybackSpeed(false, playerRef);
|
||||
if (e.keyCode === KEYCODES.N) playNext();
|
||||
if (e.keyCode === KEYCODES.P) playPrevious();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line flowtype/no-types-missing-file-annotation
|
||||
function handleSingleKeyActions(e: KeyboardEvent, playerRef, containerRef) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
||||
if (e.keyCode === KEYCODES.SPACEBAR || e.keyCode === KEYCODES.K) togglePlay(containerRef);
|
||||
if (e.keyCode === KEYCODES.F) toggleFullscreen(playerRef);
|
||||
if (e.keyCode === KEYCODES.M) toggleMute(containerRef);
|
||||
if (e.keyCode === KEYCODES.UP) volumeUp(e, playerRef);
|
||||
if (e.keyCode === KEYCODES.DOWN) volumeDown(e, playerRef);
|
||||
if (e.keyCode === KEYCODES.T) toggleTheaterMode(playerRef);
|
||||
if (e.keyCode === KEYCODES.L) seekVideo(SEEK_STEP, playerRef, containerRef);
|
||||
if (e.keyCode === KEYCODES.J) seekVideo(-SEEK_STEP, playerRef, containerRef);
|
||||
if (e.keyCode === KEYCODES.RIGHT) seekVideo(SEEK_STEP_5, playerRef, containerRef);
|
||||
if (e.keyCode === KEYCODES.LEFT) seekVideo(-SEEK_STEP_5, playerRef, containerRef);
|
||||
}
|
||||
|
||||
var curried_function = function (playerRef: any, containerRef: any) {
|
||||
return function curried_func(e: any) {
|
||||
handleKeyDown(e, playerRef, containerRef);
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
curried_function,
|
||||
};
|
||||
};
|
||||
|
||||
export default VideoJsKeyboardShorcuts;
|
||||
@@ -2,7 +2,6 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import Button from 'component/button';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import * as KEYCODES from 'constants/keycodes';
|
||||
import classnames from 'classnames';
|
||||
import videojs from 'video.js';
|
||||
import 'video.js/dist/alt/video-js-cdn.min.css';
|
||||
@@ -12,9 +11,10 @@ import './plugins/videojs-mobile-ui/plugin';
|
||||
import hlsQualitySelector from './plugins/videojs-hls-quality-selector/plugin';
|
||||
import recsys from './plugins/videojs-recsys/plugin';
|
||||
import qualityLevels from 'videojs-contrib-quality-levels';
|
||||
import isUserTyping from 'util/detect-typing';
|
||||
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
import LbryVolumeBarClass from './lbry-volume-bar';
|
||||
import keyboardShorcuts from './videojs-keyboard-shortcuts';
|
||||
import events from './videojs-events';
|
||||
import functions from './videojs-functions';
|
||||
|
||||
export type Player = {
|
||||
on: (string, (any) => void) => void,
|
||||
@@ -61,15 +61,6 @@ type Props = {
|
||||
playPrevious: () => void,
|
||||
};
|
||||
|
||||
// type VideoJSOptions = {
|
||||
// controls: boolean,
|
||||
// preload: string,
|
||||
// playbackRates: Array<number>,
|
||||
// responsive: boolean,
|
||||
// poster?: string,
|
||||
// muted?: boolean,
|
||||
// };
|
||||
|
||||
const videoPlaybackRates = [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 1.75, 2];
|
||||
|
||||
const IS_IOS =
|
||||
@@ -89,9 +80,6 @@ const VIDEO_JS_OPTIONS = {
|
||||
},
|
||||
};
|
||||
|
||||
const SEEK_STEP_5 = 5;
|
||||
const SEEK_STEP = 10; // time to seek in seconds
|
||||
|
||||
if (!Object.keys(videojs.getPlugins()).includes('eventTracking')) {
|
||||
videojs.registerPlugin('eventTracking', eventTracking);
|
||||
}
|
||||
@@ -108,47 +96,6 @@ if (!Object.keys(videojs.getPlugins()).includes('recsys')) {
|
||||
videojs.registerPlugin('recsys', recsys);
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// LbryVolumeBarClass
|
||||
// ****************************************************************************
|
||||
|
||||
const VIDEOJS_CONTROL_BAR_CLASS = 'ControlBar';
|
||||
const VIDEOJS_VOLUME_PANEL_CLASS = 'VolumePanel';
|
||||
const VIDEOJS_VOLUME_CONTROL_CLASS = 'VolumeControl';
|
||||
const VIDEOJS_VOLUME_BAR_CLASS = 'VolumeBar';
|
||||
|
||||
class LbryVolumeBarClass extends videojs.getComponent(VIDEOJS_VOLUME_BAR_CLASS) {
|
||||
constructor(player, options = {}) {
|
||||
super(player, options);
|
||||
}
|
||||
|
||||
static replaceExisting(player) {
|
||||
try {
|
||||
const volumeControl = player
|
||||
.getChild(VIDEOJS_CONTROL_BAR_CLASS)
|
||||
.getChild(VIDEOJS_VOLUME_PANEL_CLASS)
|
||||
.getChild(VIDEOJS_VOLUME_CONTROL_CLASS);
|
||||
const volumeBar = volumeControl.getChild(VIDEOJS_VOLUME_BAR_CLASS);
|
||||
volumeControl.removeChild(volumeBar);
|
||||
volumeControl.addChild(new LbryVolumeBarClass(player));
|
||||
} catch (error) {
|
||||
// In case it slips in 'Production', the original volume bar will be used and the site should still be working
|
||||
// (just not exactly the way we want).
|
||||
if (isDev) throw Error('\n\nvideojs.jsx: Volume Panel hierarchy changed?\n\n' + error);
|
||||
}
|
||||
}
|
||||
|
||||
handleMouseDown(event) {
|
||||
super.handleMouseDown(event);
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
handleMouseMove(event) {
|
||||
super.handleMouseMove(event);
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// VideoJs
|
||||
// ****************************************************************************
|
||||
@@ -175,9 +122,18 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
playPrevious,
|
||||
} = props;
|
||||
|
||||
const [reload, setReload] = useState('initial');
|
||||
// will later store the videojs player
|
||||
const playerRef = useRef();
|
||||
const containerRef = useRef();
|
||||
|
||||
const tapToUnmuteRef = useRef();
|
||||
const tapToRetryRef = useRef();
|
||||
|
||||
// initiate keyboard shortcuts
|
||||
const { curried_function } = keyboardShorcuts({ toggleVideoTheaterMode, playNext, playPrevious });
|
||||
|
||||
const [reload, setReload] = useState('initial');
|
||||
|
||||
const videoJsOptions = {
|
||||
...VIDEO_JS_OPTIONS,
|
||||
autoplay: autoplay,
|
||||
@@ -199,322 +155,17 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
},
|
||||
};
|
||||
|
||||
const tapToUnmuteRef = useRef();
|
||||
const tapToRetryRef = useRef();
|
||||
const { detectFileType, createVideoPlayerDOM } = functions({ source, sourceType, videoJsOptions, isAudio });
|
||||
|
||||
const TAP = {
|
||||
NONE: 'NONE',
|
||||
UNMUTE: 'UNMUTE',
|
||||
RETRY: 'RETRY',
|
||||
};
|
||||
|
||||
function showTapButton(tapButton) {
|
||||
const setButtonVisibility = (theRef, newState) => {
|
||||
// Use the DOM to control the state of the button to prevent re-renders.
|
||||
if (theRef.current) {
|
||||
const curState = theRef.current.style.visibility === 'visible';
|
||||
if (newState !== curState) {
|
||||
theRef.current.style.visibility = newState ? 'visible' : 'hidden';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
switch (tapButton) {
|
||||
case TAP.NONE:
|
||||
setButtonVisibility(tapToUnmuteRef, false);
|
||||
setButtonVisibility(tapToRetryRef, false);
|
||||
break;
|
||||
case TAP.UNMUTE:
|
||||
setButtonVisibility(tapToUnmuteRef, true);
|
||||
setButtonVisibility(tapToRetryRef, false);
|
||||
break;
|
||||
case TAP.RETRY:
|
||||
setButtonVisibility(tapToUnmuteRef, false);
|
||||
setButtonVisibility(tapToRetryRef, true);
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw new Error('showTapButton: unexpected ref');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function unmuteAndHideHint() {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
player.muted(false);
|
||||
if (player.volume() === 0) {
|
||||
player.volume(1.0);
|
||||
}
|
||||
}
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
|
||||
function retryVideoAfterFailure() {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
setReload(Date.now());
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function resolveCtrlText(e) {
|
||||
// Override the player's control text. We override to:
|
||||
// 1. Add keyboard shortcut to the tool-tip.
|
||||
// 2. Override videojs' i18n and use our own (don't want to have 2 systems).
|
||||
//
|
||||
// Notes:
|
||||
// - For dynamic controls (e.g. play/pause), those unfortunately need to be
|
||||
// updated again at their event-listener level (that's just the way videojs
|
||||
// updates the text), hence the need to listen to 'play', 'pause' and 'volumechange'
|
||||
// on top of just 'loadstart'.
|
||||
// - videojs changes the MuteToggle text at 'loadstart', so this was chosen
|
||||
// as the listener to update static texts.
|
||||
|
||||
const setLabel = (controlBar, childName, label) => {
|
||||
const c = controlBar.getChild(childName);
|
||||
if (c) {
|
||||
c.controlText(label);
|
||||
}
|
||||
};
|
||||
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const ctrlBar = player.getChild('controlBar');
|
||||
switch (e.type) {
|
||||
case 'play':
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Pause (space)'));
|
||||
break;
|
||||
case 'pause':
|
||||
setLabel(ctrlBar, 'PlayToggle', __('Play (space)'));
|
||||
break;
|
||||
case 'volumechange':
|
||||
ctrlBar
|
||||
.getChild('VolumePanel')
|
||||
.getChild('MuteToggle')
|
||||
.controlText(player.muted() || player.volume() === 0 ? __('Unmute (m)') : __('Mute (m)'));
|
||||
break;
|
||||
case 'fullscreenchange':
|
||||
setLabel(
|
||||
ctrlBar,
|
||||
'FullscreenToggle',
|
||||
player.isFullscreen() ? __('Exit Fullscreen (f)') : __('Fullscreen (f)')
|
||||
);
|
||||
break;
|
||||
case 'loadstart':
|
||||
// --- Do everything ---
|
||||
setLabel(ctrlBar, 'PlaybackRateMenuButton', __('Playback Rate (<, >)'));
|
||||
setLabel(ctrlBar, 'QualityButton', __('Quality'));
|
||||
setLabel(ctrlBar, 'PlayNextButton', __('Play Next (SHIFT+N)'));
|
||||
setLabel(ctrlBar, 'PlayPreviousButton', __('Play Previous (SHIFT+P)'));
|
||||
setLabel(ctrlBar, 'TheaterModeButton', videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||
setLabel(ctrlBar, 'AutoplayNextButton', autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off'));
|
||||
|
||||
resolveCtrlText({ type: 'play' });
|
||||
resolveCtrlText({ type: 'pause' });
|
||||
resolveCtrlText({ type: 'volumechange' });
|
||||
resolveCtrlText({ type: 'fullscreenchange' });
|
||||
break;
|
||||
default:
|
||||
if (isDev) throw Error('Unexpected: ' + e.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onInitialPlay() {
|
||||
const player = playerRef.current;
|
||||
if (player && (player.muted() || player.volume() === 0)) {
|
||||
// The css starts as "hidden". We make it visible here without
|
||||
// re-rendering the whole thing.
|
||||
showTapButton(TAP.UNMUTE);
|
||||
} else {
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function onVolumeChange() {
|
||||
const player = playerRef.current;
|
||||
if (player && !player.muted()) {
|
||||
showTapButton(TAP.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
function onError() {
|
||||
const player = playerRef.current;
|
||||
showTapButton(TAP.RETRY);
|
||||
|
||||
// reattach initial play listener in case we recover from error successfully
|
||||
// $FlowFixMe
|
||||
player.one('play', onInitialPlay);
|
||||
|
||||
if (player && player.loadingSpinner) {
|
||||
player.loadingSpinner.hide();
|
||||
}
|
||||
}
|
||||
|
||||
const onEnded = React.useCallback(() => {
|
||||
// not sure if this is necessary - used to be dependent on !adUrl
|
||||
showTapButton(TAP.NONE);
|
||||
}, []);
|
||||
|
||||
function handleKeyDown(e: KeyboardEvent) {
|
||||
const player = playerRef.current;
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode || !player || isUserTyping()) return;
|
||||
handleSingleKeyActions(e);
|
||||
handleShiftKeyActions(e);
|
||||
}
|
||||
|
||||
function handleShiftKeyActions(e: KeyboardEvent) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || !e.shiftKey) return;
|
||||
if (e.keyCode === KEYCODES.PERIOD) changePlaybackSpeed(true);
|
||||
if (e.keyCode === KEYCODES.COMMA) changePlaybackSpeed(false);
|
||||
if (e.keyCode === KEYCODES.N) playNext();
|
||||
if (e.keyCode === KEYCODES.P) playPrevious();
|
||||
}
|
||||
|
||||
function handleSingleKeyActions(e: KeyboardEvent) {
|
||||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
||||
if (e.keyCode === KEYCODES.SPACEBAR || e.keyCode === KEYCODES.K) togglePlay();
|
||||
if (e.keyCode === KEYCODES.F) toggleFullscreen();
|
||||
if (e.keyCode === KEYCODES.M) toggleMute();
|
||||
if (e.keyCode === KEYCODES.UP) volumeUp();
|
||||
if (e.keyCode === KEYCODES.DOWN) volumeDown();
|
||||
if (e.keyCode === KEYCODES.T) toggleTheaterMode();
|
||||
if (e.keyCode === KEYCODES.L) seekVideo(SEEK_STEP);
|
||||
if (e.keyCode === KEYCODES.J) seekVideo(-SEEK_STEP);
|
||||
if (e.keyCode === KEYCODES.RIGHT) seekVideo(SEEK_STEP_5);
|
||||
if (e.keyCode === KEYCODES.LEFT) seekVideo(-SEEK_STEP_5);
|
||||
}
|
||||
|
||||
function seekVideo(stepSize: number) {
|
||||
const player = playerRef.current;
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode || !player) return;
|
||||
const duration = videoNode.duration;
|
||||
const currentTime = videoNode.currentTime;
|
||||
const newDuration = currentTime + stepSize;
|
||||
if (newDuration < 0) {
|
||||
videoNode.currentTime = 0;
|
||||
} else if (newDuration > duration) {
|
||||
videoNode.currentTime = duration;
|
||||
} else {
|
||||
videoNode.currentTime = newDuration;
|
||||
}
|
||||
OVERLAY.showSeekedOverlay(player, Math.abs(stepSize), stepSize > 0);
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function changePlaybackSpeed(shouldSpeedUp: boolean) {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
const isSpeedUp = shouldSpeedUp;
|
||||
const rate = player.playbackRate();
|
||||
let rateIndex = videoPlaybackRates.findIndex((x) => x === rate);
|
||||
if (rateIndex >= 0) {
|
||||
rateIndex = isSpeedUp ? Math.min(rateIndex + 1, videoPlaybackRates.length - 1) : Math.max(rateIndex - 1, 0);
|
||||
const nextRate = videoPlaybackRates[rateIndex];
|
||||
|
||||
OVERLAY.showPlaybackRateOverlay(player, nextRate, isSpeedUp);
|
||||
player.userActive(true);
|
||||
player.playbackRate(nextRate);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleFullscreen() {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
if (!player.isFullscreen()) {
|
||||
player.requestFullscreen();
|
||||
} else {
|
||||
player.exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTheaterMode() {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
toggleVideoTheaterMode();
|
||||
if (player.isFullscreen()) {
|
||||
player.exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMute() {
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode) return;
|
||||
videoNode.muted = !videoNode.muted;
|
||||
}
|
||||
|
||||
function togglePlay() {
|
||||
const videoNode = containerRef.current && containerRef.current.querySelector('video, audio');
|
||||
if (!videoNode) return;
|
||||
videoNode.paused ? videoNode.play() : videoNode.pause();
|
||||
}
|
||||
|
||||
function volumeUp() {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
player.volume(player.volume() + 0.05);
|
||||
OVERLAY.showVolumeverlay(player, Math.round(player.volume() * 100));
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
function volumeDown() {
|
||||
const player = playerRef.current;
|
||||
if (!player) return;
|
||||
player.volume(player.volume() - 0.05);
|
||||
OVERLAY.showVolumeverlay(player, Math.round(player.volume() * 100));
|
||||
player.userActive(true);
|
||||
}
|
||||
|
||||
// Create the video DOM element and wrapper
|
||||
function createVideoPlayerDOM(container) {
|
||||
if (!container) return;
|
||||
|
||||
// This seems like a poor way to generate the DOM for video.js
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.setAttribute('data-vjs-player', 'true');
|
||||
const el = document.createElement(isAudio ? 'audio' : 'video');
|
||||
el.className = 'video-js vjs-big-play-centered ';
|
||||
wrapper.appendChild(el);
|
||||
|
||||
container.appendChild(wrapper);
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
function detectFileType() {
|
||||
return new Promise(async (res, rej) => {
|
||||
try {
|
||||
const response = await fetch(source, { method: 'HEAD', cache: 'no-store' });
|
||||
|
||||
// Temp variables to hold results
|
||||
let finalType = sourceType;
|
||||
let finalSource = source;
|
||||
|
||||
// override type if we receive an .m3u8 (transcoded mp4)
|
||||
// do we need to check if explicitly redirected
|
||||
// or is checking extension only a safer method
|
||||
if (response && response.redirected && response.url && response.url.endsWith('m3u8')) {
|
||||
finalType = 'application/x-mpegURL';
|
||||
finalSource = response.url;
|
||||
}
|
||||
|
||||
// Modify video source in options
|
||||
videoJsOptions.sources = [
|
||||
{
|
||||
src: finalSource,
|
||||
type: finalType,
|
||||
},
|
||||
];
|
||||
|
||||
return res(videoJsOptions);
|
||||
} catch (error) {
|
||||
return rej(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
const { unmuteAndHideHint, retryVideoAfterFailure, initializeEvents } = events({
|
||||
tapToUnmuteRef,
|
||||
tapToRetryRef,
|
||||
setReload,
|
||||
videoTheaterMode,
|
||||
playerRef,
|
||||
autoplaySetting,
|
||||
replay,
|
||||
});
|
||||
|
||||
// Initialize video.js
|
||||
function initializeVideoPlayer(el) {
|
||||
@@ -526,16 +177,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
// this seems like a weird thing to have to check for here
|
||||
if (!player) return;
|
||||
|
||||
// Add various event listeners to player
|
||||
player.one('play', onInitialPlay);
|
||||
player.on('play', resolveCtrlText);
|
||||
player.on('pause', resolveCtrlText);
|
||||
player.on('loadstart', resolveCtrlText);
|
||||
player.on('fullscreenchange', resolveCtrlText);
|
||||
player.on('volumechange', resolveCtrlText);
|
||||
player.on('volumechange', onVolumeChange);
|
||||
player.on('error', onError);
|
||||
player.on('ended', onEnded);
|
||||
initializeEvents();
|
||||
|
||||
// Replace volume bar with custom LBRY volume bar
|
||||
LbryVolumeBarClass.replaceExisting(player);
|
||||
@@ -560,7 +202,6 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
}
|
||||
|
||||
// set playsinline for mobile
|
||||
// TODO: make this better
|
||||
player.children_[0].setAttribute('playsinline', '');
|
||||
|
||||
// I think this is a callback function
|
||||
@@ -568,45 +209,14 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
onPlayerReady(player, videoNode);
|
||||
});
|
||||
|
||||
// fixes #3498 (https://github.com/lbryio/lbry-desktop/issues/3498)
|
||||
// summary: on firefox the focus would stick to the fullscreen button which caused buggy behavior with spacebar
|
||||
vjs.on('fullscreenchange', () => document.activeElement && document.activeElement.blur());
|
||||
|
||||
return vjs;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (replay && player) {
|
||||
player.play();
|
||||
}
|
||||
}, [replay]);
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const controlBar = player.getChild('controlBar');
|
||||
controlBar
|
||||
.getChild('TheaterModeButton')
|
||||
.controlText(videoTheaterMode ? __('Default Mode (t)') : __('Theater Mode (t)'));
|
||||
}
|
||||
}, [videoTheaterMode]);
|
||||
|
||||
useEffect(() => {
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
const touchOverlay = player.getChild('TouchOverlay');
|
||||
const controlBar = player.getChild('controlBar') || touchOverlay.getChild('controlBar');
|
||||
const autoplayButton = controlBar.getChild('AutoplayNextButton');
|
||||
|
||||
if (autoplayButton) {
|
||||
const title = autoplaySetting ? __('Autoplay Next On') : __('Autoplay Next Off');
|
||||
|
||||
autoplayButton.controlText(title);
|
||||
autoplayButton.setAttribute('aria-label', title);
|
||||
autoplayButton.setAttribute('aria-checked', autoplaySetting);
|
||||
}
|
||||
}
|
||||
}, [autoplaySetting]);
|
||||
|
||||
/** instantiate videoJS and dispose of it when done with code **/
|
||||
// This lifecycle hook is only called once (on mount), or when `isAudio` or `source` changes.
|
||||
useEffect(() => {
|
||||
const vjsElement = createVideoPlayerDOM(containerRef.current);
|
||||
@@ -622,13 +232,12 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||
// Set reference in component state
|
||||
playerRef.current = vjsPlayer;
|
||||
|
||||
// Add event listener for keyboard shortcuts
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
window.addEventListener('keydown', curried_function(playerRef, containerRef));
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
window.removeEventListener('keydown', curried_function);
|
||||
|
||||
const player = playerRef.current;
|
||||
if (player) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
import { connect } from 'react-redux';
|
||||
import { selectLanguage, selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||
import { doToast } from 'redux/actions/notifications';
|
||||
import { doOpenModal, doHideModal } from 'redux/actions/app';
|
||||
import { withRouter } from 'react-router';
|
||||
@@ -9,7 +9,6 @@ import analytics from 'analytics';
|
||||
import Wunderbar from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
language: selectLanguage(state),
|
||||
showMature: selectShowMatureContent(state),
|
||||
});
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ export const TOGGLE_YOUTUBE_SYNC_INTEREST = 'TOGGLE_YOUTUBE_SYNC_INTEREST';
|
||||
export const TOGGLE_SPLASH_ANIMATION = 'TOGGLE_SPLASH_ANIMATION';
|
||||
export const SET_ACTIVE_CHANNEL = 'SET_ACTIVE_CHANNEL';
|
||||
export const SET_INCOGNITO = 'SET_INCOGNITO';
|
||||
export const DISK_SPACE = 'DISK_SPACE';
|
||||
|
||||
// Navigation
|
||||
export const CHANGE_AFTER_AUTH_PATH = 'CHANGE_AFTER_AUTH_PATH';
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
export const VALID_IPADDRESS_REGEX = new RegExp(
|
||||
'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\.)){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'
|
||||
);
|
||||
export const VALID_HOSTNAME_REGEX = new RegExp(
|
||||
'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(\\.))+([A-Za-z]|[A-Za-z][A-Za-z]*[A-Za-z])$'
|
||||
);
|
||||
|
||||
export const VALID_ENDPOINT_REGEX = new RegExp('^((\\/)([a-zA-Z0-9]+))+$');
|
||||
@@ -41,9 +41,11 @@ export const VIDEO_THEATER_MODE = 'video_theater_mode';
|
||||
export const VIDEO_PLAYBACK_RATE = 'video_playback_rate';
|
||||
export const CUSTOM_COMMENTS_SERVER_ENABLED = 'custom_comments_server_enabled';
|
||||
export const CUSTOM_COMMENTS_SERVER_URL = 'custom_comments_server_url';
|
||||
export const CUSTOM_COMMENTS_SERVERS = 'custom_comments_servers';
|
||||
export const CUSTOM_SHARE_URL_ENABLED = 'custom_share_url_enabled';
|
||||
export const CUSTOM_SHARE_URL = 'custom_share_url';
|
||||
export const ENABLE_PRERELEASE_UPDATES = 'enable_prerelease_updates';
|
||||
export const DISABLE_AUTO_UPDATES = 'disable_auto_updates';
|
||||
|
||||
export const SETTINGS_GRP = {
|
||||
APPEARANCE: 'appearance',
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export const useActiveElement = () => {
|
||||
const [active, setActive] = useState(document.activeElement);
|
||||
|
||||
const handleFocus = (e) => {
|
||||
setActive(document.activeElement);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener('focusin', handleFocus);
|
||||
document.addEventListener('focusout', handleFocus);
|
||||
return () => {
|
||||
document.removeEventListener('focusin', handleFocus);
|
||||
document.removeEventListener('focusout', handleFocus);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return active;
|
||||
};
|
||||
@@ -1,55 +0,0 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { VASTClient } from 'vast-client';
|
||||
import analytics from 'analytics';
|
||||
|
||||
const PRE_ROLL_ADS_PROVIDER = 'https://tag.targeting.unrulymedia.com/rmp/216276/0/vast2?vastfw=vpaid&w=300&h=500&url=';
|
||||
|
||||
// Ignores any call made 1 minutes or less after the last successful ad
|
||||
const ADS_CAP_LEVEL = 1 * 60 * 1000;
|
||||
const vastClient = new VASTClient(0, ADS_CAP_LEVEL);
|
||||
|
||||
export function useGetAds(approvedVideo: boolean, adsEnabled: boolean): [?string, (?string) => void, boolean] {
|
||||
const [isFetching, setIsFetching] = React.useState(true);
|
||||
const [adUrl, setAdUrl] = React.useState();
|
||||
|
||||
// Fetch ads for all approved videos, even if we won't show ads to the user
|
||||
// Unruly needs more fetches before they will start returning ads ¯\_(ツ)_/¯
|
||||
React.useEffect(() => {
|
||||
if (!approvedVideo) {
|
||||
setIsFetching(false);
|
||||
return;
|
||||
}
|
||||
|
||||
analytics.adsFetchedEvent();
|
||||
const encodedHref = encodeURI(window.location.href);
|
||||
const url = `${PRE_ROLL_ADS_PROVIDER}${encodedHref}`;
|
||||
// Used for testing on local dev
|
||||
// const url = 'https://raw.githubusercontent.com/dailymotion/vast-client-js/master/test/vastfiles/sample.xml';
|
||||
|
||||
vastClient
|
||||
.get(url)
|
||||
.then((res) => {
|
||||
if (res.ads.length > 0) {
|
||||
// Let this line error if res.ads is empty
|
||||
// I took this from an example response from Dailymotion
|
||||
// It will be caught below and sent to matomo to figure out if there if this needs to be something changed to deal with unrulys data
|
||||
const adUrl = res.ads[0].creatives[0].mediaFiles[0].fileURL;
|
||||
|
||||
// Dummy video file
|
||||
// const adUrl = 'https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4';
|
||||
|
||||
if (adsEnabled && adUrl) {
|
||||
setAdUrl(adUrl);
|
||||
}
|
||||
}
|
||||
|
||||
setIsFetching(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setIsFetching(false);
|
||||
});
|
||||
}, [approvedVideo, adsEnabled]);
|
||||
|
||||
return [adUrl, setAdUrl, isFetching];
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { useActiveElement } from './use-active-element';
|
||||
export default function useHistoryNav(history) {
|
||||
const el = useActiveElement(); // disable if we're in a textarea.
|
||||
useEffect(() => {
|
||||
const handleKeyPress = e => {
|
||||
const handleKeyPress = (e) => {
|
||||
if ((e.metaKey || e.altKey) && !e.ctrlKey && !e.shiftKey) {
|
||||
switch (e.code) {
|
||||
case 'ArrowLeft':
|
||||
@@ -19,7 +20,9 @@ export default function useHistoryNav(history) {
|
||||
}
|
||||
}
|
||||
};
|
||||
window.addEventListener('keydown', handleKeyPress);
|
||||
if (!el.type || (el.type && !el.type.startsWith('text'))) {
|
||||
window.addEventListener('keydown', handleKeyPress);
|
||||
}
|
||||
return () => window.removeEventListener('keydown', handleKeyPress);
|
||||
}, []);
|
||||
}, [el]);
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
doHideModal,
|
||||
doToggle3PAnalytics,
|
||||
doUpdateDownloadProgress,
|
||||
doNotifyUpdateAvailable,
|
||||
} from 'redux/actions/app';
|
||||
import { isURIValid } from 'util/lbryURI';
|
||||
import { setSearchApi } from 'redux/actions/search';
|
||||
@@ -91,6 +92,18 @@ rewards.setCallback('claimRewardSuccess', (reward) => {
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.on('send-disk-space', (event, result) => {
|
||||
if (result.error) {
|
||||
console.log(`disk space error: ${result.error}`);
|
||||
} else {
|
||||
app.store.dispatch({
|
||||
type: ACTIONS.DISK_SPACE,
|
||||
data: result.diskSpace,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.send('get-disk-space');
|
||||
// @if TARGET='app'
|
||||
ipcRenderer.on('open-uri-requested', (event, url, newSession) => {
|
||||
function handleError() {
|
||||
@@ -117,6 +130,10 @@ ipcRenderer.on('open-uri-requested', (event, url, newSession) => {
|
||||
handleError();
|
||||
});
|
||||
|
||||
autoUpdater.on('update-available', (e) => {
|
||||
app.store.dispatch(doNotifyUpdateAvailable(e));
|
||||
});
|
||||
|
||||
ipcRenderer.on('download-progress-update', (e, p) => {
|
||||
app.store.dispatch(doUpdateDownloadProgress(Math.round(p.percent * 100)));
|
||||
});
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { selectRemoteVersion } from 'redux/selectors/app';
|
||||
import { doDownloadUpgrade, doSkipUpgrade, doHideModal } from 'redux/actions/app';
|
||||
import ModalUpgrade from './view';
|
||||
|
||||
const select = () => ({});
|
||||
const select = (state) => ({
|
||||
releaseVersion: selectRemoteVersion(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
const perform = (dispatch) => ({
|
||||
downloadUpgrade: () => dispatch(doDownloadUpgrade()),
|
||||
skipUpgrade: () => {
|
||||
dispatch(doHideModal());
|
||||
@@ -12,7 +15,4 @@ const perform = dispatch => ({
|
||||
},
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(ModalUpgrade);
|
||||
export default connect(select, perform)(ModalUpgrade);
|
||||
@@ -8,11 +8,12 @@ const IS_MAC = navigator.userAgent.indexOf('Mac OS X') !== -1;
|
||||
type Props = {
|
||||
downloadUpgrade: () => void,
|
||||
skipUpgrade: () => void,
|
||||
releaseVersion: string,
|
||||
};
|
||||
|
||||
class ModalUpgrade extends React.PureComponent<Props> {
|
||||
render() {
|
||||
const { downloadUpgrade, skipUpgrade } = this.props;
|
||||
const { downloadUpgrade, skipUpgrade, releaseVersion } = this.props;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
@@ -26,10 +27,7 @@ class ModalUpgrade extends React.PureComponent<Props> {
|
||||
onConfirmed={downloadUpgrade}
|
||||
onAborted={skipUpgrade}
|
||||
>
|
||||
<p>
|
||||
{__('An updated version of LBRY is now available.')}{' '}
|
||||
{__('Your version is out of date and may be unreliable or insecure.')}
|
||||
</p>
|
||||
{__('A new version %release_tag% of LBRY is ready for you.', { release_tag: releaseVersion })}
|
||||
<LastReleaseChanges hideReleaseVersion />
|
||||
</Modal>
|
||||
);
|
||||
|
||||
@@ -75,21 +75,15 @@ export default function OwnComments(props: Props) {
|
||||
)}
|
||||
{!contentClaim && <Empty text={__('Content or channel was deleted.')} />}
|
||||
</div>
|
||||
<Comment
|
||||
isTopLevel
|
||||
hideActions
|
||||
authorUri={comment.channel_url}
|
||||
author={comment.channel_name}
|
||||
commentId={comment.comment_id}
|
||||
message={comment.comment}
|
||||
timePosted={comment.timestamp * 1000}
|
||||
commentIsMine
|
||||
supportAmount={comment.support_amount}
|
||||
numDirectReplies={0} // Don't show replies here
|
||||
isModerator={comment.is_moderator}
|
||||
isGlobalMod={comment.is_global_mod}
|
||||
isFiat={comment.is_fiat}
|
||||
/>
|
||||
<React.Suspense fallback={null}>
|
||||
<Comment
|
||||
isTopLevel
|
||||
hideActions
|
||||
comment={comment}
|
||||
commentIsMine
|
||||
numDirectReplies={0} // Don't show replies here
|
||||
/>
|
||||
</React.Suspense>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doEnterSettingsPage, doExitSettingsPage } from 'redux/actions/settings';
|
||||
import { selectDaemonSettings, selectLanguage } from 'redux/selectors/settings';
|
||||
import { selectDaemonSettings } from 'redux/selectors/settings';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
|
||||
import SettingsPage from './view';
|
||||
@@ -8,7 +8,6 @@ import SettingsPage from './view';
|
||||
const select = (state) => ({
|
||||
daemonSettings: selectDaemonSettings(state),
|
||||
isAuthenticated: selectUserVerifiedEmail(state),
|
||||
language: selectLanguage(state),
|
||||
});
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
|
||||
+38
-31
@@ -18,7 +18,6 @@ import { Lbryio } from 'lbryinc';
|
||||
import { selectFollowedTagsList } from 'redux/selectors/tags';
|
||||
import { doToast, doError, doNotificationList } from 'redux/actions/notifications';
|
||||
|
||||
import Native from 'native';
|
||||
import {
|
||||
doFetchDaemonSettings,
|
||||
doSetAutoLaunch,
|
||||
@@ -37,7 +36,7 @@ import {
|
||||
selectModal,
|
||||
selectAllowAnalytics,
|
||||
} from 'redux/selectors/app';
|
||||
import { selectDaemonSettings, makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { selectDaemonSettings, makeSelectClientSetting, selectDisableAutoUpdates } from 'redux/selectors/settings';
|
||||
import { selectUser } from 'redux/selectors/user';
|
||||
import { doSyncLoop, doSetPrefsReady, doPreferenceGet, doPopulateSharedUserState } from 'redux/actions/sync';
|
||||
import { doAuthenticate } from 'redux/actions/user';
|
||||
@@ -183,42 +182,50 @@ export function doCheckUpgradeAvailable() {
|
||||
type: ACTIONS.CHECK_UPGRADE_START,
|
||||
});
|
||||
|
||||
if (['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE) {
|
||||
// On Windows, Mac, and AppImage, updates happen silently through
|
||||
// electron-updater.
|
||||
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
||||
const autoUpdateSupported = ['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE;
|
||||
|
||||
if (!autoUpdateDeclined && !isDev) {
|
||||
ipcRenderer.send('check-for-updates');
|
||||
}
|
||||
const autoUpdateDeclined = selectAutoUpdateDeclined(state);
|
||||
|
||||
// If auto update isn't supported (Linux using .deb packages)
|
||||
// don't perform any download, just get the upgrade info
|
||||
// (release notes and version)
|
||||
const disableAutoUpdate = !autoUpdateSupported || selectDisableAutoUpdates(state);
|
||||
|
||||
if (autoUpdateDeclined || isDev) {
|
||||
return;
|
||||
}
|
||||
|
||||
const success = ({ remoteVersion, upgradeAvailable }) => {
|
||||
dispatch({
|
||||
type: ACTIONS.CHECK_UPGRADE_SUCCESS,
|
||||
data: {
|
||||
upgradeAvailable,
|
||||
remoteVersion,
|
||||
},
|
||||
});
|
||||
ipcRenderer.send('check-for-updates', !disableAutoUpdate);
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
upgradeAvailable &&
|
||||
!selectModal(state) &&
|
||||
(!selectIsUpgradeSkipped(state) || remoteVersion !== selectRemoteVersion(state))
|
||||
) {
|
||||
dispatch(doOpenModal(MODALS.UPGRADE));
|
||||
}
|
||||
};
|
||||
export function doNotifyUpdateAvailable(e) {
|
||||
return (dispatch, getState) => {
|
||||
const remoteVersion = e.releaseName || e.version;
|
||||
|
||||
const fail = () => {
|
||||
dispatch({
|
||||
type: ACTIONS.CHECK_UPGRADE_FAIL,
|
||||
});
|
||||
};
|
||||
const state = getState();
|
||||
const noModalBeingDisplayed = !selectModal(state);
|
||||
const isUpgradeSkipped = selectIsUpgradeSkipped(state);
|
||||
const isRemoteVersionDiff = remoteVersion !== selectRemoteVersion(state);
|
||||
|
||||
Native.getAppVersionInfo().then(success, fail);
|
||||
dispatch({
|
||||
type: ACTIONS.CHECK_UPGRADE_SUCCESS,
|
||||
data: {
|
||||
upgradeAvailable: true,
|
||||
remoteVersion,
|
||||
releaseNotes: e.releaseNotes,
|
||||
},
|
||||
});
|
||||
|
||||
const autoUpdateSupported = ['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE;
|
||||
|
||||
if (autoUpdateSupported) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (noModalBeingDisplayed && !isUpgradeSkipped && isRemoteVersionDiff) {
|
||||
dispatch(doOpenModal(MODALS.UPGRADE));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,8 @@ export function doSetPrimaryUri(uri: ?string) {
|
||||
};
|
||||
}
|
||||
|
||||
export const doClearPlayingUri = () => (dispatch: Dispatch) => dispatch(doSetPlayingUri({ uri: null }));
|
||||
|
||||
export function doSetPlayingUri({
|
||||
uri,
|
||||
source,
|
||||
@@ -165,6 +167,7 @@ export function doPlayUri(
|
||||
const alreadyDownloading = fileInfo && !!downloadingByOutpoint[fileInfo.outpoint];
|
||||
|
||||
if (alreadyDownloading || alreadyDownloaded) {
|
||||
attemptPlay();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,14 +126,15 @@ export function doSetDaemonSetting(key, value, doNotDispatch = false) {
|
||||
// todo: add sdk reloadsettings() (or it happens automagically?)
|
||||
}
|
||||
});
|
||||
Lbry.settings_get().then((settings) => {
|
||||
analytics.toggleInternal(settings.share_usage_data);
|
||||
dispatch({
|
||||
type: ACTIONS.DAEMON_SETTINGS_RECEIVED,
|
||||
data: {
|
||||
settings,
|
||||
},
|
||||
});
|
||||
dispatch(doFetchDaemonSettings());
|
||||
};
|
||||
}
|
||||
|
||||
export function doCleanBlobs() {
|
||||
return (dispatch) => {
|
||||
Lbry.blob_clean().then(() => {
|
||||
dispatch(doFetchDaemonSettings());
|
||||
return 'done';
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
+18
-11
@@ -525,7 +525,7 @@ export function doSupportAbandonForClaim(claimId, claimType, keep, preview) {
|
||||
}
|
||||
|
||||
export function doWalletReconnect() {
|
||||
return (dispatch) => {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_RESTART,
|
||||
});
|
||||
@@ -533,16 +533,23 @@ export function doWalletReconnect() {
|
||||
// this basically returns null when it's done. :(
|
||||
// might be good to dispatch ACTIONS.WALLET_RESTARTED
|
||||
const walletTimeout = setTimeout(() => {
|
||||
failed = true;
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_RESTART_COMPLETED,
|
||||
});
|
||||
dispatch(
|
||||
doToast({
|
||||
message: __('Your servers were not available. Check your url and port, or switch back to defaults.'),
|
||||
isError: true,
|
||||
})
|
||||
);
|
||||
const state = getState();
|
||||
const { settings } = state;
|
||||
const { daemonStatus } = settings || {};
|
||||
const { wallet } = daemonStatus || {};
|
||||
const availableServers = wallet.available_servers;
|
||||
if (!availableServers) {
|
||||
failed = true;
|
||||
dispatch({
|
||||
type: ACTIONS.WALLET_RESTART_COMPLETED,
|
||||
});
|
||||
dispatch(
|
||||
doToast({
|
||||
message: __('Your servers were not available. Check your url and port, or switch back to defaults.'),
|
||||
isError: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
}, FIFTEEN_SECONDS);
|
||||
Lbry.wallet_reconnect().then(() => {
|
||||
clearTimeout(walletTimeout);
|
||||
|
||||
@@ -45,6 +45,7 @@ export type AppState = {
|
||||
interestedInYoutubeSync: boolean,
|
||||
activeChannel: ?string,
|
||||
incognito: boolean,
|
||||
diskSpace: ?DiskSpace,
|
||||
};
|
||||
|
||||
const defaultState: AppState = {
|
||||
@@ -83,6 +84,7 @@ const defaultState: AppState = {
|
||||
interestedInYoutubeSync: false,
|
||||
activeChannel: undefined,
|
||||
incognito: false,
|
||||
diskSpace: null,
|
||||
};
|
||||
|
||||
// @@router comes from react-router
|
||||
@@ -317,6 +319,13 @@ reducers[ACTIONS.SET_INCOGNITO] = (state, action) => {
|
||||
};
|
||||
};
|
||||
|
||||
reducers[ACTIONS.DISK_SPACE] = (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
diskSpace: action.data,
|
||||
};
|
||||
};
|
||||
|
||||
reducers[ACTIONS.SYNC_STATE_POPULATE] = (state, action) => {
|
||||
const { welcomeVersion, allowAnalytics } = action.data;
|
||||
return {
|
||||
|
||||
@@ -45,6 +45,7 @@ const defaultState = {
|
||||
[SETTINGS.DESKTOP_WINDOW_ZOOM]: 1,
|
||||
[SETTINGS.CUSTOM_COMMENTS_SERVER_ENABLED]: false,
|
||||
[SETTINGS.CUSTOM_COMMENTS_SERVER_URL]: '',
|
||||
[SETTINGS.CUSTOM_COMMENTS_SERVERS]: [],
|
||||
[SETTINGS.CUSTOM_SHARE_URL_ENABLED]: false,
|
||||
[SETTINGS.CUSTOM_SHARE_URL]: '',
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import { selectClaimsById, selectMyChannelClaims, selectTotalStakedAmountForChannelUri } from 'redux/selectors/claims';
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
|
||||
export const selectState = (state) => state.app || {};
|
||||
|
||||
@@ -51,6 +52,10 @@ export const selectAutoUpdateDownloaded = createSelector(selectState, (state) =>
|
||||
|
||||
export const selectAutoUpdateDeclined = createSelector(selectState, (state) => state.autoUpdateDeclined);
|
||||
|
||||
export const selectIsUpdateModalDisplayed = createSelector(selectState, (state) => {
|
||||
return [MODALS.AUTO_UPDATE_DOWNLOADED, MODALS.UPGRADE, MODALS.DOWNLOADING].includes(state.modal);
|
||||
});
|
||||
|
||||
export const selectDaemonVersionMatched = createSelector(selectState, (state) => state.daemonVersionMatched);
|
||||
|
||||
export const selectVolume = createSelector(selectState, (state) => state.volume);
|
||||
@@ -134,3 +139,5 @@ export const selectActiveChannelStakedLevel = createSelector(
|
||||
);
|
||||
|
||||
export const selectIncognito = createSelector(selectState, (state) => state.incognito);
|
||||
|
||||
export const selectDiskSpace = createSelector(selectState, (state) => state.diskSpace);
|
||||
@@ -83,3 +83,5 @@ export const selectHomepageData = createSelector(
|
||||
);
|
||||
|
||||
export const selectosNotificationsEnabled = makeSelectClientSetting(SETTINGS.OS_NOTIFICATIONS_ENABLED);
|
||||
|
||||
export const selectDisableAutoUpdates = makeSelectClientSetting(SETTINGS.DISABLE_AUTO_UPDATES);
|
||||
@@ -68,3 +68,5 @@
|
||||
@import 'component/wallet-tip-send';
|
||||
@import 'component/swipe-list';
|
||||
@import 'component/utils';
|
||||
@import 'component/settings';
|
||||
@import 'component/embed-player';
|
||||
@@ -290,8 +290,17 @@
|
||||
margin-right: var(--spacing-m);
|
||||
padding: 0 var(--spacing-xxs);
|
||||
|
||||
&.button--file-action-active {
|
||||
.icon {
|
||||
fill: var(--color-primary-alt);
|
||||
stroke: var(--color-primary) !important; //fixme
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
.icon {
|
||||
stroke: var(--color-text-subtitle);
|
||||
&:not(.color-override) {
|
||||
stroke: var(--color-text-subtitle);
|
||||
}
|
||||
}
|
||||
|
||||
.button__label {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
.comment__badge {
|
||||
padding-right: var(--spacing-xxs);
|
||||
|
||||
.icon {
|
||||
margin-bottom: -4px;
|
||||
height: 1rem;
|
||||
width: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.comment__badge--globalMod {
|
||||
.st0 {
|
||||
// @see: ICONS.BADGE_MOD
|
||||
fill: #fe7500;
|
||||
}
|
||||
}
|
||||
|
||||
.comment__badge--mod {
|
||||
.st0 {
|
||||
// @see: ICONS.BADGE_MOD
|
||||
fill: #ff3850;
|
||||
}
|
||||
}
|
||||
@@ -43,11 +43,13 @@ $thumbnailWidthSmall: 1rem;
|
||||
|
||||
.commentCreate__labelWrapper {
|
||||
display: flex;
|
||||
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
max-width: 50%;
|
||||
|
||||
.commentCreate__label {
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
.embed__wrapper {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background-color: var(--color-black);
|
||||
}
|
||||
|
||||
.embed__wrapper--light-background {
|
||||
@extend .embed__wrapper;
|
||||
|
||||
.vjs-poster,
|
||||
video {
|
||||
background-color: var(--color-white);
|
||||
}
|
||||
}
|
||||
|
||||
.embed__inline-button {
|
||||
@include thumbnail;
|
||||
position: relative;
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100%;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-top-left-radius: var(--border-radius);
|
||||
border-top-right-radius: var(--border-radius);
|
||||
background-color: var(--color-black);
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
height: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
.embed__inline-button-preview {
|
||||
@extend .embed__inline-button;
|
||||
background-color: var(--color-editor-inline-code-bg);
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.embed__loading {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.embed__loading-text {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--color-white);
|
||||
|
||||
h1 {
|
||||
font-size: var(--font-large);
|
||||
}
|
||||
}
|
||||
|
||||
.embed__overlay-logo {
|
||||
max-height: 2rem;
|
||||
max-width: 7rem;
|
||||
}
|
||||
@@ -111,6 +111,21 @@ label {
|
||||
.icon__lbc {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.compound-label {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: baseline;
|
||||
*:not(:first-child) {
|
||||
margin-left: var(--spacing-s);
|
||||
}
|
||||
.compount-label__strong {
|
||||
}
|
||||
.compound-label__details {
|
||||
color: var(--color-text-subtitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input-submit {
|
||||
@@ -293,7 +308,9 @@ input[type='number'] {
|
||||
|
||||
fieldset-group {
|
||||
+ fieldset-group {
|
||||
margin-top: var(--spacing-s);
|
||||
&:not(.fieldset-group--row) {
|
||||
margin-top: var(--spacing-s);
|
||||
}
|
||||
}
|
||||
|
||||
&.fieldset-group--smushed {
|
||||
@@ -339,6 +356,9 @@ fieldset-group {
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
&:not(.fieldset-group--row) {
|
||||
}
|
||||
}
|
||||
|
||||
// This is a special case where the prefix appears "inside" the input
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
border-bottom: none;
|
||||
|
||||
.header__navigation {
|
||||
padding: var(--spacing-xs);
|
||||
padding: var(--spacing-xs) 0;
|
||||
}
|
||||
|
||||
.header__navigationItem--logo {
|
||||
@@ -47,6 +47,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.header--mac {
|
||||
padding-top: var(--mac-titlebar-height);
|
||||
}
|
||||
|
||||
.header__contents {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -65,7 +69,7 @@
|
||||
justify-content: space-between;
|
||||
flex: 1;
|
||||
height: var(--header-height);
|
||||
padding: var(--spacing-s) var(--spacing-m);
|
||||
padding: var(--spacing-s) 0;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
@@ -156,8 +160,6 @@
|
||||
}
|
||||
|
||||
.header__navigationItem--profilePic {
|
||||
margin-right: var(--spacing-s);
|
||||
|
||||
.channel-thumbnail {
|
||||
height: var(--height-button);
|
||||
width: var(--height-button);
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
min-height: calc(100vh - var(--header-height));
|
||||
padding: 0 var(--spacing-m);
|
||||
|
||||
@media (max-width: $breakpoint-small) {
|
||||
width: 100%;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
.setting-item-input {
|
||||
min-height: var(--spacing-l);
|
||||
padding: 0 0 var(--spacing-s) 0;
|
||||
fieldset-section,
|
||||
.fieldset-group,
|
||||
fieldset-group {
|
||||
margin-top: 0;
|
||||
&:not(first-child) {
|
||||
margin-bottom: var(--spacing-m);
|
||||
}
|
||||
}
|
||||
&.checkbox,
|
||||
.checkbox:only-child {
|
||||
height: var(--spacing-l);
|
||||
float: left;
|
||||
}
|
||||
& {
|
||||
margin-left: 2.2rem;
|
||||
}
|
||||
}
|
||||
@@ -224,6 +224,7 @@
|
||||
min-width: 60%;
|
||||
max-width: 60%;
|
||||
}
|
||||
margin-bottom: var(--spacing-m);
|
||||
}
|
||||
|
||||
.settings__row-section-title {
|
||||
@@ -250,7 +251,9 @@
|
||||
}
|
||||
|
||||
fieldset-group {
|
||||
margin-top: var(--spacing-m);
|
||||
&:not(.fieldset-group--row) {
|
||||
margin-top: var(--spacing-m);
|
||||
}
|
||||
}
|
||||
|
||||
.tags__input-wrapper {
|
||||
|
||||
@@ -108,3 +108,17 @@ export function parseSticker(comment: string) {
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function getStickerUrl(comment: string) {
|
||||
const stickerFromComment = parseSticker(comment);
|
||||
return stickerFromComment && stickerFromComment.url;
|
||||
}
|
||||
|
||||
export function getCommentsListTitle(totalComments: number) {
|
||||
const title =
|
||||
(totalComments === 0 && __('Leave a comment')) ||
|
||||
(totalComments === 1 && __('1 comment')) ||
|
||||
__('%total_comments% comments', { total_comments: totalComments });
|
||||
|
||||
return title;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
const { exec } = require('child_process');
|
||||
|
||||
export const diskSpaceLinux = (path) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(`df ${path}`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
if (stderr) {
|
||||
return reject(new Error(stderr));
|
||||
}
|
||||
// Sample df command output:
|
||||
// Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
// C:\ 185087700 120552556 64535144 66% /mnt/c
|
||||
const dfResult = stdout.split('\n')[1].split(/\s+/);
|
||||
resolve({
|
||||
total: dfResult[1],
|
||||
free: dfResult[3],
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const diskSpaceMac = (path) => {
|
||||
// Escape spaces in path to prevent errors.
|
||||
// Example:
|
||||
// "/Users/username/Library/Application Support/LBRY" gets updated to
|
||||
// "/Users/username/Library/Application\\ Support/LBRY"
|
||||
const escapedPath = path.replace(/(\s+)/g, '\\$1');
|
||||
return diskSpaceLinux(escapedPath);
|
||||
};
|
||||
|
||||
export const diskSpaceWindows = (path) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(`wmic logicaldisk get size,freespace,caption`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
if (stderr) {
|
||||
return reject(new Error(stderr));
|
||||
}
|
||||
|
||||
// Drive used in the path (ie, C:, D:, etc.)
|
||||
const pathDrive = path.split(':')[0] + ':';
|
||||
|
||||
// Sample outout:
|
||||
// Caption FreeSpace Size
|
||||
// C: 66218471424 189529804800
|
||||
// D:
|
||||
// E: 536829952 536854528
|
||||
const stdoutLines = stdout.split('\n');
|
||||
// Find the drive used in the path.
|
||||
const driveLine = stdoutLines.find((line) => line.startsWith(pathDrive));
|
||||
// Parse the values in each column by filtering out the
|
||||
// empty spaces.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [drive, freeSpace, totalSize] = driveLine.split(' ').filter((x) => x);
|
||||
|
||||
resolve({
|
||||
total: totalSize,
|
||||
free: freeSpace,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -3,3 +3,8 @@
|
||||
export function formatNumberWithCommas(num: number, numberOfDigits?: number): string {
|
||||
return num.toLocaleString('en', { minimumFractionDigits: numberOfDigits !== undefined ? numberOfDigits : 8 });
|
||||
}
|
||||
|
||||
export function isTrulyANumber(num: number) {
|
||||
// typeof NaN = 'number' but NaN !== NaN
|
||||
return typeof num === 'number' && num === num; // eslint-disable-line
|
||||
}
|
||||
+14
-8
@@ -12,13 +12,19 @@ const invalidRegex = /[-_.+=?!@#$%^&*:;,{}<>\w/\\]/;
|
||||
const mentionRegex = /@[^\s()"-_.+=?!@$%^&*;,{}<>/\\]*/gm;
|
||||
|
||||
function handlePunctuation(value) {
|
||||
const modifierIndex =
|
||||
(value.indexOf(':') >= 0 && value.indexOf(':')) || (value.indexOf('#') >= 0 && value.indexOf('#'));
|
||||
const protocolIndex = value.indexOf('lbry://') === 0 ? protocol.length - 1 : 0;
|
||||
const channelModifierIndex =
|
||||
(value.indexOf(':', protocolIndex) >= 0 && value.indexOf(':', protocolIndex)) ||
|
||||
(value.indexOf('#', protocolIndex) >= 0 && value.indexOf('#', protocolIndex));
|
||||
const claimModifierIndex =
|
||||
(value.indexOf(':', channelModifierIndex + 1) >= 0 && value.indexOf(':', channelModifierIndex + 1)) ||
|
||||
(value.indexOf('#', channelModifierIndex + 1) >= 0 && value.indexOf('#', channelModifierIndex + 1)) ||
|
||||
channelModifierIndex;
|
||||
|
||||
let punctuationIndex;
|
||||
punctuationMarks.some((p) => {
|
||||
if (modifierIndex) {
|
||||
punctuationIndex = value.indexOf(p, modifierIndex + 1) >= 0 && value.indexOf(p, modifierIndex + 1);
|
||||
if (claimModifierIndex) {
|
||||
punctuationIndex = value.indexOf(p, claimModifierIndex + 1) >= 0 && value.indexOf(p, claimModifierIndex + 1);
|
||||
}
|
||||
return punctuationIndex;
|
||||
});
|
||||
@@ -108,15 +114,15 @@ function tokenizeURI(eat, value, silent) {
|
||||
|
||||
// Configure tokenizer for lbry urls
|
||||
tokenizeURI.locator = locateURI;
|
||||
tokenizeURI.notInList = true;
|
||||
tokenizeURI.notInList = false;
|
||||
tokenizeURI.notInLink = true;
|
||||
tokenizeURI.notInBlock = true;
|
||||
tokenizeURI.notInBlock = false;
|
||||
|
||||
// Configure tokenizer for lbry channels
|
||||
tokenizeMention.locator = locateMention;
|
||||
tokenizeMention.notInList = true;
|
||||
tokenizeMention.notInList = false;
|
||||
tokenizeMention.notInLink = true;
|
||||
tokenizeMention.notInBlock = true;
|
||||
tokenizeMention.notInBlock = false;
|
||||
|
||||
const visitor = (node, index, parent) => {
|
||||
if (node.type === 'link' && parent && parent.type === 'paragraph') {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
const PAGES = require('../../ui/constants/pages');
|
||||
|
||||
async function iframeDestroyerMiddleware(ctx, next) {
|
||||
const {
|
||||
request: { path },
|
||||
} = ctx;
|
||||
const decodedPath = decodeURIComponent(path);
|
||||
|
||||
if (!decodedPath.startsWith(`/$/${PAGES.EMBED}`)) {
|
||||
ctx.set('X-Frame-Options', 'DENY');
|
||||
}
|
||||
|
||||
return next();
|
||||
}
|
||||
|
||||
module.exports = iframeDestroyerMiddleware;
|
||||
Reference in new issue
Block a user