Merge pull request #159 from lbryio/channelUpdate

Channel update
This commit is contained in:
Sean Yesmunt 2019-07-02 13:48:28 -04:00 committed by GitHub
commit efccab44cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 131 additions and 10 deletions

56
dist/bundle.es.js vendored
View file

@ -103,6 +103,9 @@ const FETCH_CHANNEL_LIST_COMPLETED = 'FETCH_CHANNEL_LIST_COMPLETED';
const CREATE_CHANNEL_STARTED = 'CREATE_CHANNEL_STARTED'; const CREATE_CHANNEL_STARTED = 'CREATE_CHANNEL_STARTED';
const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED'; const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED';
const CREATE_CHANNEL_FAILED = 'CREATE_CHANNEL_FAILED'; 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 PUBLISH_STARTED = 'PUBLISH_STARTED'; const PUBLISH_STARTED = 'PUBLISH_STARTED';
const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED'; const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED';
const PUBLISH_FAILED = 'PUBLISH_FAILED'; const PUBLISH_FAILED = 'PUBLISH_FAILED';
@ -328,6 +331,9 @@ var action_types = /*#__PURE__*/Object.freeze({
CREATE_CHANNEL_STARTED: CREATE_CHANNEL_STARTED, CREATE_CHANNEL_STARTED: CREATE_CHANNEL_STARTED,
CREATE_CHANNEL_COMPLETED: CREATE_CHANNEL_COMPLETED, CREATE_CHANNEL_COMPLETED: CREATE_CHANNEL_COMPLETED,
CREATE_CHANNEL_FAILED: CREATE_CHANNEL_FAILED, CREATE_CHANNEL_FAILED: CREATE_CHANNEL_FAILED,
UPDATE_CHANNEL_STARTED: UPDATE_CHANNEL_STARTED,
UPDATE_CHANNEL_COMPLETED: UPDATE_CHANNEL_COMPLETED,
UPDATE_CHANNEL_FAILED: UPDATE_CHANNEL_FAILED,
PUBLISH_STARTED: PUBLISH_STARTED, PUBLISH_STARTED: PUBLISH_STARTED,
PUBLISH_COMPLETED: PUBLISH_COMPLETED, PUBLISH_COMPLETED: PUBLISH_COMPLETED,
PUBLISH_FAILED: PUBLISH_FAILED, PUBLISH_FAILED: PUBLISH_FAILED,
@ -707,6 +713,7 @@ const Lbry = {
claim_search: params => daemonCallWithResult('claim_search', params), claim_search: params => daemonCallWithResult('claim_search', params),
claim_list: params => daemonCallWithResult('claim_list', params), claim_list: params => daemonCallWithResult('claim_list', params),
channel_create: params => daemonCallWithResult('channel_create', params), channel_create: params => daemonCallWithResult('channel_create', params),
channel_update: params => daemonCallWithResult('channel_update', params),
channel_list: params => daemonCallWithResult('channel_list', params), channel_list: params => daemonCallWithResult('channel_list', params),
stream_abandon: params => daemonCallWithResult('stream_abandon', params), stream_abandon: params => daemonCallWithResult('stream_abandon', params),
channel_abandon: params => daemonCallWithResult('channel_abandon', params), channel_abandon: params => daemonCallWithResult('channel_abandon', params),
@ -1334,6 +1341,10 @@ const makeSelectDateForUri = uri => reselect.createSelector(makeSelectClaimForUr
return dateObj; return dateObj;
}); });
const makeSelectAmountForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
return claim && claim.amount;
});
const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => { const makeSelectContentTypeForUri = uri => reselect.createSelector(makeSelectClaimForUri(uri), claim => {
const source = claim && claim.value && claim.value.source; const source = claim && claim.value && claim.value.source;
return source ? source.media_type : undefined; return source ? source.media_type : undefined;
@ -2229,6 +2240,38 @@ function doCreateChannel(name, amount) {
}; };
} }
function doUpdateChannel(params) {
return dispatch => {
dispatch({
type: UPDATE_CHANNEL_STARTED
});
const updateParams = {
claim_id: params.claim_id,
bid: creditsToString(params.amount),
title: params.title,
cover_url: params.cover,
thumbnail_url: params.thumbnail,
description: params.description,
website_url: params.website,
email: params.email,
replace: true
};
return lbryProxy.channel_update(updateParams).then(result => {
const channelClaim = result.outputs[0];
dispatch({
type: UPDATE_CHANNEL_COMPLETED,
data: { channelClaim }
});
}).catch(error => {
dispatch({
type: UPDATE_CHANNEL_FAILED,
data: error
});
});
};
}
function doFetchChannelListMine() { function doFetchChannelListMine() {
return dispatch => { return dispatch => {
dispatch({ dispatch({
@ -3476,6 +3519,17 @@ reducers[CREATE_CHANNEL_COMPLETED] = (state, action) => {
}); });
}; };
reducers[UPDATE_CHANNEL_COMPLETED] = (state, action) => {
const channelClaim = action.data.channelClaim;
const byId = Object.assign({}, state.byId);
byId[channelClaim.claim_id] = channelClaim;
return Object.assign({}, state, {
byId
});
};
reducers[RESOLVE_URIS_STARTED] = (state, action) => { reducers[RESOLVE_URIS_STARTED] = (state, action) => {
const { uris } = action.data; const { uris } = action.data;
@ -4619,6 +4673,7 @@ exports.doToggleTagFollow = doToggleTagFollow;
exports.doTotalBalanceSubscribe = doTotalBalanceSubscribe; exports.doTotalBalanceSubscribe = doTotalBalanceSubscribe;
exports.doUpdateBalance = doUpdateBalance; exports.doUpdateBalance = doUpdateBalance;
exports.doUpdateBlockHeight = doUpdateBlockHeight; exports.doUpdateBlockHeight = doUpdateBlockHeight;
exports.doUpdateChannel = doUpdateChannel;
exports.doUpdatePublishForm = doUpdatePublishForm; exports.doUpdatePublishForm = doUpdatePublishForm;
exports.doUpdateSearchOptions = doUpdateSearchOptions; exports.doUpdateSearchOptions = doUpdateSearchOptions;
exports.doUpdateSearchQuery = doUpdateSearchQuery; exports.doUpdateSearchQuery = doUpdateSearchQuery;
@ -4636,6 +4691,7 @@ exports.isClaimNsfw = isClaimNsfw;
exports.isNameValid = isNameValid; exports.isNameValid = isNameValid;
exports.isURIClaimable = isURIClaimable; exports.isURIClaimable = isURIClaimable;
exports.isURIValid = isURIValid; exports.isURIValid = isURIValid;
exports.makeSelectAmountForUri = makeSelectAmountForUri;
exports.makeSelectChannelForClaimUri = makeSelectChannelForClaimUri; exports.makeSelectChannelForClaimUri = makeSelectChannelForClaimUri;
exports.makeSelectClaimForUri = makeSelectClaimForUri; exports.makeSelectClaimForUri = makeSelectClaimForUri;
exports.makeSelectClaimIsMine = makeSelectClaimIsMine; exports.makeSelectClaimIsMine = makeSelectClaimIsMine;

View file

@ -65,9 +65,7 @@ declare type VersionResponse = {
declare type ResolveResponse = { declare type ResolveResponse = {
// Keys are the url(s) passed to resolve // Keys are the url(s) passed to resolve
[string]: [string]: Claim | { error?: {} },
| Claim
| { error?: {} },
}; };
declare type GetResponse = FileListItem; declare type GetResponse = FileListItem;
@ -105,6 +103,10 @@ declare type ChannelCreateResponse = GenericTxResponse & {
outputs: Array<ChannelClaim>, outputs: Array<ChannelClaim>,
}; };
declare type UpdateChannelResponse = GenericTxResponse & {
outputs: Array<ChannelClaim>,
};
declare type CommentCreateResponse = Comment; declare type CommentCreateResponse = Comment;
declare type CommentListResponse = Array<Comment>; declare type CommentListResponse = Array<Comment>;
@ -160,7 +162,7 @@ declare type LbryTypes = {
apiRequestHeaders: { [key: string]: string }, apiRequestHeaders: { [key: string]: string },
setDaemonConnectionString: string => void, setDaemonConnectionString: string => void,
setApiHeader: (string, string) => void, setApiHeader: (string, string) => void,
unsetApiHeader: (string) => void, unsetApiHeader: string => void,
overrides: { [string]: ?Function }, overrides: { [string]: ?Function },
setOverride: (string, Function) => void, setOverride: (string, Function) => void,
getMediaType: (string, ?string) => string, getMediaType: (string, ?string) => string,
@ -176,6 +178,7 @@ declare type LbryTypes = {
claim_search: (params: {}) => Promise<ClaimSearchResponse>, claim_search: (params: {}) => Promise<ClaimSearchResponse>,
claim_list: (params?: {}) => Promise<ClaimListResponse>, claim_list: (params?: {}) => Promise<ClaimListResponse>,
channel_create: (params: {}) => Promise<ChannelCreateResponse>, channel_create: (params: {}) => Promise<ChannelCreateResponse>,
channel_update: (params: {}) => Promise<UpdateChannelResponse>,
channel_list: () => Promise<ChannelListResponse>, channel_list: () => Promise<ChannelListResponse>,
stream_abandon: (params: {}) => Promise<GenericTxResponse>, stream_abandon: (params: {}) => Promise<GenericTxResponse>,
channel_abandon: (params: {}) => Promise<GenericTxResponse>, channel_abandon: (params: {}) => Promise<GenericTxResponse>,

11
flow-typed/Lbry.js vendored
View file

@ -65,9 +65,7 @@ declare type VersionResponse = {
declare type ResolveResponse = { declare type ResolveResponse = {
// Keys are the url(s) passed to resolve // Keys are the url(s) passed to resolve
[string]: [string]: Claim | { error?: {} },
| Claim
| { error?: {} },
}; };
declare type GetResponse = FileListItem; declare type GetResponse = FileListItem;
@ -105,6 +103,10 @@ declare type ChannelCreateResponse = GenericTxResponse & {
outputs: Array<ChannelClaim>, outputs: Array<ChannelClaim>,
}; };
declare type ChannelUpdateResponse = GenericTxResponse & {
outputs: Array<ChannelClaim>,
};
declare type CommentCreateResponse = Comment; declare type CommentCreateResponse = Comment;
declare type CommentListResponse = Array<Comment>; declare type CommentListResponse = Array<Comment>;
@ -160,7 +162,7 @@ declare type LbryTypes = {
apiRequestHeaders: { [key: string]: string }, apiRequestHeaders: { [key: string]: string },
setDaemonConnectionString: string => void, setDaemonConnectionString: string => void,
setApiHeader: (string, string) => void, setApiHeader: (string, string) => void,
unsetApiHeader: (string) => void, unsetApiHeader: string => void,
overrides: { [string]: ?Function }, overrides: { [string]: ?Function },
setOverride: (string, Function) => void, setOverride: (string, Function) => void,
getMediaType: (string, ?string) => string, getMediaType: (string, ?string) => string,
@ -176,6 +178,7 @@ declare type LbryTypes = {
claim_search: (params: {}) => Promise<ClaimSearchResponse>, claim_search: (params: {}) => Promise<ClaimSearchResponse>,
claim_list: (params?: {}) => Promise<ClaimListResponse>, claim_list: (params?: {}) => Promise<ClaimListResponse>,
channel_create: (params: {}) => Promise<ChannelCreateResponse>, channel_create: (params: {}) => Promise<ChannelCreateResponse>,
channel_update: (params: {}) => Promise<ChannelUpdateResponse>,
channel_list: () => Promise<ChannelListResponse>, channel_list: () => Promise<ChannelListResponse>,
stream_abandon: (params: {}) => Promise<GenericTxResponse>, stream_abandon: (params: {}) => Promise<GenericTxResponse>,
channel_abandon: (params: {}) => Promise<GenericTxResponse>, channel_abandon: (params: {}) => Promise<GenericTxResponse>,

View file

@ -80,6 +80,9 @@ export const FETCH_CHANNEL_LIST_COMPLETED = 'FETCH_CHANNEL_LIST_COMPLETED';
export const CREATE_CHANNEL_STARTED = 'CREATE_CHANNEL_STARTED'; export const CREATE_CHANNEL_STARTED = 'CREATE_CHANNEL_STARTED';
export const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED'; export const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED';
export const CREATE_CHANNEL_FAILED = 'CREATE_CHANNEL_FAILED'; 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 PUBLISH_STARTED = 'PUBLISH_STARTED'; export const PUBLISH_STARTED = 'PUBLISH_STARTED';
export const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED'; export const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED';
export const PUBLISH_FAILED = 'PUBLISH_FAILED'; export const PUBLISH_FAILED = 'PUBLISH_FAILED';

View file

@ -49,6 +49,7 @@ export {
doResolveUri, doResolveUri,
doFetchChannelListMine, doFetchChannelListMine,
doCreateChannel, doCreateChannel,
doUpdateChannel,
doClaimSearch, doClaimSearch,
} from 'redux/actions/claims'; } from 'redux/actions/claims';
@ -149,6 +150,7 @@ export {
makeSelectCoverForUri, makeSelectCoverForUri,
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectDateForUri, makeSelectDateForUri,
makeSelectAmountForUri,
makeSelectTagsForUri, makeSelectTagsForUri,
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
makeSelectIsUriResolving, makeSelectIsUriResolving,

View file

@ -71,6 +71,7 @@ const Lbry: LbryTypes = {
claim_search: params => daemonCallWithResult('claim_search', params), claim_search: params => daemonCallWithResult('claim_search', params),
claim_list: params => daemonCallWithResult('claim_list', params), claim_list: params => daemonCallWithResult('claim_list', params),
channel_create: params => daemonCallWithResult('channel_create', params), channel_create: params => daemonCallWithResult('channel_create', params),
channel_update: params => daemonCallWithResult('channel_update', params),
channel_list: params => daemonCallWithResult('channel_list', params), channel_list: params => daemonCallWithResult('channel_list', params),
stream_abandon: params => daemonCallWithResult('stream_abandon', params), stream_abandon: params => daemonCallWithResult('stream_abandon', params),
channel_abandon: params => daemonCallWithResult('channel_abandon', params), channel_abandon: params => daemonCallWithResult('channel_abandon', params),

View file

@ -248,6 +248,40 @@ export function doCreateChannel(name: string, amount: number) {
}; };
} }
export function doUpdateChannel(params: any) {
return (dispatch: Dispatch) => {
dispatch({
type: ACTIONS.UPDATE_CHANNEL_STARTED,
});
const updateParams = {
claim_id: params.claim_id,
bid: creditsToString(params.amount),
title: params.title,
cover_url: params.cover,
thumbnail_url: params.thumbnail,
description: params.description,
website_url: params.website,
email: params.email,
replace: true,
};
return Lbry.channel_update(updateParams)
.then((result: ChannelUpdateResponse) => {
const channelClaim = result.outputs[0];
dispatch({
type: ACTIONS.UPDATE_CHANNEL_COMPLETED,
data: { channelClaim },
});
})
.catch(error => {
dispatch({
type: ACTIONS.UPDATE_CHANNEL_FAILED,
data: error,
});
});
};
}
export function doFetchChannelListMine() { export function doFetchChannelListMine() {
return (dispatch: Dispatch) => { return (dispatch: Dispatch) => {
dispatch({ dispatch({

View file

@ -257,6 +257,17 @@ reducers[ACTIONS.CREATE_CHANNEL_COMPLETED] = (state: State, action: any): State
}); });
}; };
reducers[ACTIONS.UPDATE_CHANNEL_COMPLETED] = (state: State, action: any): State => {
const channelClaim: ChannelClaim = action.data.channelClaim;
const byId = Object.assign({}, state.byId);
byId[channelClaim.claim_id] = channelClaim;
return Object.assign({}, state, {
byId,
});
};
reducers[ACTIONS.RESOLVE_URIS_STARTED] = (state: State, action: any): State => { reducers[ACTIONS.RESOLVE_URIS_STARTED] = (state: State, action: any): State => {
const { uris }: { uris: Array<string> } = action.data; const { uris }: { uris: Array<string> } = action.data;

View file

@ -204,6 +204,14 @@ export const makeSelectDateForUri = (uri: string) =>
} }
); );
export const makeSelectAmountForUri = (uri: string) =>
createSelector(
makeSelectClaimForUri(uri),
claim => {
return claim && claim.amount;
}
);
export const makeSelectContentTypeForUri = (uri: string) => export const makeSelectContentTypeForUri = (uri: string) =>
createSelector( createSelector(
makeSelectClaimForUri(uri), makeSelectClaimForUri(uri),