2019-06-28 09:27:55 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import {
|
|
|
|
doResetThumbnailStatus,
|
|
|
|
doClearPublish,
|
|
|
|
doUpdatePublishForm,
|
|
|
|
doPrepareEdit,
|
2021-10-17 10:36:14 +02:00
|
|
|
doPublishDesktop,
|
|
|
|
} from 'redux/actions/publish';
|
|
|
|
import { doResolveUri, doCheckPublishNameAvailability } from 'redux/actions/claims';
|
|
|
|
import {
|
|
|
|
selectTakeOverAmount,
|
|
|
|
selectPublishFormValues,
|
|
|
|
selectIsStillEditing,
|
2021-04-14 06:06:11 +02:00
|
|
|
makeSelectPublishFormValue,
|
2021-10-17 10:36:14 +02:00
|
|
|
selectIsResolvingPublishUris,
|
|
|
|
selectMyClaimForUri,
|
|
|
|
} from 'redux/selectors/publish';
|
2021-11-16 04:52:35 +01:00
|
|
|
import { selectIsStreamPlaceholderForUri } from 'redux/selectors/claims';
|
2021-04-14 06:06:11 +02:00
|
|
|
import * as RENDER_MODES from 'constants/file_render_modes';
|
2021-10-17 10:36:14 +02:00
|
|
|
import * as SETTINGS from 'constants/settings';
|
2021-08-18 18:34:24 +02:00
|
|
|
import { doClaimInitialRewards } from 'redux/actions/rewards';
|
|
|
|
import {
|
|
|
|
selectUnclaimedRewardValue,
|
|
|
|
selectIsClaimingInitialRewards,
|
|
|
|
selectHasClaimedInitialRewards,
|
|
|
|
} from 'redux/selectors/rewards';
|
2021-04-08 21:19:14 +02:00
|
|
|
import {
|
|
|
|
selectModal,
|
|
|
|
selectActiveChannelClaim,
|
|
|
|
selectIncognito,
|
|
|
|
selectActiveChannelStakedLevel,
|
|
|
|
} from 'redux/selectors/app';
|
2021-11-23 05:29:04 +01:00
|
|
|
import { selectClientSetting } from 'redux/selectors/settings';
|
2021-04-14 06:06:11 +02:00
|
|
|
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
|
2022-03-09 19:05:37 +01:00
|
|
|
import { selectUser, selectOdyseeMembershipName } from 'redux/selectors/user';
|
2021-11-08 07:27:14 +01:00
|
|
|
import PublishForm from './view';
|
2017-06-30 10:45:54 +02:00
|
|
|
|
2021-04-14 06:06:11 +02:00
|
|
|
const select = (state) => {
|
|
|
|
const myClaimForUri = selectMyClaimForUri(state);
|
|
|
|
const permanentUrl = (myClaimForUri && myClaimForUri.permanent_url) || '';
|
|
|
|
const isPostClaim = makeSelectFileRenderModeForUri(permanentUrl)(state) === RENDER_MODES.MARKDOWN;
|
|
|
|
|
|
|
|
return {
|
|
|
|
...selectPublishFormValues(state),
|
|
|
|
user: selectUser(state),
|
|
|
|
// The winning claim for a short lbry uri
|
|
|
|
amountNeededForTakeover: selectTakeOverAmount(state),
|
2021-11-16 04:52:35 +01:00
|
|
|
isLivestreamClaim: selectIsStreamPlaceholderForUri(state, permanentUrl),
|
2021-04-14 06:06:11 +02:00
|
|
|
isPostClaim,
|
|
|
|
permanentUrl,
|
|
|
|
// My previously published claims under this short lbry uri
|
|
|
|
myClaimForUri,
|
|
|
|
// If I clicked the "edit" button, have I changed the uri?
|
|
|
|
// Need this to make it easier to find the source on previously published content
|
|
|
|
isStillEditing: selectIsStillEditing(state),
|
|
|
|
filePath: makeSelectPublishFormValue('filePath')(state),
|
|
|
|
remoteUrl: makeSelectPublishFormValue('remoteFileUrl')(state),
|
2021-04-23 18:57:51 +02:00
|
|
|
publishSuccess: makeSelectPublishFormValue('publishSuccess')(state),
|
2021-04-14 06:06:11 +02:00
|
|
|
isResolvingUri: selectIsResolvingPublishUris(state),
|
|
|
|
totalRewardValue: selectUnclaimedRewardValue(state),
|
|
|
|
modal: selectModal(state),
|
2021-11-23 05:29:04 +01:00
|
|
|
enablePublishPreview: selectClientSetting(state, SETTINGS.ENABLE_PUBLISH_PREVIEW),
|
2021-04-14 06:06:11 +02:00
|
|
|
activeChannelClaim: selectActiveChannelClaim(state),
|
|
|
|
incognito: selectIncognito(state),
|
|
|
|
activeChannelStakedLevel: selectActiveChannelStakedLevel(state),
|
2021-08-18 18:34:24 +02:00
|
|
|
isClaimingInitialRewards: selectIsClaimingInitialRewards(state),
|
|
|
|
hasClaimedInitialRewards: selectHasClaimedInitialRewards(state),
|
2022-03-09 19:05:37 +01:00
|
|
|
odyseeMembership: selectOdyseeMembershipName(state),
|
2021-04-14 06:06:11 +02:00
|
|
|
};
|
|
|
|
};
|
2019-06-28 09:27:55 +02:00
|
|
|
|
2021-03-26 22:03:52 +01:00
|
|
|
const perform = (dispatch) => ({
|
|
|
|
updatePublishForm: (value) => dispatch(doUpdatePublishForm(value)),
|
2019-06-28 09:27:55 +02:00
|
|
|
clearPublish: () => dispatch(doClearPublish()),
|
2021-03-26 22:03:52 +01:00
|
|
|
resolveUri: (uri) => dispatch(doResolveUri(uri)),
|
2020-07-31 15:33:49 +02:00
|
|
|
publish: (filePath, preview) => dispatch(doPublishDesktop(filePath, preview)),
|
2019-06-28 09:27:55 +02:00
|
|
|
prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)),
|
|
|
|
resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()),
|
2021-03-26 22:03:52 +01:00
|
|
|
checkAvailability: (name) => dispatch(doCheckPublishNameAvailability(name)),
|
2021-08-18 18:34:24 +02:00
|
|
|
claimInitialRewards: () => dispatch(doClaimInitialRewards()),
|
2019-06-28 09:27:55 +02:00
|
|
|
});
|
|
|
|
|
2021-11-08 07:27:14 +01:00
|
|
|
export default connect(select, perform)(PublishForm);
|