updates for lbrynet30

This commit is contained in:
Sean Yesmunt 2018-10-26 00:20:18 -04:00
parent eb12522bc7
commit 5e98a9b982
20 changed files with 108 additions and 191 deletions

View file

@ -17,7 +17,7 @@ const downloadDaemon = targetPlatform =>
let currentPlatform = os.platform(); let currentPlatform = os.platform();
var daemonPlatform = process.env.TARGET || targetPlatform || currentPlatform; var daemonPlatform = process.env.TARGET || targetPlatform || currentPlatform;
if (daemonPlatform === 'mac' || daemonPlatform === 'darwin') daemonPlatform = 'macos'; if (daemonPlatform === 'mac' || daemonPlatform === 'darwin') daemonPlatform = 'mac';
if (daemonPlatform === 'win32' || daemonPlatform === 'windows') { if (daemonPlatform === 'win32' || daemonPlatform === 'windows') {
daemonPlatform = 'windows'; daemonPlatform = 'windows';
daemonFileName = daemonFileName + '.exe'; daemonFileName = daemonFileName + '.exe';

View file

@ -49,8 +49,8 @@
"formik": "^0.10.4", "formik": "^0.10.4",
"hast-util-sanitize": "^1.1.2", "hast-util-sanitize": "^1.1.2",
"keytar": "^4.2.1", "keytar": "^4.2.1",
"lbry-redux": "lbryio/lbry-redux#ecd1ab156fb755c8bff4d890679399d66f41ad17", "lbry-redux": "lbryio/lbry-redux#634c3899f7d1e01fb08e3bd16d16c66670d6093c",
"lbryinc": "lbryio/lbryinc#3f34af546ee73ff2ee7d8ad05e540b3b0aa658fb", "lbryinc": "lbryio/lbryinc#3f3aaa9c367765d8ff14a06d0231cc126e94fe96",
"localforage": "^1.7.1", "localforage": "^1.7.1",
"mammoth": "^1.4.6", "mammoth": "^1.4.6",
"mime": "^2.3.1", "mime": "^2.3.1",
@ -134,9 +134,9 @@
"yarn": "^1.3" "yarn": "^1.3"
}, },
"lbrySettings": { "lbrySettings": {
"lbrynetDaemonVersion": "0.21.2", "lbrynetDaemonVersion": "0.30.0",
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip", "lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-OSNAME.zip",
"lbrynetDaemonDir": "static/daemon", "lbrynetDaemonDir": "static/daemon",
"lbrynetDaemonFileName": "lbrynet-daemon" "lbrynetDaemonFileName": "lbrynet"
} }
} }

View file

