adds channelImport

This commit is contained in:
jessop 2019-09-12 15:06:49 -04:00 committed by Sean Yesmunt
parent 4d88d62129
commit 9fd930564e
9 changed files with 101 additions and 3 deletions

54
dist/bundle.es.js vendored
View file

@ -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;

View file

@ -190,6 +190,7 @@ declare type LbryTypes = {
claim_list: (params?: {}) => Promise<ClaimListResponse>,
channel_create: (params: {}) => Promise<ChannelCreateResponse>,
channel_update: (params: {}) => Promise<ChannelUpdateResponse>,
channel_import: (params: {}) => Promise<string>,
channel_list: () => Promise<ChannelListResponse>,
stream_abandon: (params: {}) => Promise<GenericTxResponse>,
channel_abandon: (params: {}) => Promise<GenericTxResponse>,

1
flow-typed/Lbry.js vendored
View file

@ -190,6 +190,7 @@ declare type LbryTypes = {
claim_list: (params?: {}) => Promise<ClaimListResponse>,
channel_create: (params: {}) => Promise<ChannelCreateResponse>,
channel_update: (params: {}) => Promise<ChannelUpdateResponse>,
channel_import: (params: {}) => Promise<string>,
channel_list: () => Promise<ChannelListResponse>,
stream_abandon: (params: {}) => Promise<GenericTxResponse>,
channel_abandon: (params: {}) => Promise<GenericTxResponse>,

View file

@ -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';

View file

@ -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';

View file

@ -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),

View file

@ -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({

View file

@ -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;

View file

@ -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,