successfully publishes using lbry-redux
updates lbry-redux hash adds streamPublish success and fail callbacks passing callbacks in doPublish( success, fail ) update redux prepare rebase
This commit is contained in:
parent
6eafb3a561
commit
f2c51f7735
18 changed files with 243 additions and 152 deletions
|
@ -1,19 +1,18 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doResolveUri, selectBalance } from 'lbry-redux';
|
|
||||||
import {
|
import {
|
||||||
|
doResolveUri,
|
||||||
|
selectBalance,
|
||||||
selectPublishFormValues,
|
selectPublishFormValues,
|
||||||
selectIsStillEditing,
|
selectIsStillEditing,
|
||||||
selectMyClaimForUri,
|
selectMyClaimForUri,
|
||||||
selectIsResolvingPublishUris,
|
selectIsResolvingPublishUris,
|
||||||
selectTakeOverAmount,
|
selectTakeOverAmount,
|
||||||
} from 'redux/selectors/publish';
|
|
||||||
import {
|
|
||||||
doResetThumbnailStatus,
|
doResetThumbnailStatus,
|
||||||
doClearPublish,
|
doClearPublish,
|
||||||
doUpdatePublishForm,
|
doUpdatePublishForm,
|
||||||
doPublish,
|
|
||||||
doPrepareEdit,
|
doPrepareEdit,
|
||||||
} from 'redux/actions/publish';
|
} from 'lbry-redux';
|
||||||
|
import { doPublish } from 'redux/actions/publish';
|
||||||
import { selectUnclaimedRewardValue } from 'lbryinc';
|
import { selectUnclaimedRewardValue } from 'lbryinc';
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectBalance } from 'lbry-redux';
|
|
||||||
import { selectIsStillEditing, makeSelectPublishFormValue } from 'redux/selectors/publish';
|
import { selectBalance, selectIsStillEditing, makeSelectPublishFormValue, doUpdatePublishForm } from 'lbry-redux';
|
||||||
import { doUpdatePublishForm } from 'redux/actions/publish';
|
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doResolveUri } from 'lbry-redux';
|
|
||||||
import {
|
import {
|
||||||
|
doResolveUri,
|
||||||
selectPublishFormValues,
|
selectPublishFormValues,
|
||||||
selectIsStillEditing,
|
selectIsStillEditing,
|
||||||
selectMyClaimForUri,
|
selectMyClaimForUri,
|
||||||
selectIsResolvingPublishUris,
|
selectIsResolvingPublishUris,
|
||||||
selectTakeOverAmount,
|
selectTakeOverAmount,
|
||||||
} from 'redux/selectors/publish';
|
|
||||||
import {
|
|
||||||
doResetThumbnailStatus,
|
doResetThumbnailStatus,
|
||||||
doClearPublish,
|
doClearPublish,
|
||||||
doUpdatePublishForm,
|
doUpdatePublishForm,
|
||||||
doPublish,
|
|
||||||
doPrepareEdit,
|
doPrepareEdit,
|
||||||
} from 'redux/actions/publish';
|
} from 'lbry-redux';
|
||||||
|
import { doPublish } from 'redux/actions/publish';
|
||||||
import { selectUnclaimedRewardValue } from 'lbryinc';
|
import { selectUnclaimedRewardValue } from 'lbryinc';
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
|
@ -34,7 +32,7 @@ const perform = dispatch => ({
|
||||||
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
|
||||||
clearPublish: () => dispatch(doClearPublish()),
|
clearPublish: () => dispatch(doClearPublish()),
|
||||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||||
publish: params => dispatch(doPublish(params)),
|
publish: (success, fail) => dispatch(doPublish(success, fail)),
|
||||||
prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)),
|
prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)),
|
||||||
resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()),
|
resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()),
|
||||||
});
|
});
|
||||||
|
|
|
@ -170,7 +170,7 @@ function PublishForm(props: Props) {
|
||||||
<div className="card__actions">
|
<div className="card__actions">
|
||||||
<Button
|
<Button
|
||||||
button="primary"
|
button="primary"
|
||||||
onClick={publish}
|
onClick={() => publish(success, fail)}
|
||||||
label={submitLabel}
|
label={submitLabel}
|
||||||
disabled={formDisabled || !formValid || uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS}
|
disabled={formDisabled || !formValid || uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectPublishFormValue, selectIsStillEditing } from 'redux/selectors/publish';
|
import { makeSelectPublishFormValue, selectIsStillEditing } from 'lbry-redux';
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
|
|
@ -5,9 +5,11 @@ import {
|
||||||
selectMyClaimForUri,
|
selectMyClaimForUri,
|
||||||
selectIsResolvingPublishUris,
|
selectIsResolvingPublishUris,
|
||||||
selectTakeOverAmount,
|
selectTakeOverAmount,
|
||||||
} from 'redux/selectors/publish';
|
doUpdatePublishForm,
|
||||||
import { doUpdatePublishForm, doPrepareEdit } from 'redux/actions/publish';
|
doPrepareEdit,
|
||||||
import { selectBalance } from 'lbry-redux';
|
selectBalance,
|
||||||
|
} from 'lbry-redux';
|
||||||
|
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
@ -15,7 +17,6 @@ const select = state => ({
|
||||||
channel: makeSelectPublishFormValue('channel')(state),
|
channel: makeSelectPublishFormValue('channel')(state),
|
||||||
bid: makeSelectPublishFormValue('bid')(state),
|
bid: makeSelectPublishFormValue('bid')(state),
|
||||||
uri: makeSelectPublishFormValue('uri')(state),
|
uri: makeSelectPublishFormValue('uri')(state),
|
||||||
bid: makeSelectPublishFormValue('bid')(state),
|
|
||||||
isStillEditing: selectIsStillEditing(state),
|
isStillEditing: selectIsStillEditing(state),
|
||||||
isResolvingUri: selectIsResolvingPublishUris(state),
|
isResolvingUri: selectIsResolvingPublishUris(state),
|
||||||
amountNeededForTakeover: selectTakeOverAmount(state),
|
amountNeededForTakeover: selectTakeOverAmount(state),
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doUpdatePublishForm } from 'redux/actions/publish';
|
import { makeSelectPublishFormValue, doUpdatePublishForm } from 'lbry-redux';
|
||||||
import { makeSelectPublishFormValue } from 'redux/selectors/publish';
|
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { makeSelectPublishFormValue } from 'redux/selectors/publish';
|
import { doUpdatePublishForm, makeSelectPublishFormValue } from 'lbry-redux';
|
||||||
import { doUpdatePublishForm } from 'redux/actions/publish';
|
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doResolveUri } from 'lbry-redux';
|
|
||||||
import {
|
import {
|
||||||
|
doResolveUri,
|
||||||
selectPublishFormValues,
|
selectPublishFormValues,
|
||||||
selectIsStillEditing,
|
selectIsStillEditing,
|
||||||
selectMyClaimForUri,
|
selectMyClaimForUri,
|
||||||
selectIsResolvingPublishUris,
|
selectIsResolvingPublishUris,
|
||||||
selectTakeOverAmount,
|
selectTakeOverAmount,
|
||||||
} from 'redux/selectors/publish';
|
|
||||||
import {
|
|
||||||
doResetThumbnailStatus,
|
doResetThumbnailStatus,
|
||||||
doClearPublish,
|
doClearPublish,
|
||||||
doUpdatePublishForm,
|
doUpdatePublishForm,
|
||||||
doPublish,
|
|
||||||
doPrepareEdit,
|
doPrepareEdit,
|
||||||
} from 'redux/actions/publish';
|
} from 'lbry-redux';
|
||||||
|
|
||||||
import { doOpenModal } from 'redux/actions/app';
|
import { doOpenModal } from 'redux/actions/app';
|
||||||
|
import { doPublish } from 'redux/actions/publish';
|
||||||
import { selectUnclaimedRewardValue } from 'lbryinc';
|
import { selectUnclaimedRewardValue } from 'lbryinc';
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,16 @@ import React, { useState, useEffect } from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate, doOpenModal, doHideModal } from 'redux/actions/app';
|
import { doConditionalAuthNavigate, doDaemonReady, doAutoUpdate, doOpenModal, doHideModal } from 'redux/actions/app';
|
||||||
import { Lbry, doToast, isURIValid, setSearchApi } from 'lbry-redux';
|
import {
|
||||||
|
Lbry,
|
||||||
|
doToast,
|
||||||
|
isURIValid,
|
||||||
|
setSearchApi,
|
||||||
|
// reduxCallbacks,
|
||||||
|
// batchActions,
|
||||||
|
// selectMyClaimsWithoutChannels,
|
||||||
|
// doError,
|
||||||
|
} from 'lbry-redux';
|
||||||
import { doInitLanguage, doUpdateIsNightAsync } from 'redux/actions/settings';
|
import { doInitLanguage, doUpdateIsNightAsync } from 'redux/actions/settings';
|
||||||
import {
|
import {
|
||||||
doAuthenticate,
|
doAuthenticate,
|
||||||
|
@ -129,6 +138,45 @@ rewards.setCallback('claimRewardSuccess', () => {
|
||||||
app.store.dispatch(doHideModal(MODALS.REWARD_APPROVAL_REQUIRED));
|
app.store.dispatch(doHideModal(MODALS.REWARD_APPROVAL_REQUIRED));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// mimicking app.js.doOpenModal(id, modalProps {}) here
|
||||||
|
// reduxCallbacks.setCallback('streamPublishSuccess', successResponse => {
|
||||||
|
// const state = store.getState();
|
||||||
|
// analytics.apiLogPublish();
|
||||||
|
// const myClaims = selectMyClaimsWithoutChannels(state);
|
||||||
|
// const pendingClaim = successResponse.outputs[0];
|
||||||
|
// const uri = pendingClaim.permanent_url;
|
||||||
|
// const actions = [];
|
||||||
|
//
|
||||||
|
// actions.push({
|
||||||
|
// type: ACTIONS.PUBLISH_SUCCESS,
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// // We have to fake a temp claim until the new pending one is returned by claim_list_mine
|
||||||
|
// // We can't rely on claim_list_mine because there might be some delay before the new claims are returned
|
||||||
|
// // Doing this allows us to show the pending claim immediately, it will get overwritten by the real one
|
||||||
|
// const isMatch = claim => claim.claim_id === pendingClaim.claim_id;
|
||||||
|
// const isEdit = myClaims.some(isMatch);
|
||||||
|
//
|
||||||
|
// const myNewClaims = isEdit
|
||||||
|
// ? myClaims.map(claim => (isMatch(claim) ? pendingClaim : claim))
|
||||||
|
// : myClaims.concat(pendingClaim);
|
||||||
|
//
|
||||||
|
// actions.push(doOpenModal(MODALS.PUBLISH, { uri, isEdit }));
|
||||||
|
//
|
||||||
|
// actions.push({
|
||||||
|
// type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
||||||
|
// data: {
|
||||||
|
// claims: myNewClaims,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// store.dispatch(batchActions(...actions));
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// reduxCallbacks.setCallback('streamPublishFail', error => {
|
||||||
|
// store.dispatch({ type: ACTIONS.PUBLISH_FAIL });
|
||||||
|
// store.dispatch(doError(error.message));
|
||||||
|
// });
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
ipcRenderer.on('open-uri-requested', (event, uri, newSession) => {
|
ipcRenderer.on('open-uri-requested', (event, uri, newSession) => {
|
||||||
if (uri && uri.startsWith('lbry://')) {
|
if (uri && uri.startsWith('lbry://')) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doHideModal } from 'redux/actions/app';
|
import { doHideModal } from 'redux/actions/app';
|
||||||
import { doUploadThumbnail } from 'redux/actions/publish';
|
import { doToast, doUploadThumbnail } from 'lbry-redux';
|
||||||
import { doToast } from 'lbry-redux';
|
|
||||||
import ModalAutoGenerateThumbnail from './view';
|
import ModalAutoGenerateThumbnail from './view';
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doHideModal } from 'redux/actions/app';
|
import { doHideModal } from 'redux/actions/app';
|
||||||
import { doUploadThumbnail, doUpdatePublishForm } from 'redux/actions/publish';
|
import { doUploadThumbnail, doUpdatePublishForm } from 'lbry-redux';
|
||||||
import ModalConfirmThumbnailUpload from './view';
|
import ModalConfirmThumbnailUpload from './view';
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doHideModal } from 'redux/actions/app';
|
import { doHideModal } from 'redux/actions/app';
|
||||||
import ModalPublishSuccess from './view';
|
import ModalPublishSuccess from './view';
|
||||||
import { doClearPublish } from 'redux/actions/publish';
|
import { doClearPublish } from 'lbry-redux';
|
||||||
import { push } from 'connected-react-router';
|
import { push } from 'connected-react-router';
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -16,11 +16,11 @@ import {
|
||||||
makeSelectTitleForUri,
|
makeSelectTitleForUri,
|
||||||
makeSelectThumbnailForUri,
|
makeSelectThumbnailForUri,
|
||||||
makeSelectClaimIsNsfw,
|
makeSelectClaimIsNsfw,
|
||||||
|
doPrepareEdit,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { doFetchViewCount, makeSelectViewCountForUri, makeSelectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc';
|
import { doFetchViewCount, makeSelectViewCountForUri, makeSelectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc';
|
||||||
import { selectShowNsfw, makeSelectClientSetting } from 'redux/selectors/settings';
|
import { selectShowNsfw, makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
|
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
|
||||||
import { doPrepareEdit } from 'redux/actions/publish';
|
|
||||||
import { doOpenModal } from 'redux/actions/app';
|
import { doOpenModal } from 'redux/actions/app';
|
||||||
import FilePage from './view';
|
import FilePage from './view';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectIsFetchingClaimListMine, selectMyClaimUrisWithoutChannels } from 'lbry-redux';
|
import { selectIsFetchingClaimListMine, selectMyClaimUrisWithoutChannels, doCheckPendingPublishes } from 'lbry-redux';
|
||||||
import { doCheckPendingPublishes } from 'redux/actions/publish';
|
|
||||||
import FileListPublished from './view';
|
import FileListPublished from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
notificationsReducer,
|
notificationsReducer,
|
||||||
tagsReducer,
|
tagsReducer,
|
||||||
commentReducer,
|
commentReducer,
|
||||||
|
publishReducer,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import {
|
import {
|
||||||
userReducer,
|
userReducer,
|
||||||
|
@ -23,7 +24,7 @@ import availabilityReducer from 'redux/reducers/availability';
|
||||||
import contentReducer from 'redux/reducers/content';
|
import contentReducer from 'redux/reducers/content';
|
||||||
import settingsReducer from 'redux/reducers/settings';
|
import settingsReducer from 'redux/reducers/settings';
|
||||||
import subscriptionsReducer from 'redux/reducers/subscriptions';
|
import subscriptionsReducer from 'redux/reducers/subscriptions';
|
||||||
import publishReducer from 'redux/reducers/publish';
|
|
||||||
|
|
||||||
export default history =>
|
export default history =>
|
||||||
combineReducers({
|
combineReducers({
|
||||||
|
|
|
@ -9,19 +9,23 @@ import {
|
||||||
batchActions,
|
batchActions,
|
||||||
creditsToString,
|
creditsToString,
|
||||||
selectPendingById,
|
selectPendingById,
|
||||||
selectMyClaimsWithoutChannels,
|
|
||||||
doError,
|
doError,
|
||||||
isClaimNsfw,
|
isClaimNsfw,
|
||||||
|
selectMyClaimForUri,
|
||||||
|
selectPublishFormValues,
|
||||||
|
selectMyClaimsWithoutChannels,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { doOpenModal } from 'redux/actions/app';
|
// import { doOpenModal } from 'redux/actions/app';
|
||||||
import { selectosNotificationsEnabled } from 'redux/selectors/settings';
|
import { selectosNotificationsEnabled } from 'redux/selectors/settings';
|
||||||
import { selectMyClaimForUri, selectPublishFormValues } from 'redux/selectors/publish';
|
|
||||||
import { push } from 'connected-react-router';
|
import { push } from 'connected-react-router';
|
||||||
import analytics from 'analytics';
|
// import analytics from 'analytics';
|
||||||
import { formatLbryUriForWeb } from 'util/uri';
|
import { formatLbryUriForWeb } from 'util/uri';
|
||||||
// @if TARGET='app'
|
// @if TARGET='app'
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { store } from '../../store';
|
||||||
|
import analytics from '../../analytics';
|
||||||
|
import { doOpenModal } from './app';
|
||||||
// @endif
|
// @endif
|
||||||
|
|
||||||
export const doResetThumbnailStatus = () => (dispatch: Dispatch) => {
|
export const doResetThumbnailStatus = () => (dispatch: Dispatch) => {
|
||||||
|
@ -207,6 +211,49 @@ export const doPrepareEdit = (claim: StreamClaim, uri: string, fileInfo: FileLis
|
||||||
dispatch({ type: ACTIONS.DO_PREPARE_EDIT, data: publishData });
|
dispatch({ type: ACTIONS.DO_PREPARE_EDIT, data: publishData });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const publishSuccess = successResponse => {
|
||||||
|
const state = store.getState();
|
||||||
|
analytics.apiLogPublish();
|
||||||
|
const myClaims = selectMyClaimsWithoutChannels(state);
|
||||||
|
const pendingClaim = successResponse.outputs[0];
|
||||||
|
const uri = pendingClaim.permanent_url;
|
||||||
|
const actions = [];
|
||||||
|
|
||||||
|
actions.push({
|
||||||
|
type: ACTIONS.PUBLISH_SUCCESS,
|
||||||
|
});
|
||||||
|
|
||||||
|
// We have to fake a temp claim until the new pending one is returned by claim_list_mine
|
||||||
|
// We can't rely on claim_list_mine because there might be some delay before the new claims are returned
|
||||||
|
// Doing this allows us to show the pending claim immediately, it will get overwritten by the real one
|
||||||
|
const isMatch = claim => claim.claim_id === pendingClaim.claim_id;
|
||||||
|
const isEdit = myClaims.some(isMatch);
|
||||||
|
|
||||||
|
const myNewClaims = isEdit
|
||||||
|
? myClaims.map(claim => (isMatch(claim) ? pendingClaim : claim))
|
||||||
|
: myClaims.concat(pendingClaim);
|
||||||
|
|
||||||
|
actions.push(doOpenModal(MODALS.PUBLISH, { uri, isEdit }));
|
||||||
|
|
||||||
|
actions.push({
|
||||||
|
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
||||||
|
data: {
|
||||||
|
claims: myNewClaims,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
store.dispatch(batchActions(...actions));
|
||||||
|
};
|
||||||
|
|
||||||
|
const publishFail = error => {
|
||||||
|
store.dispatch({ type: ACTIONS.PUBLISH_FAIL });
|
||||||
|
store.dispatch(doError(error.message));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const doPublishDesktop = (publishSuccess, publishFail) => {
|
||||||
|
doPublish(publishSuccess, publishFail);
|
||||||
|
};
|
||||||
|
|
||||||
export const doPublish = () => (dispatch: Dispatch, getState: () => {}) => {
|
export const doPublish = () => (dispatch: Dispatch, getState: () => {}) => {
|
||||||
dispatch({ type: ACTIONS.PUBLISH_START });
|
dispatch({ type: ACTIONS.PUBLISH_START });
|
||||||
|
|
||||||
|
@ -252,17 +299,20 @@ export const doPublish = () => (dispatch: Dispatch, getState: () => {}) => {
|
||||||
|
|
||||||
const publishPayload: {
|
const publishPayload: {
|
||||||
name: ?string,
|
name: ?string,
|
||||||
channel_id?: string,
|
|
||||||
bid: number,
|
bid: number,
|
||||||
|
description?: string,
|
||||||
|
channel_id?: string,
|
||||||
file_path?: string,
|
file_path?: string,
|
||||||
tags: Array<string>,
|
|
||||||
locations?: Array<Location>,
|
|
||||||
license_url?: string,
|
license_url?: string,
|
||||||
license?: string,
|
license?: string,
|
||||||
thumbnail_url?: string,
|
thumbnail_url?: string,
|
||||||
release_time?: number,
|
release_time?: number,
|
||||||
fee_currency?: string,
|
fee_currency?: string,
|
||||||
fee_amount?: string,
|
fee_amount?: string,
|
||||||
|
tags: Array<string>,
|
||||||
|
locations?: Array<Location>,
|
||||||
|
languages?: Array<string>,
|
||||||
} = {
|
} = {
|
||||||
name,
|
name,
|
||||||
title,
|
title,
|
||||||
|
|
|
@ -1,107 +1,107 @@
|
||||||
// @flow
|
// // @flow
|
||||||
import { handleActions } from 'util/redux-utils';
|
// import { handleActions } from 'util/redux-utils';
|
||||||
import { buildURI } from 'lbry-redux';
|
// import { buildURI } from 'lbry-redux';
|
||||||
import * as ACTIONS from 'constants/action_types';
|
// import * as ACTIONS from 'constants/action_types';
|
||||||
import * as THUMBNAIL_STATUSES from 'constants/thumbnail_upload_statuses';
|
// import * as THUMBNAIL_STATUSES from 'constants/thumbnail_upload_statuses';
|
||||||
import { CHANNEL_ANONYMOUS } from 'constants/claim';
|
// import { CHANNEL_ANONYMOUS } from 'constants/claim';
|
||||||
|
//
|
||||||
type PublishState = {
|
// type PublishState = {
|
||||||
editingURI: ?string,
|
// editingURI: ?string,
|
||||||
filePath: ?string,
|
// filePath: ?string,
|
||||||
contentIsFree: boolean,
|
// contentIsFree: boolean,
|
||||||
fee: {
|
// fee: {
|
||||||
amount: number,
|
// amount: number,
|
||||||
currency: string,
|
// currency: string,
|
||||||
},
|
// },
|
||||||
title: string,
|
// title: string,
|
||||||
thumbnail_url: string,
|
// thumbnail_url: string,
|
||||||
thumbnailPath: string,
|
// thumbnailPath: string,
|
||||||
uploadThumbnailStatus: string,
|
// uploadThumbnailStatus: string,
|
||||||
description: string,
|
// description: string,
|
||||||
language: string,
|
// language: string,
|
||||||
channel: string,
|
// channel: string,
|
||||||
channelId: ?string,
|
// channelId: ?string,
|
||||||
name: string,
|
// name: string,
|
||||||
nameError: ?string,
|
// nameError: ?string,
|
||||||
bid: number,
|
// bid: number,
|
||||||
bidError: ?string,
|
// bidError: ?string,
|
||||||
otherLicenseDescription: string,
|
// otherLicenseDescription: string,
|
||||||
licenseUrl: string,
|
// licenseUrl: string,
|
||||||
tags: Array<string>,
|
// tags: Array<string>,
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
const defaultState: PublishState = {
|
// const defaultState: PublishState = {
|
||||||
editingURI: undefined,
|
// editingURI: undefined,
|
||||||
filePath: undefined,
|
// filePath: undefined,
|
||||||
contentIsFree: true,
|
// contentIsFree: true,
|
||||||
fee: {
|
// fee: {
|
||||||
amount: 1,
|
// amount: 1,
|
||||||
currency: 'LBC',
|
// currency: 'LBC',
|
||||||
},
|
// },
|
||||||
title: '',
|
// title: '',
|
||||||
thumbnail_url: '',
|
// thumbnail_url: '',
|
||||||
thumbnailPath: '',
|
// thumbnailPath: '',
|
||||||
uploadThumbnailStatus: THUMBNAIL_STATUSES.API_DOWN,
|
// uploadThumbnailStatus: THUMBNAIL_STATUSES.API_DOWN,
|
||||||
description: '',
|
// description: '',
|
||||||
language: 'en',
|
// language: 'en',
|
||||||
nsfw: false,
|
// nsfw: false,
|
||||||
channel: CHANNEL_ANONYMOUS,
|
// channel: CHANNEL_ANONYMOUS,
|
||||||
channelId: '',
|
// channelId: '',
|
||||||
name: '',
|
// name: '',
|
||||||
nameError: undefined,
|
// nameError: undefined,
|
||||||
bid: 0.1,
|
// bid: 0.1,
|
||||||
bidError: undefined,
|
// bidError: undefined,
|
||||||
licenseType: 'None',
|
// licenseType: 'None',
|
||||||
otherLicenseDescription: 'All rights reserved',
|
// otherLicenseDescription: 'All rights reserved',
|
||||||
licenseUrl: '',
|
// licenseUrl: '',
|
||||||
tags: [],
|
// tags: [],
|
||||||
publishing: false,
|
// publishing: false,
|
||||||
publishSuccess: false,
|
// publishSuccess: false,
|
||||||
publishError: undefined,
|
// publishError: undefined,
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
export default handleActions(
|
// export default handleActions(
|
||||||
{
|
// {
|
||||||
[ACTIONS.UPDATE_PUBLISH_FORM]: (state, action): PublishState => {
|
// [ACTIONS.UPDATE_PUBLISH_FORM]: (state, action): PublishState => {
|
||||||
const { data } = action;
|
// const { data } = action;
|
||||||
return {
|
// return {
|
||||||
...state,
|
// ...state,
|
||||||
...data,
|
// ...data,
|
||||||
};
|
// };
|
||||||
},
|
// },
|
||||||
[ACTIONS.CLEAR_PUBLISH]: (): PublishState => ({
|
// [ACTIONS.CLEAR_PUBLISH]: (): PublishState => ({
|
||||||
...defaultState,
|
// ...defaultState,
|
||||||
}),
|
// }),
|
||||||
[ACTIONS.PUBLISH_START]: (state: PublishState): PublishState => ({
|
// [ACTIONS.PUBLISH_START]: (state: PublishState): PublishState => ({
|
||||||
...state,
|
// ...state,
|
||||||
publishing: true,
|
// publishing: true,
|
||||||
}),
|
// }),
|
||||||
[ACTIONS.PUBLISH_FAIL]: (state: PublishState): PublishState => ({
|
// [ACTIONS.PUBLISH_FAIL]: (state: PublishState): PublishState => ({
|
||||||
...state,
|
// ...state,
|
||||||
publishing: false,
|
// publishing: false,
|
||||||
}),
|
// }),
|
||||||
[ACTIONS.PUBLISH_SUCCESS]: (state: PublishState): PublishState => ({
|
// [ACTIONS.PUBLISH_SUCCESS]: (state: PublishState): PublishState => ({
|
||||||
...state,
|
// ...state,
|
||||||
publishing: false,
|
// publishing: false,
|
||||||
}),
|
// }),
|
||||||
[ACTIONS.DO_PREPARE_EDIT]: (state: PublishState, action) => {
|
// [ACTIONS.DO_PREPARE_EDIT]: (state: PublishState, action) => {
|
||||||
const { ...publishData } = action.data;
|
// const { ...publishData } = action.data;
|
||||||
const { channel, name, uri } = publishData;
|
// const { channel, name, uri } = publishData;
|
||||||
|
//
|
||||||
// The short uri is what is presented to the user
|
// // The short uri is what is presented to the user
|
||||||
// The editingUri is the full uri with claim id
|
// // The editingUri is the full uri with claim id
|
||||||
const shortUri = buildURI({
|
// const shortUri = buildURI({
|
||||||
channelName: channel,
|
// channelName: channel,
|
||||||
contentName: name,
|
// contentName: name,
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
return {
|
// return {
|
||||||
...defaultState,
|
// ...defaultState,
|
||||||
...publishData,
|
// ...publishData,
|
||||||
editingURI: uri,
|
// editingURI: uri,
|
||||||
uri: shortUri,
|
// uri: shortUri,
|
||||||
};
|
// };
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
defaultState
|
// defaultState
|
||||||
);
|
// );
|
||||||
|
|
Loading…
Reference in a new issue