@ -3,7 +3,7 @@ import path from 'path';
import { spawn, execSync } from 'child_process'; import { spawn, execSync } from 'child_process';
export default class Daemon { export default class Daemon {
static path = process.env.LBRY_DAEMON || path.join(__static, 'daemon/lbrynet-daemon'); static path = process.env.LBRY_DAEMON || path.join(__static, 'daemon/lbrynet');
subprocess; subprocess;
handlers; handlers;
@ -12,13 +12,12 @@ export default class Daemon {
} }
launch() { launch() {
console.log('Launching daemon:', Daemon.path); this.subprocess = spawn(Daemon.path, ['start']);
this.subprocess = spawn(Daemon.path);
this.subprocess.stdout.on('data', data => console.log(`Daemon: ${data}`)); this.subprocess.stdout.on('data', data => console.log(`Daemon: ${data}`));
this.subprocess.stderr.on('data', data => console.error(`Daemon: ${data}`)); this.subprocess.stderr.on('data', data => console.error(`Daemon: ${data}`));
this.subprocess.on('exit', () => this.fire('exit')); this.subprocess.on('exit', () => this.fire('exit'));
this.subprocess.on('error', error => console.error(`Daemon: ${error}`)); this.subprocess.on('error', error => console.error(`Daemon error: ${error}`));
} }
quit() { quit() {

View file

@ -64,8 +64,9 @@ if (isDev) {
} }
app.on('ready', async () => { app.on('ready', async () => {
const processList = await findProcess('name', 'lbrynet-daemon'); const processList = await findProcess('name', 'lbrynet');
const isDaemonRunning = processList.length > 0; const isDaemonRunning = processList.length > 0;
if (!isDaemonRunning) { if (!isDaemonRunning) {
daemon = new Daemon(); daemon = new Daemon();
daemon.on('exit', () => { daemon.on('exit', () => {
@ -96,9 +97,14 @@ app.on('ready', async () => {
// See https://github.com/electron/electron/issues/13008#issuecomment-400261941 // See https://github.com/electron/electron/issues/13008#issuecomment-400261941
session.defaultSession.webRequest.onBeforeRequest({}, (details, callback) => { session.defaultSession.webRequest.onBeforeRequest({}, (details, callback) => {
if (details.url.indexOf('7accc8730b0f99b5e7c0702ea89d1fa7c17bfe33') !== -1) { if (details.url.indexOf('7accc8730b0f99b5e7c0702ea89d1fa7c17bfe33') !== -1) {
callback({redirectURL: details.url.replace('7accc8730b0f99b5e7c0702ea89d1fa7c17bfe33', '57c9d07b416b5a2ea23d28247300e4af36329bdc')}); callback({
redirectURL: details.url.replace(
'7accc8730b0f99b5e7c0702ea89d1fa7c17bfe33',
'57c9d07b416b5a2ea23d28247300e4af36329bdc'
),
});
} else { } else {
callback({cancel: false}); callback({ cancel: false });
} }
}); });
}); });

View file

@ -6,6 +6,7 @@ import {
makeSelectFileInfoForUri, makeSelectFileInfoForUri,
makeSelectIsUriResolving, makeSelectIsUriResolving,
makeSelectClaimIsMine, makeSelectClaimIsMine,
makeSelectClaimIsPending,
} from 'lbry-redux'; } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { import {
@ -13,34 +14,22 @@ import {
makeSelectContentPositionForUri, makeSelectContentPositionForUri,
} from 'redux/selectors/content'; } from 'redux/selectors/content';
import { selectShowNsfw } from 'redux/selectors/settings'; import { selectShowNsfw } from 'redux/selectors/settings';
import { selectPendingPublish } from 'redux/selectors/publish';
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions'; import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import { doClearContentHistoryUri } from 'redux/actions/content'; import { doClearContentHistoryUri } from 'redux/actions/content';
import FileCard from './view'; import FileCard from './view';
const select = (state, props) => { const select = (state, props) => ({
let pendingPublish; pending: makeSelectClaimIsPending(props.uri)(state),
if (props.checkPending) {
pendingPublish = selectPendingPublish(props.uri)(state);
}
const fileCardInfo = pendingPublish || {
claim: makeSelectClaimForUri(props.uri)(state), claim: makeSelectClaimForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
};
return {
obscureNsfw: !selectShowNsfw(state), obscureNsfw: !selectShowNsfw(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state), claimIsMine: makeSelectClaimIsMine(props.uri)(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state, props), rewardedContentClaimIds: selectRewardContentClaimIds(state, props),
...fileCardInfo, fileInfo: makeSelectFileInfoForUri(props.uri)(state),
pending: !!pendingPublish, metadata: makeSelectMetadataForUri(props.uri)(state),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
position: makeSelectContentPositionForUri(props.uri)(state), position: makeSelectContentPositionForUri(props.uri)(state),
isSubscribed: makeSelectIsSubscribed(props.uri)(state), isSubscribed: makeSelectIsSubscribed(props.uri)(state),
}; });
};
const perform = dispatch => ({ const perform = dispatch => ({
navigate: (path, params) => dispatch(doNavigate(path, params)), navigate: (path, params) => dispatch(doNavigate(path, params)),

View file

@ -10,7 +10,6 @@ type Props = {
sortByHeight?: boolean, sortByHeight?: boolean,
claimsById: Array<{}>, claimsById: Array<{}>,
fileInfos: Array<FileInfo>, fileInfos: Array<FileInfo>,
checkPending?: boolean,
sortBy: string, sortBy: string,
page?: string, page?: string,
setFileListSort: (?string, string) => void, setFileListSort: (?string, string) => void,
@ -30,9 +29,12 @@ class FileList extends React.PureComponent<Props> {
[SORT_OPTIONS.DATE_NEW]: fileInfos => [SORT_OPTIONS.DATE_NEW]: fileInfos =>
this.props.sortByHeight this.props.sortByHeight
? fileInfos.sort((fileInfo1, fileInfo2) => { ? fileInfos.sort((fileInfo1, fileInfo2) => {
if (fileInfo1.pending) { if (fileInfo1.confirmations < 1) {
return -1; return -1;
} else if (fileInfo2.confirmations < 1) {
return 1;
} }
const height1 = this.props.claimsById[fileInfo1.claim_id] const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height ? this.props.claimsById[fileInfo1.claim_id].height
: 0; : 0;
@ -125,7 +127,8 @@ class FileList extends React.PureComponent<Props> {
sortFunctions: {}; sortFunctions: {};
render() { render() {
const { fileInfos, hideFilter, checkPending, sortBy } = this.props; const { fileInfos, hideFilter, sortBy } = this.props;
const content = []; const content = [];
if (!fileInfos) { if (!fileInfos) {
return null; return null;
@ -151,7 +154,7 @@ class FileList extends React.PureComponent<Props> {
const outpoint = `${txid}:${nout}`; const outpoint = `${txid}:${nout}`;
// See https://github.com/lbryio/lbry-desktop/issues/1327 for discussion around using outpoint as the key // See https://github.com/lbryio/lbry-desktop/issues/1327 for discussion around using outpoint as the key
content.push(<FileCard key={outpoint} uri={uri} checkPending={checkPending} isNew={isNew} />); content.push(<FileCard key={outpoint} uri={uri} isNew={isNew} />);
}); });
return ( return (

View file

@ -123,7 +123,7 @@ class PublishForm extends React.PureComponent<Props> {
const { channel, updatePublishForm } = this.props; const { channel, updatePublishForm } = this.props;
if (!name) { if (!name) {
updatePublishForm({ nameError: undefined }); updatePublishForm({ name: '', nameError: __('A name is required.') });
return; return;
} }

View file

@ -159,7 +159,6 @@ class ChannelSection extends React.PureComponent<Props, State> {
<FormField <FormField
key="channel" key="channel"
type="select" type="select"
tabIndex="1"
onChange={this.handleChannelChange} onChange={this.handleChannelChange}
value={channel} value={channel}
> >

View file

@ -38,18 +38,12 @@ class UriIndicator extends React.PureComponent<Props> {
if (!claim) { if (!claim) {
return <span className="empty">{isResolvingUri ? 'Validating...' : 'Unused'}</span>; return <span className="empty">{isResolvingUri ? 'Validating...' : 'Unused'}</span>;
} }
const { channel_name: channelName, signature_is_valid: signatureIsValid, value } = claim;
const {
channel_name: channelName,
has_signature: hasSignature,
signature_is_valid: signatureIsValid,
value,
} = claim;
const channelClaimId = const channelClaimId =
value && value.publisherSignature && value.publisherSignature.certificateId; value && value.publisherSignature && value.publisherSignature.certificateId;
if (!hasSignature || !channelName) { if (!channelName) {
return <span className="channel-name">Anonymous</span>; return <span className="channel-name">Anonymous</span>;
} }

View file

@ -1,6 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
doSendSupport, doSendTip,
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectClaimForUri, makeSelectClaimForUri,
selectIsSendingSupport, selectIsSendingSupport,
@ -16,7 +16,10 @@ const select = (state, props) => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
sendSupport: (amount, claimId, uri) => dispatch(doSendSupport(amount, claimId, uri)), sendSupport: (amount, claimId, uri) => dispatch(doSendTip(amount, claimId, uri)),
}); });
export default connect(select, perform)(WalletSendTip); export default connect(
select,
perform
)(WalletSendTip);

View file

@ -1,20 +1,19 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectPendingPublishes, selectClaimsWithPendingPublishes } from 'redux/selectors/publish'; import { selectPendingPublishes } from 'redux/selectors/publish';
import { selectIsFetchingClaimListMine, selectFileListPublishedSort } from 'lbry-redux'; import { selectIsFetchingClaimListMine, selectFileListPublishedSort, selectMyClaimsWithoutChannels } from 'lbry-redux';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import { doCheckPendingPublishes } from 'redux/actions/publish'; import { doCheckPendingPublishes } from 'redux/actions/publish';
import FileListPublished from './view'; import FileListPublished from './view';
const select = state => ({ const select = state => ({
claims: selectClaimsWithPendingPublishes(state), claims: selectMyClaimsWithoutChannels(state),
fetching: selectIsFetchingClaimListMine(state), fetching: selectIsFetchingClaimListMine(state),
pendingPublishes: selectPendingPublishes(state),
sortBy: selectFileListPublishedSort(state), sortBy: selectFileListPublishedSort(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({
navigate: path => dispatch(doNavigate(path)), navigate: path => dispatch(doNavigate(path)),
checkIfPublishesConfirmed: publishes => dispatch(doCheckPendingPublishes(publishes)), checkPendingPublishes: () => dispatch(doCheckPendingPublishes()),
}); });
export default connect( export default connect(

View file

@ -1,4 +1,5 @@
// @flow // @flow
import type { Claim } from 'types/claim';
import React from 'react'; import React from 'react';
import Button from 'component/button'; import Button from 'component/button';
import FileList from 'component/fileList'; import FileList from 'component/fileList';
@ -6,9 +7,8 @@ import Page from 'component/page';
import { PAGES } from 'lbry-redux'; import { PAGES } from 'lbry-redux';
type Props = { type Props = {
pendingPublishes: Array<{}>, claims: Array<Claim>,
claims: Array<{}>, checkPendingPublishes: () => void,
checkIfPublishesConfirmed: (Array<{}>) => void,
navigate: (string, ?{}) => void, navigate: (string, ?{}) => void,
fetching: boolean, fetching: boolean,
sortBy: string, sortBy: string,
@ -16,10 +16,8 @@ type Props = {
class FileListPublished extends React.PureComponent<Props> { class FileListPublished extends React.PureComponent<Props> {
componentDidMount() { componentDidMount() {
const { pendingPublishes, checkIfPublishesConfirmed } = this.props; const { checkPendingPublishes } = this.props;
if (pendingPublishes.length) { checkPendingPublishes();
checkIfPublishesConfirmed(pendingPublishes);
}
} }
render() { render() {

View file

@ -26,7 +26,6 @@ type VersionInfo = {
os_release: string, os_release: string,
platform: string, platform: string,
lbrynet_version: string, lbrynet_version: string,
lbryum_version: string,
}; };
type State = { type State = {
@ -209,10 +208,6 @@ class HelpPage extends React.PureComponent<Props, State> {
<td>{__('Daemon (lbrynet)')}</td> <td>{__('Daemon (lbrynet)')}</td>
<td>{ver.lbrynet_version}</td> <td>{ver.lbrynet_version}</td>
</tr> </tr>
<tr>
<td>{__('Wallet (lbryum)')}</td>
<td>{ver.lbryum_version}</td>
</tr>
<tr> <tr>
<td>{__('Connected Email')}</td> <td>{__('Connected Email')}</td>
<td> <td>

View file

@ -292,7 +292,7 @@ export function doFetchClaimsByChannel(uri, page, pageSize) {
data: { uri, page }, data: { uri, page },
}); });
Lbry.claim_list_by_channel({ uri, page: page || 1, page_size: pageSize || 48 }).then(result => { Lbry.claim_list_by_channel({ uri, page: page || 1, page_size: pageSize || 20 }).then(result => {
const claimResult = result[uri] || {}; const claimResult = result[uri] || {};
const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult; const { claims_in_channel: claimsInChannel, returned_page: returnedPage } = claimResult;

View file

@ -1,4 +1,11 @@
// @flow // @flow
import type { Dispatch, GetState } from 'types/redux';
import type { Source, Metadata } from 'types/claim';
import type {
UpdatePublishFormData,
UpdatePublishFormAction,
PublishParams,
} from 'redux/reducers/publish';
import { import {
ACTIONS, ACTIONS,
Lbry, Lbry,
@ -7,20 +14,14 @@ import {
selectMyChannelClaims, selectMyChannelClaims,
THUMBNAIL_STATUSES, THUMBNAIL_STATUSES,
batchActions, batchActions,
creditsToString,
selectPendingById,
} from 'lbry-redux'; } from 'lbry-redux';
import { selectPendingPublishes } from 'redux/selectors/publish';
import type {
UpdatePublishFormData,
UpdatePublishFormAction,
PublishParams,
} from 'redux/reducers/publish';
import { selectosNotificationsEnabled } from 'redux/selectors/settings'; import { selectosNotificationsEnabled } from 'redux/selectors/settings';
import { doNavigate } from 'redux/actions/navigation'; import { doNavigate } from 'redux/actions/navigation';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { CC_LICENSES, COPYRIGHT, OTHER } from 'constants/licenses'; import { CC_LICENSES, COPYRIGHT, OTHER } from 'constants/licenses';
import type { Dispatch, GetState } from 'types/redux';
import type { Source } from 'types/claim';
type Action = UpdatePublishFormAction | { type: ACTIONS.CLEAR_PUBLISH }; type Action = UpdatePublishFormAction | { type: ACTIONS.CLEAR_PUBLISH };
@ -229,7 +230,6 @@ export const doPublish = (params: PublishParams) => (
licenseUrl, licenseUrl,
language, language,
thumbnail, thumbnail,
fee: fee || undefined,
description: description || undefined, description: description || undefined,
}; };
@ -237,16 +237,23 @@ export const doPublish = (params: PublishParams) => (
name: ?string, name: ?string,
channel_id: string, channel_id: string,
bid: ?number, bid: ?number,
metadata: ?any, metadata: ?Metadata,
file_path?: string, file_path?: string,
sources?: Source, sources?: Source,
} = { } = {
name, name,
channel_id: channelId, channel_id: channelId,
bid, bid: creditsToString(bid),
metadata, metadata,
}; };
if (fee) {
metadata.fee = {
currency: fee.currency,
amount: creditsToString(fee.amount),
};
}
if (filePath) { if (filePath) {
publishPayload.file_path = filePath; publishPayload.file_path = filePath;
} else { } else {
@ -258,7 +265,6 @@ export const doPublish = (params: PublishParams) => (
const success = () => { const success = () => {
dispatch({ dispatch({
type: ACTIONS.PUBLISH_SUCCESS, type: ACTIONS.PUBLISH_SUCCESS,
data: { pendingPublish: { ...publishPayload } },
}); });
dispatch(doNotify({ id: MODALS.PUBLISH }, { uri })); dispatch(doNotify({ id: MODALS.PUBLISH }, { uri }));
}; };
@ -274,28 +280,21 @@ export const doPublish = (params: PublishParams) => (
// Calls claim_list_mine until any pending publishes are confirmed // Calls claim_list_mine until any pending publishes are confirmed
export const doCheckPendingPublishes = () => (dispatch: Dispatch<Action>, getState: GetState) => { export const doCheckPendingPublishes = () => (dispatch: Dispatch<Action>, getState: GetState) => {
const state = getState(); const state = getState();
const pendingPublishes = selectPendingPublishes(state); const pendingById = selectPendingById(state);
if (!Object.keys(pendingById)) {
return;
}
let publishCheckInterval; let publishCheckInterval;
const checkFileList = () => { const checkFileList = () => {
Lbry.claim_list_mine().then(claims => { Lbry.claim_list_mine().then(claims => {
const pendingPublishMap = {};
pendingPublishes.forEach(({ name }) => {
pendingPublishMap[name] = name;
});
const actions = [];
claims.forEach(claim => { claims.forEach(claim => {
if (pendingPublishMap[claim.name]) { // If it's confirmed, check that it wasn't pending previously
actions.push({ if (claim.confirmations > 0 && pendingById[claim.claim_id]) {
type: ACTIONS.REMOVE_PENDING_PUBLISH, delete pendingById[claim.claim_id];
data: {
name: claim.name,
},
});
delete pendingPublishMap[claim.name]; // If it's confirmed, check if we should notify the user
if (selectosNotificationsEnabled(getState())) { if (selectosNotificationsEnabled(getState())) {
const notif = new window.Notification('LBRY Publish Complete', { const notif = new window.Notification('LBRY Publish Complete', {
body: `${claim.value.stream.metadata.title} has been published to lbry://${ body: `${claim.value.stream.metadata.title} has been published to lbry://${
@ -314,25 +313,21 @@ export const doCheckPendingPublishes = () => (dispatch: Dispatch<Action>, getSta
} }
}); });
actions.push({ dispatch({
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
data: { data: {
claims, claims,
}, },
}); });
dispatch(batchActions(...actions)); if (!Object.keys(pendingById).length) {
if (!Object.keys(pendingPublishMap).length) {
clearInterval(publishCheckInterval); clearInterval(publishCheckInterval);
} }
}); });
}; };
if (pendingPublishes.length) {
checkFileList(); checkFileList();
publishCheckInterval = setInterval(() => { publishCheckInterval = setInterval(() => {
checkFileList(); checkFileList();
}, 30000); }, 30000);
}
}; };

View file

@ -100,7 +100,7 @@ export const doFetchMySubscriptions = () => (dispatch: ReduxDispatch, getState:
data: subscriptions, data: subscriptions,
}); });
subscriptions.forEach(({ uri }) => dispatch(doFetchClaimsByChannel(uri, 1, 20))); subscriptions.forEach(({ uri }) => dispatch(doFetchClaimsByChannel(uri, 1)));
}) })
.catch(() => { .catch(() => {
dispatch({ dispatch({

View file

@ -29,7 +29,6 @@ type PublishState = {
bidError: ?string, bidError: ?string,
otherLicenseDescription: string, otherLicenseDescription: string,
licenseUrl: string, licenseUrl: string,
pendingPublishes: Array<any>,
}; };
export type UpdatePublishFormData = { export type UpdatePublishFormData = {
@ -115,7 +114,6 @@ const defaultState: PublishState = {
publishing: false, publishing: false,
publishSuccess: false, publishSuccess: false,
publishError: undefined, publishError: undefined,
pendingPublishes: [],
}; };
export default handleActions( export default handleActions(
@ -127,10 +125,9 @@ export default handleActions(
...data, ...data,
}; };
}, },
[ACTIONS.CLEAR_PUBLISH]: (state: PublishState): PublishState => { [ACTIONS.CLEAR_PUBLISH]: (): PublishState => ({
const { pendingPublishes } = state; ...defaultState,
return { ...defaultState, pendingPublishes }; }),
},
[ACTIONS.PUBLISH_START]: (state: PublishState): PublishState => ({ [ACTIONS.PUBLISH_START]: (state: PublishState): PublishState => ({
...state, ...state,
publishing: true, publishing: true,
@ -139,29 +136,11 @@ export default handleActions(
...state, ...state,
publishing: false, publishing: false,
}), }),
[ACTIONS.PUBLISH_SUCCESS]: (state: PublishState, action): PublishState => { [ACTIONS.PUBLISH_SUCCESS]: (state: PublishState): PublishState => ({
const { pendingPublish } = action.data;
const newPendingPublishes = state.pendingPublishes.slice();
newPendingPublishes.push(pendingPublish);
return {
...state, ...state,
publishing: false, publishing: false,
pendingPublishes: newPendingPublishes, }),
};
},
[ACTIONS.REMOVE_PENDING_PUBLISH]: (state: PublishState, action) => {
const { name } = action.data;
const pendingPublishes = state.pendingPublishes.filter(publish => publish.name !== name);
return {
...state,
pendingPublishes,
};
},
[ACTIONS.DO_PREPARE_EDIT]: (state: PublishState, action) => { [ACTIONS.DO_PREPARE_EDIT]: (state: PublishState, action) => {
const { pendingPublishes } = state;
const { ...publishData } = action.data; const { ...publishData } = action.data;
const { channel, name, uri } = publishData; const { channel, name, uri } = publishData;
@ -175,7 +154,6 @@ export default handleActions(
return { return {
...defaultState, ...defaultState,
...publishData, ...publishData,
pendingPublishes,
editingURI: uri, editingURI: uri,
uri: shortUri, uri: shortUri,
}; };

View file

@ -10,47 +10,11 @@ import {
const selectState = state => state.publish || {}; const selectState = state => state.publish || {};
export const selectPendingPublishes = createSelector(
selectState,
state => state.pendingPublishes.map(pendingClaim => ({ ...pendingClaim, pending: true })) || []
);
export const selectClaimsWithPendingPublishes = createSelector(
selectMyClaimsWithoutChannels,
selectPendingPublishes,
(claims, pendingPublishes) => {
// ensure there are no duplicates, they are being checked for in a setInterval
// no need to wait for it to complete though
// loop through myclaims
// if a claim has the same name as one in pendingPublish, remove it from pending
const claimMap = {};
claims.forEach(claim => {
claimMap[claim.name] = true;
});
const filteredPendingPublishes = pendingPublishes.filter(claim => !claimMap[claim.name]);
return [...filteredPendingPublishes, ...claims];
}
);
export const selectPublishFormValues = createSelector(selectState, state => { export const selectPublishFormValues = createSelector(selectState, state => {
const { pendingPublish, ...formValues } = state; const { pendingPublish, ...formValues } = state;
return formValues; return formValues;
}); });
export const selectPendingPublish = uri =>
createSelector(selectPendingPublishes, pendingPublishes => {
const { claimName, contentName } = parseURI(uri);
if (!pendingPublishes.length) {
return null;
}
return pendingPublishes.filter(
publish => publish.name === claimName || publish.name === contentName
)[0];
});
// Is the current uri the same as the uri they clicked "edit" on // Is the current uri the same as the uri they clicked "edit" on
export const selectIsStillEditing = createSelector(selectPublishFormValues, publishState => { export const selectIsStillEditing = createSelector(selectPublishFormValues, publishState => {
const { editingURI, uri } = publishState; const { editingURI, uri } = publishState;

View file

@ -1,5 +1,7 @@
export function formatCredits(amount, precision) { export function formatCredits(amount, precision = 1) {
return amount.toFixed(precision || 1).replace(/\.?0+$/, ''); return parseFloat(amount)
.toFixed(precision || 1)
.replace(/\.?0+$/, '');
} }
export function formatFullPrice(amount, precision = 1) { export function formatFullPrice(amount, precision = 1) {

View file

@ -5663,25 +5663,18 @@ lazy-val@^1.0.3:
version "1.0.3" version "1.0.3"
resolved "https://registry.yarnpkg.com/lazy-val/-/lazy-val-1.0.3.tgz#bb97b200ef00801d94c317e29dc6ed39e31c5edc" resolved "https://registry.yarnpkg.com/lazy-val/-/lazy-val-1.0.3.tgz#bb97b200ef00801d94c317e29dc6ed39e31c5edc"
lbry-redux@lbryio/lbry-redux: lbry-redux@lbryio/lbry-redux#634c3899f7d1e01fb08e3bd16d16c66670d6093c:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/a8e81949837171e94e649fce6f7c7a8b7faadd51" resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/634c3899f7d1e01fb08e3bd16d16c66670d6093c"
dependencies: dependencies:
proxy-polyfill "0.1.6" proxy-polyfill "0.1.6"
reselect "^3.0.0" reselect "^3.0.0"
lbry-redux@lbryio/lbry-redux#03aea43da5f12bc01546a92bdf460ebd08681013: lbryinc@lbryio/lbryinc#3f3aaa9c367765d8ff14a06d0231cc126e94fe96:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/03aea43da5f12bc01546a92bdf460ebd08681013" resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/3f3aaa9c367765d8ff14a06d0231cc126e94fe96"
dependencies: dependencies:
proxy-polyfill "0.1.6" lbry-redux lbryio/lbry-redux#634c3899f7d1e01fb08e3bd16d16c66670d6093c
reselect "^3.0.0"
lbryinc@lbryio/lbryinc#3f34af546ee73ff2ee7d8ad05e540b3b0aa658fb:
version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/3f34af546ee73ff2ee7d8ad05e540b3b0aa658fb"
dependencies:
lbry-redux lbryio/lbry-redux
reselect "^3.0.0" reselect "^3.0.0"
lcid@^1.0.0: lcid@^1.0.0: