diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 21f2290..8b4e319 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -106,6 +106,9 @@ const CREATE_CHANNEL_FAILED = 'CREATE_CHANNEL_FAILED'; const UPDATE_CHANNEL_STARTED = 'UPDATE_CHANNEL_STARTED'; const UPDATE_CHANNEL_COMPLETED = 'UPDATE_CHANNEL_COMPLETED'; const UPDATE_CHANNEL_FAILED = 'UPDATE_CHANNEL_FAILED'; +const IMPORT_CHANNEL_STARTED = 'IMPORT_CHANNEL_STARTED'; +const IMPORT_CHANNEL_COMPLETED = 'IMPORT_CHANNEL_COMPLETED'; +const IMPORT_CHANNEL_FAILED = 'IMPORT_CHANNEL_FAILED'; const PUBLISH_STARTED = 'PUBLISH_STARTED'; const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED'; const PUBLISH_FAILED = 'PUBLISH_FAILED'; @@ -342,6 +345,9 @@ var action_types = /*#__PURE__*/Object.freeze({ UPDATE_CHANNEL_STARTED: UPDATE_CHANNEL_STARTED, UPDATE_CHANNEL_COMPLETED: UPDATE_CHANNEL_COMPLETED, UPDATE_CHANNEL_FAILED: UPDATE_CHANNEL_FAILED, + IMPORT_CHANNEL_STARTED: IMPORT_CHANNEL_STARTED, + IMPORT_CHANNEL_COMPLETED: IMPORT_CHANNEL_COMPLETED, + IMPORT_CHANNEL_FAILED: IMPORT_CHANNEL_FAILED, PUBLISH_STARTED: PUBLISH_STARTED, PUBLISH_COMPLETED: PUBLISH_COMPLETED, PUBLISH_FAILED: PUBLISH_FAILED, @@ -734,6 +740,7 @@ const Lbry = { claim_list: params => daemonCallWithResult('claim_list', params), channel_create: params => daemonCallWithResult('channel_create', params), channel_update: params => daemonCallWithResult('channel_update', params), + channel_import: params => daemonCallWithResult('channel_import', params), channel_list: params => daemonCallWithResult('channel_list', params), stream_abandon: params => daemonCallWithResult('stream_abandon', params), channel_abandon: params => daemonCallWithResult('channel_abandon', params), @@ -1050,6 +1057,18 @@ function buildURI(UrlObj, includeProto = true, protoDefault = 'lbry://') { deprecatedParts = _objectWithoutProperties(UrlObj, ['streamName', 'streamClaimId', 'channelName', 'channelClaimId', 'primaryClaimSequence', 'primaryBidPosition', 'secondaryClaimSequence', 'secondaryBidPosition']); const { claimId, claimName, contentName } = deprecatedParts; + { + if (claimId) { + console.error(__("'claimId' should no longer be used. Use 'streamClaimId' or 'channelClaimId' instead")); + } + if (claimName) { + console.error(__("'claimName' should no longer be used. Use 'streamClaimName' or 'channelClaimName' instead")); + } + if (contentName) { + console.error(__("'contentName' should no longer be used. Use 'streamName' instead")); + } + } + if (!claimName && !channelName && !streamName) { console.error(__("'claimName', 'channelName', and 'streamName' are all empty. One must be present to build a url.")); } @@ -1686,6 +1705,8 @@ const selectMyChannelClaims = reselect.createSelector(selectState$2, selectClaim const selectResolvingUris = reselect.createSelector(selectState$2, state => state.resolvingUris || []); +const selectChannelImportPending = reselect.createSelector(selectState$2, state => state.pendingChannelImport); + const makeSelectIsUriResolving = uri => reselect.createSelector(selectResolvingUris, resolvingUris => resolvingUris && resolvingUris.indexOf(uri) !== -1); const selectPlayingUri = reselect.createSelector(selectState$2, state => state.playingUri); @@ -2502,6 +2523,27 @@ function doUpdateChannel(params) { }; } +function doImportChannel(id, certificate) { + return dispatch => { + dispatch({ + type: IMPORT_CHANNEL_STARTED, + data: id + }); + + return lbryProxy.channel_import({ channel_data: certificate }).then(result => { + dispatch({ + type: IMPORT_CHANNEL_COMPLETED, + data: { result } // "Added channel signing key for @name." + }); + }).catch(error => { + dispatch({ + type: IMPORT_CHANNEL_FAILED, + data: error + }); + }); + }; +} + function doFetchChannelListMine() { return dispatch => { dispatch({ @@ -3598,7 +3640,8 @@ const defaultState = { updateChannelError: '', updatingChannel: false, creatingChannel: false, - createChannelError: undefined + createChannelError: undefined, + pendingChannelImport: false }; function handleClaimAction(state, action) { @@ -3877,6 +3920,13 @@ reducers[UPDATE_CHANNEL_FAILED] = (state, action) => { }); }; +reducers[IMPORT_CHANNEL_STARTED] = (state, action) => { + const channelId = action.data.id; + return Object.assign({}, state, { pendingChannelImports: channelId }); +}; + +reducers[IMPORT_CHANNEL_COMPLETED] = state => Object.assign({}, state, { pendingChannelImports: false }); + reducers[CLAIM_SEARCH_STARTED] = (state, action) => { const fetchingClaimSearchByQuery = Object.assign({}, state.fetchingClaimSearchByQuery); fetchingClaimSearchByQuery[action.data.query] = true; @@ -4961,6 +5011,7 @@ exports.doFileGet = doFileGet; exports.doFileList = doFileList; exports.doFocusSearchInput = doFocusSearchInput; exports.doGetNewAddress = doGetNewAddress; +exports.doImportChannel = doImportChannel; exports.doPopulateSharedUserState = doPopulateSharedUserState; exports.doPrepareEdit = doPrepareEdit; exports.doPublish = doPublish; @@ -5061,6 +5112,7 @@ exports.selectBlockedChannels = selectBlockedChannels; exports.selectBlockedChannelsCount = selectBlockedChannelsCount; exports.selectBlocks = selectBlocks; exports.selectChannelClaimCounts = selectChannelClaimCounts; +exports.selectChannelImportPending = selectChannelImportPending; exports.selectChannelIsBlocked = selectChannelIsBlocked; exports.selectClaimSearchByQuery = selectClaimSearchByQuery; exports.selectClaimSearchByQueryLastPageReached = selectClaimSearchByQueryLastPageReached; diff --git a/dist/flow-typed/Lbry.js b/dist/flow-typed/Lbry.js index 73dff71..a6adaca 100644 --- a/dist/flow-typed/Lbry.js +++ b/dist/flow-typed/Lbry.js @@ -190,6 +190,7 @@ declare type LbryTypes = { claim_list: (params?: {}) => Promise, channel_create: (params: {}) => Promise, channel_update: (params: {}) => Promise, + channel_import: (params: {}) => Promise, channel_list: () => Promise, stream_abandon: (params: {}) => Promise, channel_abandon: (params: {}) => Promise, diff --git a/flow-typed/Lbry.js b/flow-typed/Lbry.js index 73dff71..a6adaca 100644 --- a/flow-typed/Lbry.js +++ b/flow-typed/Lbry.js @@ -190,6 +190,7 @@ declare type LbryTypes = { claim_list: (params?: {}) => Promise, channel_create: (params: {}) => Promise, channel_update: (params: {}) => Promise, + channel_import: (params: {}) => Promise, channel_list: () => Promise, stream_abandon: (params: {}) => Promise, channel_abandon: (params: {}) => Promise, diff --git a/src/constants/action_types.js b/src/constants/action_types.js index a852537..a52c756 100644 --- a/src/constants/action_types.js +++ b/src/constants/action_types.js @@ -83,6 +83,9 @@ export const CREATE_CHANNEL_FAILED = 'CREATE_CHANNEL_FAILED'; export const UPDATE_CHANNEL_STARTED = 'UPDATE_CHANNEL_STARTED'; export const UPDATE_CHANNEL_COMPLETED = 'UPDATE_CHANNEL_COMPLETED'; export const UPDATE_CHANNEL_FAILED = 'UPDATE_CHANNEL_FAILED'; +export const IMPORT_CHANNEL_STARTED = 'IMPORT_CHANNEL_STARTED'; +export const IMPORT_CHANNEL_COMPLETED = 'IMPORT_CHANNEL_COMPLETED'; +export const IMPORT_CHANNEL_FAILED = 'IMPORT_CHANNEL_FAILED'; export const PUBLISH_STARTED = 'PUBLISH_STARTED'; export const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED'; export const PUBLISH_FAILED = 'PUBLISH_FAILED'; diff --git a/src/index.js b/src/index.js index 3dc3abe..c26402b 100644 --- a/src/index.js +++ b/src/index.js @@ -55,6 +55,7 @@ export { doCreateChannel, doUpdateChannel, doClaimSearch, + doImportChannel, } from 'redux/actions/claims'; export { doDeletePurchasedUri, doPurchaseUri, doFileGet } from 'redux/actions/file'; @@ -206,6 +207,7 @@ export { selectUpdateChannelError, selectCreatingChannel, selectCreateChannelError, + selectChannelImportPending, } from 'redux/selectors/claims'; export { makeSelectCommentsForUri } from 'redux/selectors/comments'; diff --git a/src/lbry.js b/src/lbry.js index ba47709..4854c75 100644 --- a/src/lbry.js +++ b/src/lbry.js @@ -79,6 +79,7 @@ const Lbry: LbryTypes = { claim_list: params => daemonCallWithResult('claim_list', params), channel_create: params => daemonCallWithResult('channel_create', params), channel_update: params => daemonCallWithResult('channel_update', params), + channel_import: params => daemonCallWithResult('channel_import', params), channel_list: params => daemonCallWithResult('channel_list', params), stream_abandon: params => daemonCallWithResult('stream_abandon', params), channel_abandon: params => daemonCallWithResult('channel_abandon', params), diff --git a/src/redux/actions/claims.js b/src/redux/actions/claims.js index 215daba..8bd6318 100644 --- a/src/redux/actions/claims.js +++ b/src/redux/actions/claims.js @@ -323,6 +323,29 @@ export function doUpdateChannel(params: any) { }; } +export function doImportChannel(id: string, certificate: string) { + return (dispatch: Dispatch) => { + dispatch({ + type: ACTIONS.IMPORT_CHANNEL_STARTED, + data: id, + }); + + return Lbry.channel_import({ channel_data: certificate }) + .then((result: string) => { + dispatch({ + type: ACTIONS.IMPORT_CHANNEL_COMPLETED, + data: { result }, // "Added channel signing key for @name." + }); + }) + .catch(error => { + dispatch({ + type: ACTIONS.IMPORT_CHANNEL_FAILED, + data: error, + }); + }); + }; +} + export function doFetchChannelListMine() { return (dispatch: Dispatch) => { dispatch({ diff --git a/src/redux/reducers/claims.js b/src/redux/reducers/claims.js index cdac7d9..f160509 100644 --- a/src/redux/reducers/claims.js +++ b/src/redux/reducers/claims.js @@ -34,6 +34,7 @@ type State = { }, updateChannelError: string, updatingChannel: boolean, + pendingChannelImport: string | boolean, }; const reducers = {}; @@ -58,6 +59,7 @@ const defaultState = { updatingChannel: false, creatingChannel: false, createChannelError: undefined, + pendingChannelImport: false, }; function handleClaimAction(state: State, action: any): State { @@ -348,6 +350,14 @@ reducers[ACTIONS.UPDATE_CHANNEL_FAILED] = (state: State, action: any): State => }); }; +reducers[ACTIONS.IMPORT_CHANNEL_STARTED] = (state: State, action: any): State => { + const channelId: string = action.data.id; + return Object.assign({}, state, { pendingChannelImports: channelId }); +}; + +reducers[ACTIONS.IMPORT_CHANNEL_COMPLETED] = (state: State): State => + Object.assign({}, state, { pendingChannelImports: false }); + reducers[ACTIONS.CLAIM_SEARCH_STARTED] = (state: State, action: any): State => { const fetchingClaimSearchByQuery = Object.assign({}, state.fetchingClaimSearchByQuery); fetchingClaimSearchByQuery[action.data.query] = true; diff --git a/src/redux/selectors/claims.js b/src/redux/selectors/claims.js index 7cff061..723f8d3 100644 --- a/src/redux/selectors/claims.js +++ b/src/redux/selectors/claims.js @@ -240,8 +240,8 @@ export const makeSelectDateForUri = (uri: string) => (claim.value.release_time ? claim.value.release_time * 1000 : claim.meta && claim.meta.creation_timestamp - ? claim.meta.creation_timestamp * 1000 - : null); + ? claim.meta.creation_timestamp * 1000 + : null); if (!timestamp) { return undefined; } @@ -382,6 +382,11 @@ export const selectResolvingUris = createSelector( state => state.resolvingUris || [] ); +export const selectChannelImportPending = createSelector( + selectState, + state => state.pendingChannelImport +); + export const makeSelectIsUriResolving = (uri: string) => createSelector( selectResolvingUris,