lbry-desktop/ui/component/fileActions/index.js

54 lines
2.1 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import {
selectClaimIsMine,
selectClaimForUri,
selectHasChannels,
2021-03-26 22:03:52 +01:00
makeSelectClaimIsStreamPlaceholder,
makeSelectTagInClaimOrChannelForUri,
} from 'redux/selectors/claims';
import { makeSelectStreamingUrlForUri, makeSelectFileInfoForUri } from 'redux/selectors/file_info';
import { doPrepareEdit } from 'redux/actions/publish';
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
2019-03-12 20:53:55 +01:00
import { makeSelectCostInfoForUri } from 'lbryinc';
import { doSetPlayingUri, doPlayUri } from 'redux/actions/content';
import { doToast } from 'redux/actions/notifications';
import { doOpenModal, doSetActiveChannel, doSetIncognito, doAnalyticsView } from 'redux/actions/app';
2020-01-06 19:32:35 +01:00
import fs from 'fs';
import FileActions from './view';
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
const select = (state, props) => {
const claim = selectClaimForUri(state, props.uri);
return {
claim,
claimIsMine: selectClaimIsMine(state, claim),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
hasChannels: selectHasChannels(state),
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
reactionsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
};
};
2021-02-15 17:58:04 +01:00
const perform = (dispatch) => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
2021-02-15 17:58:04 +01:00
prepareEdit: (publishData, uri, fileInfo) => {
if (publishData.signing_channel) {
dispatch(doSetIncognito(false));
2021-02-15 17:58:04 +01:00
dispatch(doSetActiveChannel(publishData.signing_channel.claim_id));
} else {
dispatch(doSetIncognito(true));
}
dispatch(doPrepareEdit(publishData, uri, fileInfo, fs));
},
2020-12-21 16:31:34 +01:00
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
2021-02-15 17:58:04 +01:00
doToast: (options) => dispatch(doToast(options)),
download: (uri) => dispatch(doPlayUri(uri, false, true, () => dispatch(doAnalyticsView(uri)))),
2017-06-06 06:21:55 +02:00
});
export default connect(select, perform)(FileActions);