2019-06-28 09:27:55 +02:00
|
|
|
import { connect } from 'react-redux';
|
2022-07-11 16:12:37 +02:00
|
|
|
import { doResetThumbnailStatus, doClearPublish, doUpdatePublishForm, doPublishDesktop } from 'redux/actions/publish';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { doResolveUri, doCheckPublishNameAvailability } from 'redux/actions/claims';
|
|
|
|
import {
|
|
|
|
selectPublishFormValues,
|
|
|
|
selectIsStillEditing,
|
2021-04-14 06:06:11 +02:00
|
|
|
makeSelectPublishFormValue,
|
2021-10-17 10:36:14 +02:00
|
|
|
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';
|
2022-03-31 07:06:30 +02:00
|
|
|
import { selectModal, selectActiveChannelClaim, selectIncognito } 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-31 07:06:30 +02:00
|
|
|
import { selectUser } from 'redux/selectors/user';
|
2022-07-11 16:12:37 +02:00
|
|
|
import UploadForm 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
|
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
|
|
|
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),
|
2021-08-18 18:34:24 +02:00
|
|
|
isClaimingInitialRewards: selectIsClaimingInitialRewards(state),
|
|
|
|
hasClaimedInitialRewards: selectHasClaimedInitialRewards(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
|
|
|
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
|
|
|
});
|
|
|
|
|
2022-07-11 16:12:37 +02:00
|
|
|
export default connect(select, perform)(UploadForm);
|