redux for reposts
This commit is contained in:
parent
a640c5cb0b
commit
bd07919a72
9 changed files with 238 additions and 16 deletions
104
dist/bundle.es.js
vendored
104
dist/bundle.es.js
vendored
|
@ -126,6 +126,10 @@ const CLAIM_SEARCH_FAILED = 'CLAIM_SEARCH_FAILED';
|
||||||
const CLAIM_SEARCH_BY_TAGS_STARTED = 'CLAIM_SEARCH_BY_TAGS_STARTED';
|
const CLAIM_SEARCH_BY_TAGS_STARTED = 'CLAIM_SEARCH_BY_TAGS_STARTED';
|
||||||
const CLAIM_SEARCH_BY_TAGS_COMPLETED = 'CLAIM_SEARCH_BY_TAGS_COMPLETED';
|
const CLAIM_SEARCH_BY_TAGS_COMPLETED = 'CLAIM_SEARCH_BY_TAGS_COMPLETED';
|
||||||
const CLAIM_SEARCH_BY_TAGS_FAILED = 'CLAIM_SEARCH_BY_TAGS_FAILED';
|
const CLAIM_SEARCH_BY_TAGS_FAILED = 'CLAIM_SEARCH_BY_TAGS_FAILED';
|
||||||
|
const CLAIM_REPOST_STARTED = 'CLAIM_REPOST_STARTED';
|
||||||
|
const CLAIM_REPOST_COMPLETED = 'CLAIM_REPOST_COMPLETED';
|
||||||
|
const CLAIM_REPOST_FAILED = 'CLAIM_REPOST_FAILED';
|
||||||
|
const CLEAR_REPOST_ERROR = 'CLEAR_REPOST_ERROR';
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
const COMMENT_LIST_STARTED = 'COMMENT_LIST_STARTED';
|
const COMMENT_LIST_STARTED = 'COMMENT_LIST_STARTED';
|
||||||
|
@ -383,6 +387,10 @@ var action_types = /*#__PURE__*/Object.freeze({
|
||||||
CLAIM_SEARCH_BY_TAGS_STARTED: CLAIM_SEARCH_BY_TAGS_STARTED,
|
CLAIM_SEARCH_BY_TAGS_STARTED: CLAIM_SEARCH_BY_TAGS_STARTED,
|
||||||
CLAIM_SEARCH_BY_TAGS_COMPLETED: CLAIM_SEARCH_BY_TAGS_COMPLETED,
|
CLAIM_SEARCH_BY_TAGS_COMPLETED: CLAIM_SEARCH_BY_TAGS_COMPLETED,
|
||||||
CLAIM_SEARCH_BY_TAGS_FAILED: CLAIM_SEARCH_BY_TAGS_FAILED,
|
CLAIM_SEARCH_BY_TAGS_FAILED: CLAIM_SEARCH_BY_TAGS_FAILED,
|
||||||
|
CLAIM_REPOST_STARTED: CLAIM_REPOST_STARTED,
|
||||||
|
CLAIM_REPOST_COMPLETED: CLAIM_REPOST_COMPLETED,
|
||||||
|
CLAIM_REPOST_FAILED: CLAIM_REPOST_FAILED,
|
||||||
|
CLEAR_REPOST_ERROR: CLEAR_REPOST_ERROR,
|
||||||
COMMENT_LIST_STARTED: COMMENT_LIST_STARTED,
|
COMMENT_LIST_STARTED: COMMENT_LIST_STARTED,
|
||||||
COMMENT_LIST_COMPLETED: COMMENT_LIST_COMPLETED,
|
COMMENT_LIST_COMPLETED: COMMENT_LIST_COMPLETED,
|
||||||
COMMENT_LIST_FAILED: COMMENT_LIST_FAILED,
|
COMMENT_LIST_FAILED: COMMENT_LIST_FAILED,
|
||||||
|
@ -865,7 +873,7 @@ const Lbry = {
|
||||||
// Returns a human readable media type based on the content type or extension of a file that is returned by the sdk
|
// Returns a human readable media type based on the content type or extension of a file that is returned by the sdk
|
||||||
getMediaType: (contentType, fileName) => {
|
getMediaType: (contentType, fileName) => {
|
||||||
if (fileName) {
|
if (fileName) {
|
||||||
const formats = [[/\.(mp4|m4v|webm|flv|f4v|ogv)$/i, 'video'], [/\.(mp3|m4a|aac|wav|flac|ogg|opus)$/i, 'audio'], [/\.(jpeg|jpg|png|gif|svg)$/i, 'image'], [/\.(h|go|ja|java|js|jsx|c|cpp|cs|css|rb|scss|sh|php|py)$/i, 'script'], [/\.(json|csv|txt|log|md|markdown|docx|pdf|xml|yml|yaml)$/i, 'document'], [/\.(pdf|odf|doc|docx|epub|org|rtf)$/i, 'e-book'], [/\.(stl|obj|fbx|gcode)$/i, '3D-file'], [/\.(cbr|cbt|cbz)$/i, 'comic-book'], [/\.(lbry)$/i, 'application']];
|
const formats = [[/\.(mp4|m4v|webm|flv|f4v|ogv)$/i, 'video'], [/\.(mp3|m4a|aac|wav|flac|ogg|opus)$/i, 'audio'], [/\.(jpeg|jpg|png|gif|svg)$/i, 'image'], [/\.(h|go|ja|java|js|jsx|c|cpp|cs|css|rb|scss|sh|php|py)$/i, 'script'], [/\.(html|json|csv|txt|log|md|markdown|docx|pdf|xml|yml|yaml)$/i, 'document'], [/\.(pdf|odf|doc|docx|epub|org|rtf)$/i, 'e-book'], [/\.(stl|obj|fbx|gcode)$/i, '3D-file'], [/\.(cbr|cbt|cbz)$/i, 'comic-book'], [/\.(lbry)$/i, 'application']];
|
||||||
|
|
||||||
const res = formats.reduce((ret, testpair) => {
|
const res = formats.reduce((ret, testpair) => {
|
||||||
switch (testpair[0].test(ret)) {
|
switch (testpair[0].test(ret)) {
|
||||||
|
@ -907,6 +915,7 @@ const Lbry = {
|
||||||
channel_abandon: params => daemonCallWithResult('channel_abandon', params),
|
channel_abandon: params => daemonCallWithResult('channel_abandon', params),
|
||||||
support_create: params => daemonCallWithResult('support_create', params),
|
support_create: params => daemonCallWithResult('support_create', params),
|
||||||
support_list: params => daemonCallWithResult('support_list', params),
|
support_list: params => daemonCallWithResult('support_list', params),
|
||||||
|
stream_repost: params => daemonCallWithResult('stream_repost', params),
|
||||||
|
|
||||||
// File fetching and manipulation
|
// File fetching and manipulation
|
||||||
file_list: (params = {}) => daemonCallWithResult('file_list', params),
|
file_list: (params = {}) => daemonCallWithResult('file_list', params),
|
||||||
|
@ -942,7 +951,6 @@ const Lbry = {
|
||||||
comment_create: (params = {}) => daemonCallWithResult('comment_create', params),
|
comment_create: (params = {}) => daemonCallWithResult('comment_create', params),
|
||||||
comment_hide: (params = {}) => daemonCallWithResult('comment_hide', params),
|
comment_hide: (params = {}) => daemonCallWithResult('comment_hide', params),
|
||||||
comment_abandon: (params = {}) => daemonCallWithResult('comment_abandon', params),
|
comment_abandon: (params = {}) => daemonCallWithResult('comment_abandon', params),
|
||||||
// requires SDK ver. 0.53.0
|
|
||||||
comment_update: (params = {}) => daemonCallWithResult('comment_update', params),
|
comment_update: (params = {}) => daemonCallWithResult('comment_update', params),
|
||||||
|
|
||||||
// Connect to the sdk
|
// Connect to the sdk
|
||||||
|
@ -1953,6 +1961,10 @@ const selectCreatingChannel = reselect.createSelector(selectState$2, state => st
|
||||||
|
|
||||||
const selectCreateChannelError = reselect.createSelector(selectState$2, state => state.createChannelError);
|
const selectCreateChannelError = reselect.createSelector(selectState$2, state => state.createChannelError);
|
||||||
|
|
||||||
|
const selectRepostLoading = reselect.createSelector(selectState$2, state => state.repostLoading);
|
||||||
|
|
||||||
|
const selectRepostError = reselect.createSelector(selectState$2, state => state.repostError);
|
||||||
|
|
||||||
const selectClaimsByUri = reselect.createSelector(selectState$2, selectClaimsById, (state, byId) => {
|
const selectClaimsByUri = reselect.createSelector(selectState$2, selectClaimsById, (state, byId) => {
|
||||||
const byUri = state.claimsByUri || {};
|
const byUri = state.claimsByUri || {};
|
||||||
const claims = {};
|
const claims = {};
|
||||||
|
@ -2874,7 +2886,7 @@ function doFetchClaimListMine(page = 1, pageSize = 99999) {
|
||||||
type: FETCH_CLAIM_LIST_MINE_STARTED
|
type: FETCH_CLAIM_LIST_MINE_STARTED
|
||||||
});
|
});
|
||||||
|
|
||||||
lbryProxy.stream_list({ page, page_size: pageSize }).then(result => {
|
lbryProxy.claim_list({ page, page_size: pageSize, claim_type: ['stream', 'repost'] }).then(result => {
|
||||||
const claims = result.items;
|
const claims = result.items;
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -3190,6 +3202,47 @@ function doClaimSearch(options = {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doRepost(options) {
|
||||||
|
return dispatch => {
|
||||||
|
// $FlowFixMe
|
||||||
|
return new Promise(resolve => {
|
||||||
|
dispatch({
|
||||||
|
type: CLAIM_REPOST_STARTED
|
||||||
|
});
|
||||||
|
|
||||||
|
function success(response) {
|
||||||
|
const repostClaim = response.outputs[0];
|
||||||
|
dispatch({
|
||||||
|
type: CLAIM_REPOST_COMPLETED,
|
||||||
|
data: {
|
||||||
|
originalClaimId: options.claim_id,
|
||||||
|
repostClaim
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
function failure(error) {
|
||||||
|
dispatch({
|
||||||
|
type: CLAIM_REPOST_FAILED,
|
||||||
|
data: {
|
||||||
|
error: error.message
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
lbryProxy.stream_repost(options).then(success, failure);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function doClearRepostError() {
|
||||||
|
return {
|
||||||
|
type: CLEAR_REPOST_ERROR
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const selectState$3 = state => state.fileInfo || {};
|
const selectState$3 = state => state.fileInfo || {};
|
||||||
|
|
||||||
const selectFileInfosByOutpoint = reselect.createSelector(selectState$3, state => state.byOutpoint || {});
|
const selectFileInfosByOutpoint = reselect.createSelector(selectState$3, state => state.byOutpoint || {});
|
||||||
|
@ -4450,7 +4503,9 @@ const defaultState = {
|
||||||
updatingChannel: false,
|
updatingChannel: false,
|
||||||
creatingChannel: false,
|
creatingChannel: false,
|
||||||
createChannelError: undefined,
|
createChannelError: undefined,
|
||||||
pendingChannelImport: false
|
pendingChannelImport: false,
|
||||||
|
repostLoading: false,
|
||||||
|
repostError: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleClaimAction(state, action) {
|
function handleClaimAction(state, action) {
|
||||||
|
@ -4805,6 +4860,43 @@ reducers[CLAIM_SEARCH_FAILED] = (state, action) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reducers[CLAIM_REPOST_STARTED] = state => {
|
||||||
|
return _extends$9({}, state, {
|
||||||
|
repostLoading: true,
|
||||||
|
repostError: null
|
||||||
|
});
|
||||||
|
};
|
||||||
|
reducers[CLAIM_REPOST_COMPLETED] = (state, action) => {
|
||||||
|
const { originalClaimId, repostClaim } = action.data;
|
||||||
|
const byId = _extends$9({}, state.byId);
|
||||||
|
const claimsByUri = _extends$9({}, state.claimsByUri);
|
||||||
|
const claimThatWasReposted = byId[originalClaimId];
|
||||||
|
|
||||||
|
const repostStub = _extends$9({}, repostClaim, { reposted_claim: claimThatWasReposted });
|
||||||
|
byId[repostStub.claim_id] = repostStub;
|
||||||
|
claimsByUri[repostStub.permanent_url] = repostStub.claim_id;
|
||||||
|
|
||||||
|
return _extends$9({}, state, {
|
||||||
|
byId,
|
||||||
|
claimsByUri,
|
||||||
|
repostLoading: false,
|
||||||
|
repostError: null
|
||||||
|
});
|
||||||
|
};
|
||||||
|
reducers[CLAIM_REPOST_FAILED] = (state, action) => {
|
||||||
|
const { error } = action.data;
|
||||||
|
|
||||||
|
return _extends$9({}, state, {
|
||||||
|
repostLoading: false,
|
||||||
|
repostError: error
|
||||||
|
});
|
||||||
|
};
|
||||||
|
reducers[CLEAR_REPOST_ERROR] = state => {
|
||||||
|
return _extends$9({}, state, {
|
||||||
|
repostError: null
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function claimsReducer(state = defaultState, action) {
|
function claimsReducer(state = defaultState, action) {
|
||||||
const handler = reducers[action.type];
|
const handler = reducers[action.type];
|
||||||
if (handler) return handler(state, action);
|
if (handler) return handler(state, action);
|
||||||
|
@ -5997,6 +6089,7 @@ exports.doCheckAddressIsMine = doCheckAddressIsMine;
|
||||||
exports.doCheckPendingPublishes = doCheckPendingPublishes;
|
exports.doCheckPendingPublishes = doCheckPendingPublishes;
|
||||||
exports.doClaimSearch = doClaimSearch;
|
exports.doClaimSearch = doClaimSearch;
|
||||||
exports.doClearPublish = doClearPublish;
|
exports.doClearPublish = doClearPublish;
|
||||||
|
exports.doClearRepostError = doClearRepostError;
|
||||||
exports.doClearSupport = doClearSupport;
|
exports.doClearSupport = doClearSupport;
|
||||||
exports.doCommentAbandon = doCommentAbandon;
|
exports.doCommentAbandon = doCommentAbandon;
|
||||||
exports.doCommentCreate = doCommentCreate;
|
exports.doCommentCreate = doCommentCreate;
|
||||||
|
@ -6026,6 +6119,7 @@ exports.doPreferenceSet = doPreferenceSet;
|
||||||
exports.doPrepareEdit = doPrepareEdit;
|
exports.doPrepareEdit = doPrepareEdit;
|
||||||
exports.doPublish = doPublish;
|
exports.doPublish = doPublish;
|
||||||
exports.doPurchaseUri = doPurchaseUri;
|
exports.doPurchaseUri = doPurchaseUri;
|
||||||
|
exports.doRepost = doRepost;
|
||||||
exports.doResetThumbnailStatus = doResetThumbnailStatus;
|
exports.doResetThumbnailStatus = doResetThumbnailStatus;
|
||||||
exports.doResolveUri = doResolveUri;
|
exports.doResolveUri = doResolveUri;
|
||||||
exports.doResolveUris = doResolveUris;
|
exports.doResolveUris = doResolveUris;
|
||||||
|
@ -6192,6 +6286,8 @@ exports.selectPurchaseUriErrorMessage = selectPurchaseUriErrorMessage;
|
||||||
exports.selectPurchasedUris = selectPurchasedUris;
|
exports.selectPurchasedUris = selectPurchasedUris;
|
||||||
exports.selectReceiveAddress = selectReceiveAddress;
|
exports.selectReceiveAddress = selectReceiveAddress;
|
||||||
exports.selectRecentTransactions = selectRecentTransactions;
|
exports.selectRecentTransactions = selectRecentTransactions;
|
||||||
|
exports.selectRepostError = selectRepostError;
|
||||||
|
exports.selectRepostLoading = selectRepostLoading;
|
||||||
exports.selectReservedBalance = selectReservedBalance;
|
exports.selectReservedBalance = selectReservedBalance;
|
||||||
exports.selectResolvedSearchResultsByQuery = selectResolvedSearchResultsByQuery;
|
exports.selectResolvedSearchResultsByQuery = selectResolvedSearchResultsByQuery;
|
||||||
exports.selectResolvedSearchResultsByQueryLastPageReached = selectResolvedSearchResultsByQueryLastPageReached;
|
exports.selectResolvedSearchResultsByQueryLastPageReached = selectResolvedSearchResultsByQueryLastPageReached;
|
||||||
|
|
10
dist/flow-typed/Lbry.js
vendored
10
dist/flow-typed/Lbry.js
vendored
|
@ -204,6 +204,15 @@ declare type StreamListResponse = {
|
||||||
total_pages: number,
|
total_pages: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare type StreamRepostOptions = {
|
||||||
|
name: string,
|
||||||
|
bid: string,
|
||||||
|
claim_id: string,
|
||||||
|
channel_id: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
declare type StreamRepostResponse = GenericTxResponse;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Types used in the generic Lbry object that is exported
|
// Types used in the generic Lbry object that is exported
|
||||||
//
|
//
|
||||||
|
@ -240,6 +249,7 @@ declare type LbryTypes = {
|
||||||
support_create: (params: {}) => Promise<GenericTxResponse>,
|
support_create: (params: {}) => Promise<GenericTxResponse>,
|
||||||
support_list: (params: {}) => Promise<SupportListResponse>,
|
support_list: (params: {}) => Promise<SupportListResponse>,
|
||||||
support_abandon: (params: {}) => Promise<SupportAbandonResponse>,
|
support_abandon: (params: {}) => Promise<SupportAbandonResponse>,
|
||||||
|
stream_repost: (params: StreamRepostOptions) => Promise<StreamRepostResponse>,
|
||||||
|
|
||||||
// File fetching and manipulation
|
// File fetching and manipulation
|
||||||
file_list: (params: {}) => Promise<FileListResponse>,
|
file_list: (params: {}) => Promise<FileListResponse>,
|
||||||
|
|
10
flow-typed/Lbry.js
vendored
10
flow-typed/Lbry.js
vendored
|
@ -204,6 +204,15 @@ declare type StreamListResponse = {
|
||||||
total_pages: number,
|
total_pages: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare type StreamRepostOptions = {
|
||||||
|
name: string,
|
||||||
|
bid: string,
|
||||||
|
claim_id: string,
|
||||||
|
channel_id: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
declare type StreamRepostResponse = GenericTxResponse;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Types used in the generic Lbry object that is exported
|
// Types used in the generic Lbry object that is exported
|
||||||
//
|
//
|
||||||
|
@ -240,6 +249,7 @@ declare type LbryTypes = {
|
||||||
support_create: (params: {}) => Promise<GenericTxResponse>,
|
support_create: (params: {}) => Promise<GenericTxResponse>,
|
||||||
support_list: (params: {}) => Promise<SupportListResponse>,
|
support_list: (params: {}) => Promise<SupportListResponse>,
|
||||||
support_abandon: (params: {}) => Promise<SupportAbandonResponse>,
|
support_abandon: (params: {}) => Promise<SupportAbandonResponse>,
|
||||||
|
stream_repost: (params: StreamRepostOptions) => Promise<StreamRepostResponse>,
|
||||||
|
|
||||||
// File fetching and manipulation
|
// File fetching and manipulation
|
||||||
file_list: (params: {}) => Promise<FileListResponse>,
|
file_list: (params: {}) => Promise<FileListResponse>,
|
||||||
|
|
|
@ -103,6 +103,10 @@ export const CLAIM_SEARCH_FAILED = 'CLAIM_SEARCH_FAILED';
|
||||||
export const CLAIM_SEARCH_BY_TAGS_STARTED = 'CLAIM_SEARCH_BY_TAGS_STARTED';
|
export const CLAIM_SEARCH_BY_TAGS_STARTED = 'CLAIM_SEARCH_BY_TAGS_STARTED';
|
||||||
export const CLAIM_SEARCH_BY_TAGS_COMPLETED = 'CLAIM_SEARCH_BY_TAGS_COMPLETED';
|
export const CLAIM_SEARCH_BY_TAGS_COMPLETED = 'CLAIM_SEARCH_BY_TAGS_COMPLETED';
|
||||||
export const CLAIM_SEARCH_BY_TAGS_FAILED = 'CLAIM_SEARCH_BY_TAGS_FAILED';
|
export const CLAIM_SEARCH_BY_TAGS_FAILED = 'CLAIM_SEARCH_BY_TAGS_FAILED';
|
||||||
|
export const CLAIM_REPOST_STARTED = 'CLAIM_REPOST_STARTED';
|
||||||
|
export const CLAIM_REPOST_COMPLETED = 'CLAIM_REPOST_COMPLETED';
|
||||||
|
export const CLAIM_REPOST_FAILED = 'CLAIM_REPOST_FAILED';
|
||||||
|
export const CLEAR_REPOST_ERROR = 'CLEAR_REPOST_ERROR';
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
export const COMMENT_LIST_STARTED = 'COMMENT_LIST_STARTED';
|
export const COMMENT_LIST_STARTED = 'COMMENT_LIST_STARTED';
|
||||||
|
|
|
@ -67,6 +67,8 @@ export {
|
||||||
doUpdateChannel,
|
doUpdateChannel,
|
||||||
doClaimSearch,
|
doClaimSearch,
|
||||||
doImportChannel,
|
doImportChannel,
|
||||||
|
doRepost,
|
||||||
|
doClearRepostError,
|
||||||
} from 'redux/actions/claims';
|
} from 'redux/actions/claims';
|
||||||
|
|
||||||
export { doDeletePurchasedUri, doPurchaseUri, doFileGet } from 'redux/actions/file';
|
export { doDeletePurchasedUri, doPurchaseUri, doFileGet } from 'redux/actions/file';
|
||||||
|
@ -232,6 +234,8 @@ export {
|
||||||
selectChannelImportPending,
|
selectChannelImportPending,
|
||||||
makeSelectMyStreamUrlsForPage,
|
makeSelectMyStreamUrlsForPage,
|
||||||
selectMyStreamUrlsCount,
|
selectMyStreamUrlsCount,
|
||||||
|
selectRepostError,
|
||||||
|
selectRepostLoading,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
|
|
||||||
export { makeSelectCommentsForUri } from 'redux/selectors/comments';
|
export { makeSelectCommentsForUri } from 'redux/selectors/comments';
|
||||||
|
|
|
@ -86,6 +86,7 @@ const Lbry: LbryTypes = {
|
||||||
channel_abandon: params => daemonCallWithResult('channel_abandon', params),
|
channel_abandon: params => daemonCallWithResult('channel_abandon', params),
|
||||||
support_create: params => daemonCallWithResult('support_create', params),
|
support_create: params => daemonCallWithResult('support_create', params),
|
||||||
support_list: params => daemonCallWithResult('support_list', params),
|
support_list: params => daemonCallWithResult('support_list', params),
|
||||||
|
stream_repost: params => daemonCallWithResult('stream_repost', params),
|
||||||
|
|
||||||
// File fetching and manipulation
|
// File fetching and manipulation
|
||||||
file_list: (params = {}) => daemonCallWithResult('file_list', params),
|
file_list: (params = {}) => daemonCallWithResult('file_list', params),
|
||||||
|
@ -121,7 +122,6 @@ const Lbry: LbryTypes = {
|
||||||
comment_create: (params = {}) => daemonCallWithResult('comment_create', params),
|
comment_create: (params = {}) => daemonCallWithResult('comment_create', params),
|
||||||
comment_hide: (params = {}) => daemonCallWithResult('comment_hide', params),
|
comment_hide: (params = {}) => daemonCallWithResult('comment_hide', params),
|
||||||
comment_abandon: (params = {}) => daemonCallWithResult('comment_abandon', params),
|
comment_abandon: (params = {}) => daemonCallWithResult('comment_abandon', params),
|
||||||
// requires SDK ver. 0.53.0
|
|
||||||
comment_update: (params = {}) => daemonCallWithResult('comment_update', params),
|
comment_update: (params = {}) => daemonCallWithResult('comment_update', params),
|
||||||
|
|
||||||
// Connect to the sdk
|
// Connect to the sdk
|
||||||
|
|
|
@ -100,16 +100,18 @@ export function doFetchClaimListMine(page: number = 1, pageSize: number = 99999)
|
||||||
type: ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED,
|
type: ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED,
|
||||||
});
|
});
|
||||||
|
|
||||||
Lbry.stream_list({ page, page_size: pageSize }).then((result: StreamListResponse) => {
|
Lbry.claim_list({ page, page_size: pageSize, claim_type: ['stream', 'repost'] }).then(
|
||||||
const claims = result.items;
|
(result: StreamListResponse) => {
|
||||||
|
const claims = result.items;
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
||||||
data: {
|
data: {
|
||||||
claims,
|
claims,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,3 +457,44 @@ export function doClaimSearch(
|
||||||
Lbry.claim_search(options).then(success, failure);
|
Lbry.claim_search(options).then(success, failure);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function doRepost(options: StreamRepostOptions) {
|
||||||
|
return (dispatch: Dispatch) => {
|
||||||
|
// $FlowFixMe
|
||||||
|
return new Promise(resolve => {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.CLAIM_REPOST_STARTED,
|
||||||
|
});
|
||||||
|
|
||||||
|
function success(response) {
|
||||||
|
const repostClaim = response.outputs[0];
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.CLAIM_REPOST_COMPLETED,
|
||||||
|
data: {
|
||||||
|
originalClaimId: options.claim_id,
|
||||||
|
repostClaim,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
function failure(error) {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.CLAIM_REPOST_FAILED,
|
||||||
|
data: {
|
||||||
|
error: error.message,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Lbry.stream_repost(options).then(success, failure);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function doClearRepostError() {
|
||||||
|
return {
|
||||||
|
type: ACTIONS.CLEAR_REPOST_ERROR,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ type State = {
|
||||||
updateChannelError: string,
|
updateChannelError: string,
|
||||||
updatingChannel: boolean,
|
updatingChannel: boolean,
|
||||||
pendingChannelImport: string | boolean,
|
pendingChannelImport: string | boolean,
|
||||||
|
repostLoading: boolean,
|
||||||
|
repostError: ?string,
|
||||||
};
|
};
|
||||||
|
|
||||||
const reducers = {};
|
const reducers = {};
|
||||||
|
@ -65,6 +67,8 @@ const defaultState = {
|
||||||
creatingChannel: false,
|
creatingChannel: false,
|
||||||
createChannelError: undefined,
|
createChannelError: undefined,
|
||||||
pendingChannelImport: false,
|
pendingChannelImport: false,
|
||||||
|
repostLoading: false,
|
||||||
|
repostError: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleClaimAction(state: State, action: any): State {
|
function handleClaimAction(state: State, action: any): State {
|
||||||
|
@ -447,6 +451,47 @@ reducers[ACTIONS.CLAIM_SEARCH_FAILED] = (state: State, action: any): State => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
reducers[ACTIONS.CLAIM_REPOST_STARTED] = (state: State): State => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
repostLoading: true,
|
||||||
|
repostError: null,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
reducers[ACTIONS.CLAIM_REPOST_COMPLETED] = (state: State, action: any): State => {
|
||||||
|
const { originalClaimId, repostClaim } = action.data;
|
||||||
|
const byId = { ...state.byId };
|
||||||
|
const claimsByUri = { ...state.claimsByUri };
|
||||||
|
const claimThatWasReposted = byId[originalClaimId];
|
||||||
|
|
||||||
|
const repostStub = { ...repostClaim, reposted_claim: claimThatWasReposted };
|
||||||
|
byId[repostStub.claim_id] = repostStub;
|
||||||
|
claimsByUri[repostStub.permanent_url] = repostStub.claim_id;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
byId,
|
||||||
|
claimsByUri,
|
||||||
|
repostLoading: false,
|
||||||
|
repostError: null,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
reducers[ACTIONS.CLAIM_REPOST_FAILED] = (state: State, action: any): State => {
|
||||||
|
const { error } = action.data;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
repostLoading: false,
|
||||||
|
repostError: error,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
reducers[ACTIONS.CLEAR_REPOST_ERROR] = (state: State): State => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
repostError: null,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export function claimsReducer(state: State = defaultState, action: any) {
|
export function claimsReducer(state: State = defaultState, action: any) {
|
||||||
const handler = reducers[action.type];
|
const handler = reducers[action.type];
|
||||||
if (handler) return handler(state, action);
|
if (handler) return handler(state, action);
|
||||||
|
|
|
@ -31,6 +31,16 @@ export const selectCreateChannelError = createSelector(
|
||||||
state => state.createChannelError
|
state => state.createChannelError
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectRepostLoading = createSelector(
|
||||||
|
selectState,
|
||||||
|
state => state.repostLoading
|
||||||
|
);
|
||||||
|
|
||||||
|
export const selectRepostError = createSelector(
|
||||||
|
selectState,
|
||||||
|
state => state.repostError
|
||||||
|
);
|
||||||
|
|
||||||
export const selectClaimsByUri = createSelector(
|
export const selectClaimsByUri = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
selectClaimsById,
|
selectClaimsById,
|
||||||
|
@ -279,8 +289,8 @@ export const makeSelectDateForUri = (uri: string) =>
|
||||||
(claim.value.release_time
|
(claim.value.release_time
|
||||||
? claim.value.release_time * 1000
|
? claim.value.release_time * 1000
|
||||||
: claim.meta && claim.meta.creation_timestamp
|
: claim.meta && claim.meta.creation_timestamp
|
||||||
? claim.meta.creation_timestamp * 1000
|
? claim.meta.creation_timestamp * 1000
|
||||||
: null);
|
: null);
|
||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue