2019-06-28 09:27:55 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import {
|
2019-07-03 04:30:34 +02:00
|
|
|
doResolveUri,
|
2019-06-28 09:27:55 +02:00
|
|
|
selectPublishFormValues,
|
|
|
|
selectIsStillEditing,
|
|
|
|
selectMyClaimForUri,
|
|
|
|
selectIsResolvingPublishUris,
|
|
|
|
selectTakeOverAmount,
|
|
|
|
doResetThumbnailStatus,
|
|
|
|
doClearPublish,
|
|
|
|
doUpdatePublishForm,
|
|
|
|
doPrepareEdit,
|
2020-04-24 15:51:00 +02:00
|
|
|
doCheckPublishNameAvailability,
|
2020-08-11 11:54:09 +02:00
|
|
|
SETTINGS,
|
2021-03-30 07:03:31 +02:00
|
|
|
selectMyChannelClaims,
|
|
|
|
makeSelectClaimIsStreamPlaceholder,
|
2021-04-13 18:07:51 +02:00
|
|
|
makeSelectPublishFormValue,
|
2019-07-03 04:30:34 +02:00
|
|
|
} from 'lbry-redux';
|
2021-03-30 07:03:31 +02:00
|
|
|
import * as RENDER_MODES from 'constants/file_render_modes';
|
2019-07-12 16:58:24 +02:00
|
|
|
import { doPublishDesktop } from 'redux/actions/publish';
|
2020-06-15 22:33:03 +02:00
|
|
|
import { selectUnclaimedRewardValue } from 'redux/selectors/rewards';
|
2021-04-08 21:19:14 +02:00
|
|
|
import {
|
|
|
|
selectModal,
|
|
|
|
selectActiveChannelClaim,
|
|
|
|
selectIncognito,
|
|
|
|
selectActiveChannelStakedLevel,
|
|
|
|
} from 'redux/selectors/app';
|
2020-08-11 11:54:09 +02:00
|
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
2021-03-30 07:03:31 +02:00
|
|
|
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
|
2019-06-28 09:27:55 +02:00
|
|
|
import PublishPage from './view';
|
2021-03-26 22:03:52 +01:00
|
|
|
import { selectUser } from 'redux/selectors/user';
|
2017-06-30 10:45:54 +02:00
|
|
|
|
2021-03-30 07:03:31 +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),
|
|
|
|
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(permanentUrl)(state),
|
|
|
|
isPostClaim,
|
|
|
|
permanentUrl,
|
|
|
|
// My previously published claims under this short lbry uri
|
|
|
|
// 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
|
|
|
|
myClaimForUri,
|
2021-04-13 18:07:51 +02:00
|
|
|
filePath: makeSelectPublishFormValue('filePath')(state),
|
|
|
|
remoteUrl: makeSelectPublishFormValue('remoteFileUrl')(state),
|
2021-03-30 07:03:31 +02:00
|
|
|
isStillEditing: selectIsStillEditing(state),
|
|
|
|
isResolvingUri: selectIsResolvingPublishUris(state),
|
|
|
|
totalRewardValue: selectUnclaimedRewardValue(state),
|
|
|
|
modal: selectModal(state),
|
|
|
|
enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state),
|
|
|
|
activeChannelClaim: selectActiveChannelClaim(state),
|
|
|
|
myChannels: selectMyChannelClaims(state),
|
|
|
|
incognito: selectIncognito(state),
|
|
|
|
};
|
|
|
|
};
|
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)),
|
2019-06-28 09:27:55 +02:00
|
|
|
});
|
|
|
|
|
2020-04-24 15:51:00 +02:00
|
|
|
export default connect(select, perform)(PublishPage);
|