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

42 lines
1.5 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import {
makeSelectClaimIsMine,
makeSelectFileInfoForUri,
makeSelectClaimForUri,
doPrepareEdit,
selectMyChannelClaims,
} from 'lbry-redux';
2019-03-12 15:53:55 -04:00
import { makeSelectCostInfoForUri } from 'lbryinc';
import { doSetPlayingUri } from 'redux/actions/content';
import { doToast } from 'redux/actions/notifications';
2021-02-15 11:58:04 -05:00
import { doOpenModal, doSetActiveChannel, doSetIncognito } from 'redux/actions/app';
2020-01-06 13:32:35 -05:00
import fs from 'fs';
import FileActions from './view';
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
2017-09-07 23:15:05 -04:00
const select = (state, props) => ({
2020-01-06 13:32:35 -05:00
claim: makeSelectClaimForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
2017-09-07 23:15:05 -04:00
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
2017-09-07 23:15:05 -04:00
costInfo: makeSelectCostInfoForUri(props.uri)(state),
myChannels: selectMyChannelClaims(state),
2017-09-07 23:15:05 -04:00
});
2021-02-15 11:58:04 -05:00
const perform = (dispatch) => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
2021-02-15 11:58:04 -05:00
prepareEdit: (publishData, uri, fileInfo) => {
if (publishData.signing_channel) {
dispatch(doSetActiveChannel(publishData.signing_channel.claim_id));
} else {
dispatch(doSetIncognito(true));
}
dispatch(doPrepareEdit(publishData, uri, fileInfo, fs));
},
2020-12-21 10:31:34 -05:00
clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
2021-02-15 11:58:04 -05:00
doToast: (options) => dispatch(doToast(options)),
2017-06-05 21:21:55 -07:00
});
export default connect(select, perform)(FileActions);