This commit is contained in:
Sean Yesmunt 2019-06-09 22:45:47 -04:00
parent f435dc4600
commit a22d0270d0
15 changed files with 705 additions and 133 deletions

View file

@ -10,6 +10,7 @@
"__": true "__": true
}, },
"rules": { "rules": {
"camelcase": 0,
"no-multi-spaces": 0, "no-multi-spaces": 0,
"new-cap": 0, "new-cap": 0,
"prefer-promise-reject-errors": 0, "prefer-promise-reject-errors": 0,

453
dist/bundle.es.js vendored
View file

@ -98,6 +98,9 @@ const SET_CONTENT_POSITION = 'SET_CONTENT_POSITION';
const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED'; const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED';
const CLEAR_CONTENT_HISTORY_URI = 'CLEAR_CONTENT_HISTORY_URI'; const CLEAR_CONTENT_HISTORY_URI = 'CLEAR_CONTENT_HISTORY_URI';
const CLEAR_CONTENT_HISTORY_ALL = 'CLEAR_CONTENT_HISTORY_ALL'; const CLEAR_CONTENT_HISTORY_ALL = 'CLEAR_CONTENT_HISTORY_ALL';
const CLAIM_SEARCH_STARTED = 'CLAIM_SEARCH_STARTED';
const CLAIM_SEARCH_COMPLETED = 'CLAIM_SEARCH_COMPLETED';
const CLAIM_SEARCH_FAILED = 'CLAIM_SEARCH_FAILED';
// Files // Files
const FILE_LIST_STARTED = 'FILE_LIST_STARTED'; const FILE_LIST_STARTED = 'FILE_LIST_STARTED';
@ -187,21 +190,6 @@ const FETCH_REWARD_CONTENT_COMPLETED = 'FETCH_REWARD_CONTENT_COMPLETED';
const DOWNLOAD_LANGUAGE_SUCCEEDED = 'DOWNLOAD_LANGUAGE_SUCCEEDED'; const DOWNLOAD_LANGUAGE_SUCCEEDED = 'DOWNLOAD_LANGUAGE_SUCCEEDED';
const DOWNLOAD_LANGUAGE_FAILED = 'DOWNLOAD_LANGUAGE_FAILED'; const DOWNLOAD_LANGUAGE_FAILED = 'DOWNLOAD_LANGUAGE_FAILED';
// ShapeShift
const GET_SUPPORTED_COINS_START = 'GET_SUPPORTED_COINS_START';
const GET_SUPPORTED_COINS_SUCCESS = 'GET_SUPPORTED_COINS_SUCCESS';
const GET_SUPPORTED_COINS_FAIL = 'GET_SUPPORTED_COINS_FAIL';
const GET_COIN_STATS_START = 'GET_COIN_STATS_START';
const GET_COIN_STATS_SUCCESS = 'GET_COIN_STATS_SUCCESS';
const GET_COIN_STATS_FAIL = 'GET_COIN_STATS_FAIL';
const PREPARE_SHAPE_SHIFT_START = 'PREPARE_SHAPE_SHIFT_START';
const PREPARE_SHAPE_SHIFT_SUCCESS = 'PREPARE_SHAPE_SHIFT_SUCCESS';
const PREPARE_SHAPE_SHIFT_FAIL = 'PREPARE_SHAPE_SHIFT_FAIL';
const GET_ACTIVE_SHIFT_START = 'GET_ACTIVE_SHIFT_START';
const GET_ACTIVE_SHIFT_SUCCESS = 'GET_ACTIVE_SHIFT_SUCCESS';
const GET_ACTIVE_SHIFT_FAIL = 'GET_ACTIVE_SHIFT_FAIL';
const CLEAR_SHAPE_SHIFT = 'CLEAR_SHAPE_SHIFT';
// Subscriptions // Subscriptions
const CHANNEL_SUBSCRIBE = 'CHANNEL_SUBSCRIBE'; const CHANNEL_SUBSCRIBE = 'CHANNEL_SUBSCRIBE';
const CHANNEL_UNSUBSCRIBE = 'CHANNEL_UNSUBSCRIBE'; const CHANNEL_UNSUBSCRIBE = 'CHANNEL_UNSUBSCRIBE';
@ -239,6 +227,13 @@ const FETCH_DATE = 'FETCH_DATE';
const FETCH_COST_INFO_STARTED = 'FETCH_COST_INFO_STARTED'; const FETCH_COST_INFO_STARTED = 'FETCH_COST_INFO_STARTED';
const FETCH_COST_INFO_COMPLETED = 'FETCH_COST_INFO_COMPLETED'; const FETCH_COST_INFO_COMPLETED = 'FETCH_COST_INFO_COMPLETED';
const FETCH_COST_INFO_FAILED = 'FETCH_COST_INFO_FAILED'; const FETCH_COST_INFO_FAILED = 'FETCH_COST_INFO_FAILED';
// Tags
const TOGGLE_TAG_FOLLOW = 'TOGGLE_TAG_FOLLOW';
const TAG_ADD = 'TAG_ADD';
const TAG_DELETE = 'TAG_DELETE';
const FETCH_TRENDING_STARTED = 'FETCH_TRENDING_STARTED';
const FETCH_TRENDING_COMPLETED = 'FETCH_TRENDING_COMPLETED';
const FETCH_TRENDING_FAILED = 'FETCH_TRENDING_FAILED';
var action_types = /*#__PURE__*/Object.freeze({ var action_types = /*#__PURE__*/Object.freeze({
WINDOW_FOCUSED: WINDOW_FOCUSED, WINDOW_FOCUSED: WINDOW_FOCUSED,
@ -323,6 +318,9 @@ var action_types = /*#__PURE__*/Object.freeze({
SET_CONTENT_LAST_VIEWED: SET_CONTENT_LAST_VIEWED, SET_CONTENT_LAST_VIEWED: SET_CONTENT_LAST_VIEWED,
CLEAR_CONTENT_HISTORY_URI: CLEAR_CONTENT_HISTORY_URI, CLEAR_CONTENT_HISTORY_URI: CLEAR_CONTENT_HISTORY_URI,
CLEAR_CONTENT_HISTORY_ALL: CLEAR_CONTENT_HISTORY_ALL, CLEAR_CONTENT_HISTORY_ALL: CLEAR_CONTENT_HISTORY_ALL,
CLAIM_SEARCH_STARTED: CLAIM_SEARCH_STARTED,
CLAIM_SEARCH_COMPLETED: CLAIM_SEARCH_COMPLETED,
CLAIM_SEARCH_FAILED: CLAIM_SEARCH_FAILED,
FILE_LIST_STARTED: FILE_LIST_STARTED, FILE_LIST_STARTED: FILE_LIST_STARTED,
FILE_LIST_SUCCEEDED: FILE_LIST_SUCCEEDED, FILE_LIST_SUCCEEDED: FILE_LIST_SUCCEEDED,
FETCH_FILE_INFO_STARTED: FETCH_FILE_INFO_STARTED, FETCH_FILE_INFO_STARTED: FETCH_FILE_INFO_STARTED,
@ -399,19 +397,6 @@ var action_types = /*#__PURE__*/Object.freeze({
FETCH_REWARD_CONTENT_COMPLETED: FETCH_REWARD_CONTENT_COMPLETED, FETCH_REWARD_CONTENT_COMPLETED: FETCH_REWARD_CONTENT_COMPLETED,
DOWNLOAD_LANGUAGE_SUCCEEDED: DOWNLOAD_LANGUAGE_SUCCEEDED, DOWNLOAD_LANGUAGE_SUCCEEDED: DOWNLOAD_LANGUAGE_SUCCEEDED,
DOWNLOAD_LANGUAGE_FAILED: DOWNLOAD_LANGUAGE_FAILED, DOWNLOAD_LANGUAGE_FAILED: DOWNLOAD_LANGUAGE_FAILED,
GET_SUPPORTED_COINS_START: GET_SUPPORTED_COINS_START,
GET_SUPPORTED_COINS_SUCCESS: GET_SUPPORTED_COINS_SUCCESS,
GET_SUPPORTED_COINS_FAIL: GET_SUPPORTED_COINS_FAIL,
GET_COIN_STATS_START: GET_COIN_STATS_START,
GET_COIN_STATS_SUCCESS: GET_COIN_STATS_SUCCESS,
GET_COIN_STATS_FAIL: GET_COIN_STATS_FAIL,
PREPARE_SHAPE_SHIFT_START: PREPARE_SHAPE_SHIFT_START,
PREPARE_SHAPE_SHIFT_SUCCESS: PREPARE_SHAPE_SHIFT_SUCCESS,
PREPARE_SHAPE_SHIFT_FAIL: PREPARE_SHAPE_SHIFT_FAIL,
GET_ACTIVE_SHIFT_START: GET_ACTIVE_SHIFT_START,
GET_ACTIVE_SHIFT_SUCCESS: GET_ACTIVE_SHIFT_SUCCESS,
GET_ACTIVE_SHIFT_FAIL: GET_ACTIVE_SHIFT_FAIL,
CLEAR_SHAPE_SHIFT: CLEAR_SHAPE_SHIFT,
CHANNEL_SUBSCRIBE: CHANNEL_SUBSCRIBE, CHANNEL_SUBSCRIBE: CHANNEL_SUBSCRIBE,
CHANNEL_UNSUBSCRIBE: CHANNEL_UNSUBSCRIBE, CHANNEL_UNSUBSCRIBE: CHANNEL_UNSUBSCRIBE,
HAS_FETCHED_SUBSCRIPTIONS: HAS_FETCHED_SUBSCRIPTIONS, HAS_FETCHED_SUBSCRIPTIONS: HAS_FETCHED_SUBSCRIPTIONS,
@ -440,7 +425,13 @@ var action_types = /*#__PURE__*/Object.freeze({
FETCH_DATE: FETCH_DATE, FETCH_DATE: FETCH_DATE,
FETCH_COST_INFO_STARTED: FETCH_COST_INFO_STARTED, FETCH_COST_INFO_STARTED: FETCH_COST_INFO_STARTED,
FETCH_COST_INFO_COMPLETED: FETCH_COST_INFO_COMPLETED, FETCH_COST_INFO_COMPLETED: FETCH_COST_INFO_COMPLETED,
FETCH_COST_INFO_FAILED: FETCH_COST_INFO_FAILED FETCH_COST_INFO_FAILED: FETCH_COST_INFO_FAILED,
TOGGLE_TAG_FOLLOW: TOGGLE_TAG_FOLLOW,
TAG_ADD: TAG_ADD,
TAG_DELETE: TAG_DELETE,
FETCH_TRENDING_STARTED: FETCH_TRENDING_STARTED,
FETCH_TRENDING_COMPLETED: FETCH_TRENDING_COMPLETED,
FETCH_TRENDING_FAILED: FETCH_TRENDING_FAILED
}); });
const API_DOWN = 'apiDown'; const API_DOWN = 'apiDown';
@ -1428,6 +1419,10 @@ const makeSelectChannelForClaimUri = (uri, includePrefix = false) => reselect.cr
return includePrefix ? `lbry://${channel}` : channel; return includePrefix ? `lbry://${channel}` : channel;
}); });
const makeSelectTagsForUri = uri => reselect.createSelector(makeSelectMetadataForUri(uri), metadata => {
return metadata && metadata.tags || [];
});
const selectState$2 = state => state.wallet || {}; const selectState$2 = state => state.wallet || {};
const selectWalletState = selectState$2; const selectWalletState = selectState$2;
@ -1946,6 +1941,14 @@ function doUpdateBlockHeight() {
}); });
} }
// https://github.com/reactjs/redux/issues/911
function batchActions(...actions) {
return {
type: 'BATCH_ACTIONS',
actions
};
}
var _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function doResolveUris(uris, returnCachedClaims = false) { function doResolveUris(uris, returnCachedClaims = false) {
@ -1997,10 +2000,13 @@ function doResolveUris(uris, returnCachedClaims = false) {
result.stream = uriResolveInfo; result.stream = uriResolveInfo;
if (uriResolveInfo.signing_channel) { if (uriResolveInfo.signing_channel) {
result.channel = uriResolveInfo.signing_channel; result.channel = uriResolveInfo.signing_channel;
<<<<<<< HEAD
result.claimsInChannel = uriResolveInfo.signing_channel.meta && uriResolveInfo.signing_channel.meta.claims_in_channel || 0; result.claimsInChannel = uriResolveInfo.signing_channel.meta && uriResolveInfo.signing_channel.meta.claims_in_channel || 0;
=======
result.claimsInChannel = uriResolveInfo.meta && uriResolveInfo.meta.claims_in_channel || 0;
>>>>>>> add tags
} }
} }
// $FlowFixMe // $FlowFixMe
resolveInfo[uri] = result; resolveInfo[uri] = result;
} }
@ -2119,7 +2125,11 @@ function doFetchClaimsByChannel(uri, page = 1) {
lbryProxy.claim_search({ lbryProxy.claim_search({
channel: uri, channel: uri,
<<<<<<< HEAD
valid_channel_signatures: true, valid_channel_signatures: true,
=======
is_controlling: true,
>>>>>>> add tags
page: page || 1, page: page || 1,
order_by: ['release_time'] order_by: ['release_time']
}).then(result => { }).then(result => {
@ -2181,6 +2191,46 @@ function doFetchChannelListMine() {
}; };
} }
function doClaimSearch(amount = 20, options = {}, cb) {
return dispatch => {
dispatch({
type: CLAIM_SEARCH_STARTED
});
const success = data => {
const resolveInfo = {};
const uris = [];
data.items.forEach(stream => {
resolveInfo[stream.permanent_url] = { stream };
uris.push(stream.permanent_url);
});
dispatch({
type: CLAIM_SEARCH_COMPLETED,
data: { resolveInfo }
});
if (cb) {
cb(null, uris);
}
};
const failure = err => {
dispatch({
type: CLAIM_SEARCH_FAILED,
error: err
});
if (cb) {
cb(err);
}
};
lbryProxy.claim_search(_extends$3({
page_size: amount
}, options)).then(success, failure);
};
}
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 || {});
@ -2344,6 +2394,10 @@ const selectFileListPublishedSort = reselect.createSelector(selectState$3, state
const selectFileListDownloadedSort = reselect.createSelector(selectState$3, state => state.fileListDownloadedSort); const selectFileListDownloadedSort = reselect.createSelector(selectState$3, state => state.fileListDownloadedSort);
const selectDownloadedUris = reselect.createSelector(selectFileInfosDownloaded,
// We should use permament_url but it doesn't exist in file_list
info => info.map(claim => `lbry://${claim.claim_name}#${claim.claim_id}`));
// //
const selectState$4 = state => state.file || {}; const selectState$4 = state => state.file || {};
@ -2522,14 +2576,6 @@ function doSetFileListSort(page, value) {
}; };
} }
// https://github.com/reactjs/redux/issues/911
function batchActions(...actions) {
return {
type: 'BATCH_ACTIONS',
actions
};
}
// Returns a function, that, as long as it continues to be invoked, will not // Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for // be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the // N milliseconds. If `immediate` is passed, trigger the function on the
@ -2709,6 +2755,55 @@ function savePosition(claimId, outpoint, position) {
// //
const doToggleTagFollow = name => ({
type: TOGGLE_TAG_FOLLOW,
data: {
name
}
});
const doAddTag = name => ({
type: TAG_ADD,
data: {
name
}
});
const doDeleteTag = name => ({
type: TAG_DELETE,
data: {
name
}
});
const doFetchByTags = (amount = 10, options = {}) => {
return dispatch => {
dispatch({
type: FETCH_TRENDING_STARTED
});
const callback = (error, uris = []) => {
if (error) {
return dispatch({
type: FETCH_TRENDING_FAILED,
error
});
}
dispatch({
type: FETCH_TRENDING_COMPLETED,
data: {
uris
}
});
};
dispatch(doClaimSearch(amount, options, callback));
};
};
var _extends$4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const reducers = {}; const reducers = {};
const defaultState = { const defaultState = {
byId: {}, byId: {},
@ -2725,7 +2820,7 @@ const defaultState = {
pendingById: {} pendingById: {}
}; };
reducers[RESOLVE_URIS_COMPLETED] = (state, action) => { function handleClaimAction(state, action) {
const { const {
resolveInfo resolveInfo
} = action.data; } = action.data;
@ -2762,6 +2857,10 @@ reducers[RESOLVE_URIS_COMPLETED] = (state, action) => {
channelClaimCounts, channelClaimCounts,
resolvingUris: (state.resolvingUris || []).filter(uri => !resolveInfo[uri]) resolvingUris: (state.resolvingUris || []).filter(uri => !resolveInfo[uri])
}); });
}
reducers[RESOLVE_URIS_COMPLETED] = (state, action) => {
return handleClaimAction(state, action);
}; };
reducers[FETCH_CLAIM_LIST_MINE_STARTED] = state => Object.assign({}, state, { reducers[FETCH_CLAIM_LIST_MINE_STARTED] = state => Object.assign({}, state, {
@ -2936,13 +3035,27 @@ reducers[RESOLVE_URIS_STARTED] = (state, action) => {
}); });
}; };
reducers[CLAIM_SEARCH_STARTED] = state => {
return Object.assign({}, state, {
fetchingClaimSearch: true
});
};
reducers[CLAIM_SEARCH_COMPLETED] = (state, action) => {
return _extends$4({}, handleClaimAction(state, action), { fetchingClaimSearch: false });
};
reducers[CLAIM_SEARCH_FAILED] = state => {
return Object.assign({}, state, {
fetchingClaimSearch: false
});
};
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);
return state; return state;
} }
var _extends$4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const reducers$1 = {}; const reducers$1 = {};
const defaultState$1 = { const defaultState$1 = {
@ -2959,7 +3072,7 @@ reducers$1[PURCHASE_URI_STARTED] = (state, action) => {
newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1); newFailedPurchaseUris.splice(newFailedPurchaseUris.indexOf(uri), 1);
} }
return _extends$4({}, state, { return _extends$5({}, state, {
failedPurchaseUris: newFailedPurchaseUris, failedPurchaseUris: newFailedPurchaseUris,
purchaseUriErrorMessage: '' purchaseUriErrorMessage: ''
}); });
@ -2981,7 +3094,7 @@ reducers$1[PURCHASE_URI_COMPLETED] = (state, action) => {
newPurchasedStreamingUrls[uri] = streamingUrl; newPurchasedStreamingUrls[uri] = streamingUrl;
} }
return _extends$4({}, state, { return _extends$5({}, state, {
failedPurchaseUris: newFailedPurchaseUris, failedPurchaseUris: newFailedPurchaseUris,
purchasedUris: newPurchasedUris, purchasedUris: newPurchasedUris,
purchasedStreamingUrls: newPurchasedStreamingUrls, purchasedStreamingUrls: newPurchasedStreamingUrls,
@ -2997,7 +3110,7 @@ reducers$1[PURCHASE_URI_FAILED] = (state, action) => {
newFailedPurchaseUris.push(uri); newFailedPurchaseUris.push(uri);
} }
return _extends$4({}, state, { return _extends$5({}, state, {
failedPurchaseUris: newFailedPurchaseUris, failedPurchaseUris: newFailedPurchaseUris,
purchaseUriErrorMessage: error purchaseUriErrorMessage: error
}); });
@ -3010,7 +3123,7 @@ reducers$1[DELETE_PURCHASED_URI] = (state, action) => {
newPurchasedUris.splice(newPurchasedUris.indexOf(uri), 1); newPurchasedUris.splice(newPurchasedUris.indexOf(uri), 1);
} }
return _extends$4({}, state, { return _extends$5({}, state, {
purchasedUris: newPurchasedUris purchasedUris: newPurchasedUris
}); });
}; };
@ -3021,7 +3134,7 @@ function fileReducer(state = defaultState$1, action) {
return state; return state;
} }
var _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$6 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const reducers$2 = {}; const reducers$2 = {};
const defaultState$2 = { const defaultState$2 = {
@ -3157,12 +3270,12 @@ reducers$2[LOADING_VIDEO_STARTED] = (state, action) => {
const newLoading = Object.assign({}, state.urisLoading); const newLoading = Object.assign({}, state.urisLoading);
newLoading[uri] = true; newLoading[uri] = true;
const newErrors = _extends$5({}, state.errors); const newErrors = _extends$6({}, state.errors);
if (uri in newErrors) delete newErrors[uri]; if (uri in newErrors) delete newErrors[uri];
return Object.assign({}, state, { return Object.assign({}, state, {
urisLoading: newLoading, urisLoading: newLoading,
errors: _extends$5({}, newErrors) errors: _extends$6({}, newErrors)
}); });
}; };
@ -3172,12 +3285,12 @@ reducers$2[LOADING_VIDEO_FAILED] = (state, action) => {
const newLoading = Object.assign({}, state.urisLoading); const newLoading = Object.assign({}, state.urisLoading);
delete newLoading[uri]; delete newLoading[uri];
const newErrors = _extends$5({}, state.errors); const newErrors = _extends$6({}, state.errors);
newErrors[uri] = true; newErrors[uri] = true;
return Object.assign({}, state, { return Object.assign({}, state, {
urisLoading: newLoading, urisLoading: newLoading,
errors: _extends$5({}, newErrors) errors: _extends$6({}, newErrors)
}); });
}; };
@ -3218,7 +3331,7 @@ const handleActions = (actionMap, defaultState) => (state = defaultState, action
return state; return state;
}; };
var _extends$6 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$7 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const defaultState$3 = { const defaultState$3 = {
notifications: [], notifications: [],
@ -3233,7 +3346,7 @@ const notificationsReducer = handleActions({
const newToasts = state.toasts.slice(); const newToasts = state.toasts.slice();
newToasts.push(toast); newToasts.push(toast);
return _extends$6({}, state, { return _extends$7({}, state, {
toasts: newToasts toasts: newToasts
}); });
}, },
@ -3241,7 +3354,7 @@ const notificationsReducer = handleActions({
const newToasts = state.toasts.slice(); const newToasts = state.toasts.slice();
newToasts.shift(); newToasts.shift();
return _extends$6({}, state, { return _extends$7({}, state, {
toasts: newToasts toasts: newToasts
}); });
}, },
@ -3252,7 +3365,7 @@ const notificationsReducer = handleActions({
const newNotifications = state.notifications.slice(); const newNotifications = state.notifications.slice();
newNotifications.push(notification); newNotifications.push(notification);
return _extends$6({}, state, { return _extends$7({}, state, {
notifications: newNotifications notifications: newNotifications
}); });
}, },
@ -3263,7 +3376,7 @@ const notificationsReducer = handleActions({
notifications = notifications.map(pastNotification => pastNotification.id === notification.id ? notification : pastNotification); notifications = notifications.map(pastNotification => pastNotification.id === notification.id ? notification : pastNotification);
return _extends$6({}, state, { return _extends$7({}, state, {
notifications notifications
}); });
}, },
@ -3272,7 +3385,7 @@ const notificationsReducer = handleActions({
let newNotifications = state.notifications.slice(); let newNotifications = state.notifications.slice();
newNotifications = newNotifications.filter(notification => notification.id !== id); newNotifications = newNotifications.filter(notification => notification.id !== id);
return _extends$6({}, state, { return _extends$7({}, state, {
notifications: newNotifications notifications: newNotifications
}); });
}, },
@ -3283,7 +3396,7 @@ const notificationsReducer = handleActions({
const newErrors = state.errors.slice(); const newErrors = state.errors.slice();
newErrors.push(error); newErrors.push(error);
return _extends$6({}, state, { return _extends$7({}, state, {
errors: newErrors errors: newErrors
}); });
}, },
@ -3291,13 +3404,13 @@ const notificationsReducer = handleActions({
const newErrors = state.errors.slice(); const newErrors = state.errors.slice();
newErrors.shift(); newErrors.shift();
return _extends$6({}, state, { return _extends$7({}, state, {
errors: newErrors errors: newErrors
}); });
} }
}, defaultState$3); }, defaultState$3);
var _extends$7 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$8 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const defaultState$4 = { const defaultState$4 = {
isActive: false, // does the user have any typed text in the search input isActive: false, // does the user have any typed text in the search input
@ -3317,29 +3430,29 @@ const defaultState$4 = {
}; };
const searchReducer = handleActions({ const searchReducer = handleActions({
[SEARCH_START]: state => _extends$7({}, state, { [SEARCH_START]: state => _extends$8({}, state, {
searching: true searching: true
}), }),
[SEARCH_SUCCESS]: (state, action) => { [SEARCH_SUCCESS]: (state, action) => {
const { query, uris } = action.data; const { query, uris } = action.data;
return _extends$7({}, state, { return _extends$8({}, state, {
searching: false, searching: false,
urisByQuery: Object.assign({}, state.urisByQuery, { [query]: uris }) urisByQuery: Object.assign({}, state.urisByQuery, { [query]: uris })
}); });
}, },
[SEARCH_FAIL]: state => _extends$7({}, state, { [SEARCH_FAIL]: state => _extends$8({}, state, {
searching: false searching: false
}), }),
[UPDATE_SEARCH_QUERY]: (state, action) => _extends$7({}, state, { [UPDATE_SEARCH_QUERY]: (state, action) => _extends$8({}, state, {
searchQuery: action.data.query, searchQuery: action.data.query,
isActive: true isActive: true
}), }),
[UPDATE_SEARCH_SUGGESTIONS]: (state, action) => _extends$7({}, state, { [UPDATE_SEARCH_SUGGESTIONS]: (state, action) => _extends$8({}, state, {
suggestions: _extends$7({}, state.suggestions, { suggestions: _extends$8({}, state.suggestions, {
[action.data.query]: action.data.suggestions [action.data.query]: action.data.suggestions
}) })
}), }),
@ -3347,27 +3460,27 @@ const searchReducer = handleActions({
// sets isActive to false so the uri will be populated correctly if the // sets isActive to false so the uri will be populated correctly if the
// user is on a file page. The search query will still be present on any // user is on a file page. The search query will still be present on any
// other page // other page
[DISMISS_NOTIFICATION]: state => _extends$7({}, state, { [DISMISS_NOTIFICATION]: state => _extends$8({}, state, {
isActive: false isActive: false
}), }),
[SEARCH_FOCUS]: state => _extends$7({}, state, { [SEARCH_FOCUS]: state => _extends$8({}, state, {
focused: true focused: true
}), }),
[SEARCH_BLUR]: state => _extends$7({}, state, { [SEARCH_BLUR]: state => _extends$8({}, state, {
focused: false focused: false
}), }),
[UPDATE_SEARCH_OPTIONS]: (state, action) => { [UPDATE_SEARCH_OPTIONS]: (state, action) => {
const { options: oldOptions } = state; const { options: oldOptions } = state;
const newOptions = action.data; const newOptions = action.data;
const options = _extends$7({}, oldOptions, newOptions); const options = _extends$8({}, oldOptions, newOptions);
return _extends$7({}, state, { return _extends$8({}, state, {
options options
}); });
} }
}, defaultState$4); }, defaultState$4);
var _extends$8 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const buildDraftTransaction = () => ({ const buildDraftTransaction = () => ({
amount: undefined, amount: undefined,
@ -3407,25 +3520,25 @@ const defaultState$5 = {
}; };
const walletReducer = handleActions({ const walletReducer = handleActions({
[FETCH_TRANSACTIONS_STARTED]: state => _extends$8({}, state, { [FETCH_TRANSACTIONS_STARTED]: state => _extends$9({}, state, {
fetchingTransactions: true fetchingTransactions: true
}), }),
[FETCH_TRANSACTIONS_COMPLETED]: (state, action) => { [FETCH_TRANSACTIONS_COMPLETED]: (state, action) => {
const byId = _extends$8({}, state.transactions); const byId = _extends$9({}, state.transactions);
const { transactions } = action.data; const { transactions } = action.data;
transactions.forEach(transaction => { transactions.forEach(transaction => {
byId[transaction.txid] = transaction; byId[transaction.txid] = transaction;
}); });
return _extends$8({}, state, { return _extends$9({}, state, {
transactions: byId, transactions: byId,
fetchingTransactions: false fetchingTransactions: false
}); });
}, },
[FETCH_SUPPORTS_STARTED]: state => _extends$8({}, state, { [FETCH_SUPPORTS_STARTED]: state => _extends$9({}, state, {
fetchingSupports: true fetchingSupports: true
}), }),
@ -3438,7 +3551,7 @@ const walletReducer = handleActions({
byOutpoint[`${txid}:${nout}`] = transaction; byOutpoint[`${txid}:${nout}`] = transaction;
}); });
return _extends$8({}, state, { supports: byOutpoint, fetchingSupports: false }); return _extends$9({}, state, { supports: byOutpoint, fetchingSupports: false });
}, },
[ABANDON_SUPPORT_STARTED]: (state, action) => { [ABANDON_SUPPORT_STARTED]: (state, action) => {
@ -3447,7 +3560,7 @@ const walletReducer = handleActions({
currentlyAbandoning[outpoint] = true; currentlyAbandoning[outpoint] = true;
return _extends$8({}, state, { return _extends$9({}, state, {
abandoningSupportsByOutpoint: currentlyAbandoning abandoningSupportsByOutpoint: currentlyAbandoning
}); });
}, },
@ -3460,56 +3573,56 @@ const walletReducer = handleActions({
delete currentlyAbandoning[outpoint]; delete currentlyAbandoning[outpoint];
delete byOutpoint[outpoint]; delete byOutpoint[outpoint];
return _extends$8({}, state, { return _extends$9({}, state, {
supports: byOutpoint, supports: byOutpoint,
abandoningSupportsById: currentlyAbandoning abandoningSupportsById: currentlyAbandoning
}); });
}, },
[GET_NEW_ADDRESS_STARTED]: state => _extends$8({}, state, { [GET_NEW_ADDRESS_STARTED]: state => _extends$9({}, state, {
gettingNewAddress: true gettingNewAddress: true
}), }),
[GET_NEW_ADDRESS_COMPLETED]: (state, action) => { [GET_NEW_ADDRESS_COMPLETED]: (state, action) => {
const { address } = action.data; const { address } = action.data;
return _extends$8({}, state, { gettingNewAddress: false, receiveAddress: address }); return _extends$9({}, state, { gettingNewAddress: false, receiveAddress: address });
}, },
[UPDATE_BALANCE]: (state, action) => _extends$8({}, state, { [UPDATE_BALANCE]: (state, action) => _extends$9({}, state, {
balance: action.data.balance balance: action.data.balance
}), }),
[UPDATE_TOTAL_BALANCE]: (state, action) => _extends$8({}, state, { [UPDATE_TOTAL_BALANCE]: (state, action) => _extends$9({}, state, {
totalBalance: action.data.totalBalance totalBalance: action.data.totalBalance
}), }),
[CHECK_ADDRESS_IS_MINE_STARTED]: state => _extends$8({}, state, { [CHECK_ADDRESS_IS_MINE_STARTED]: state => _extends$9({}, state, {
checkingAddressOwnership: true checkingAddressOwnership: true
}), }),
[CHECK_ADDRESS_IS_MINE_COMPLETED]: state => _extends$8({}, state, { [CHECK_ADDRESS_IS_MINE_COMPLETED]: state => _extends$9({}, state, {
checkingAddressOwnership: false checkingAddressOwnership: false
}), }),
[SET_DRAFT_TRANSACTION_AMOUNT]: (state, action) => { [SET_DRAFT_TRANSACTION_AMOUNT]: (state, action) => {
const oldDraft = state.draftTransaction; const oldDraft = state.draftTransaction;
const newDraft = _extends$8({}, oldDraft, { amount: parseFloat(action.data.amount) }); const newDraft = _extends$9({}, oldDraft, { amount: parseFloat(action.data.amount) });
return _extends$8({}, state, { draftTransaction: newDraft }); return _extends$9({}, state, { draftTransaction: newDraft });
}, },
[SET_DRAFT_TRANSACTION_ADDRESS]: (state, action) => { [SET_DRAFT_TRANSACTION_ADDRESS]: (state, action) => {
const oldDraft = state.draftTransaction; const oldDraft = state.draftTransaction;
const newDraft = _extends$8({}, oldDraft, { address: action.data.address }); const newDraft = _extends$9({}, oldDraft, { address: action.data.address });
return _extends$8({}, state, { draftTransaction: newDraft }); return _extends$9({}, state, { draftTransaction: newDraft });
}, },
[SEND_TRANSACTION_STARTED]: state => { [SEND_TRANSACTION_STARTED]: state => {
const newDraftTransaction = _extends$8({}, state.draftTransaction, { sending: true }); const newDraftTransaction = _extends$9({}, state.draftTransaction, { sending: true });
return _extends$8({}, state, { draftTransaction: newDraftTransaction }); return _extends$9({}, state, { draftTransaction: newDraftTransaction });
}, },
[SEND_TRANSACTION_COMPLETED]: state => Object.assign({}, state, { [SEND_TRANSACTION_COMPLETED]: state => Object.assign({}, state, {
@ -3522,108 +3635,108 @@ const walletReducer = handleActions({
error: action.data.error error: action.data.error
}); });
return _extends$8({}, state, { draftTransaction: newDraftTransaction }); return _extends$9({}, state, { draftTransaction: newDraftTransaction });
}, },
[SUPPORT_TRANSACTION_STARTED]: state => _extends$8({}, state, { [SUPPORT_TRANSACTION_STARTED]: state => _extends$9({}, state, {
sendingSupport: true sendingSupport: true
}), }),
[SUPPORT_TRANSACTION_COMPLETED]: state => _extends$8({}, state, { [SUPPORT_TRANSACTION_COMPLETED]: state => _extends$9({}, state, {
sendingSupport: false sendingSupport: false
}), }),
[SUPPORT_TRANSACTION_FAILED]: (state, action) => _extends$8({}, state, { [SUPPORT_TRANSACTION_FAILED]: (state, action) => _extends$9({}, state, {
error: action.data.error, error: action.data.error,
sendingSupport: false sendingSupport: false
}), }),
[WALLET_STATUS_COMPLETED]: (state, action) => _extends$8({}, state, { [WALLET_STATUS_COMPLETED]: (state, action) => _extends$9({}, state, {
walletIsEncrypted: action.result walletIsEncrypted: action.result
}), }),
[WALLET_ENCRYPT_START]: state => _extends$8({}, state, { [WALLET_ENCRYPT_START]: state => _extends$9({}, state, {
walletEncryptPending: true, walletEncryptPending: true,
walletEncryptSucceded: null, walletEncryptSucceded: null,
walletEncryptResult: null walletEncryptResult: null
}), }),
[WALLET_ENCRYPT_COMPLETED]: (state, action) => _extends$8({}, state, { [WALLET_ENCRYPT_COMPLETED]: (state, action) => _extends$9({}, state, {
walletEncryptPending: false, walletEncryptPending: false,
walletEncryptSucceded: true, walletEncryptSucceded: true,
walletEncryptResult: action.result walletEncryptResult: action.result
}), }),
[WALLET_ENCRYPT_FAILED]: (state, action) => _extends$8({}, state, { [WALLET_ENCRYPT_FAILED]: (state, action) => _extends$9({}, state, {
walletEncryptPending: false, walletEncryptPending: false,
walletEncryptSucceded: false, walletEncryptSucceded: false,
walletEncryptResult: action.result walletEncryptResult: action.result
}), }),
[WALLET_DECRYPT_START]: state => _extends$8({}, state, { [WALLET_DECRYPT_START]: state => _extends$9({}, state, {
walletDecryptPending: true, walletDecryptPending: true,
walletDecryptSucceded: null, walletDecryptSucceded: null,
walletDecryptResult: null walletDecryptResult: null
}), }),
[WALLET_DECRYPT_COMPLETED]: (state, action) => _extends$8({}, state, { [WALLET_DECRYPT_COMPLETED]: (state, action) => _extends$9({}, state, {
walletDecryptPending: false, walletDecryptPending: false,
walletDecryptSucceded: true, walletDecryptSucceded: true,
walletDecryptResult: action.result walletDecryptResult: action.result
}), }),
[WALLET_DECRYPT_FAILED]: (state, action) => _extends$8({}, state, { [WALLET_DECRYPT_FAILED]: (state, action) => _extends$9({}, state, {
walletDecryptPending: false, walletDecryptPending: false,
walletDecryptSucceded: false, walletDecryptSucceded: false,
walletDecryptResult: action.result walletDecryptResult: action.result
}), }),
[WALLET_UNLOCK_START]: state => _extends$8({}, state, { [WALLET_UNLOCK_START]: state => _extends$9({}, state, {
walletUnlockPending: true, walletUnlockPending: true,
walletUnlockSucceded: null, walletUnlockSucceded: null,
walletUnlockResult: null walletUnlockResult: null
}), }),
[WALLET_UNLOCK_COMPLETED]: (state, action) => _extends$8({}, state, { [WALLET_UNLOCK_COMPLETED]: (state, action) => _extends$9({}, state, {
walletUnlockPending: false, walletUnlockPending: false,
walletUnlockSucceded: true, walletUnlockSucceded: true,
walletUnlockResult: action.result walletUnlockResult: action.result
}), }),
[WALLET_UNLOCK_FAILED]: (state, action) => _extends$8({}, state, { [WALLET_UNLOCK_FAILED]: (state, action) => _extends$9({}, state, {
walletUnlockPending: false, walletUnlockPending: false,
walletUnlockSucceded: false, walletUnlockSucceded: false,
walletUnlockResult: action.result walletUnlockResult: action.result
}), }),
[WALLET_LOCK_START]: state => _extends$8({}, state, { [WALLET_LOCK_START]: state => _extends$9({}, state, {
walletLockPending: false, walletLockPending: false,
walletLockSucceded: null, walletLockSucceded: null,
walletLockResult: null walletLockResult: null
}), }),
[WALLET_LOCK_COMPLETED]: (state, action) => _extends$8({}, state, { [WALLET_LOCK_COMPLETED]: (state, action) => _extends$9({}, state, {
walletLockPending: false, walletLockPending: false,
walletLockSucceded: true, walletLockSucceded: true,
walletLockResult: action.result walletLockResult: action.result
}), }),
[WALLET_LOCK_FAILED]: (state, action) => _extends$8({}, state, { [WALLET_LOCK_FAILED]: (state, action) => _extends$9({}, state, {
walletLockPending: false, walletLockPending: false,
walletLockSucceded: false, walletLockSucceded: false,
walletLockResult: action.result walletLockResult: action.result
}), }),
[SET_TRANSACTION_LIST_FILTER]: (state, action) => _extends$8({}, state, { [SET_TRANSACTION_LIST_FILTER]: (state, action) => _extends$9({}, state, {
transactionListFilter: action.data transactionListFilter: action.data
}), }),
[UPDATE_CURRENT_HEIGHT]: (state, action) => _extends$8({}, state, { [UPDATE_CURRENT_HEIGHT]: (state, action) => _extends$9({}, state, {
latestBlock: action.data latestBlock: action.data
}) })
}, defaultState$5); }, defaultState$5);
var _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const reducers$3 = {}; const reducers$3 = {};
const defaultState$6 = { const defaultState$6 = {
@ -3632,9 +3745,9 @@ const defaultState$6 = {
reducers$3[SET_CONTENT_POSITION] = (state, action) => { reducers$3[SET_CONTENT_POSITION] = (state, action) => {
const { claimId, outpoint, position } = action.data; const { claimId, outpoint, position } = action.data;
return _extends$9({}, state, { return _extends$a({}, state, {
positions: _extends$9({}, state.positions, { positions: _extends$a({}, state.positions, {
[claimId]: _extends$9({}, state.positions[claimId], { [claimId]: _extends$a({}, state.positions[claimId], {
[outpoint]: position [outpoint]: position
}) })
}) })
@ -3647,6 +3760,79 @@ function contentReducer(state = defaultState$6, action) {
return state; return state;
} }
const defaultFollowedTags = ['gaming', 'blockchain', 'news', 'learning', 'funny', 'technology', 'automotive', 'economics', 'sports', 'food', 'science', 'art', 'nature', 'beliefs', 'music', 'pop culture', 'weapons'];
const defaultRecommendedTags = [];
var _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function getDefaultRecommendedTags() {
return defaultFollowedTags.concat(defaultRecommendedTags).reduce((tagsMap, tag) => _extends$b({}, tagsMap, {
[tag]: { name: tag }
}), {});
}
const defaultState$7 = {
followedTags: defaultFollowedTags,
knownTags: getDefaultRecommendedTags(),
trending: [],
fetchingTrending: false
};
const tagsReducer = handleActions({
[TOGGLE_TAG_FOLLOW]: (state, action) => {
const { followedTags } = state;
const { name } = action.data;
let newFollowedTags = followedTags.slice();
if (newFollowedTags.includes(name)) {
newFollowedTags = newFollowedTags.filter(tag => tag !== name);
} else {
newFollowedTags.push(name);
}
return _extends$b({}, state, {
followedTags: newFollowedTags
});
},
[TAG_ADD]: (state, action) => {
const { knownTags } = state;
const { name } = action.data;
let newKnownTags = _extends$b({}, knownTags);
newKnownTags[name] = { name };
return _extends$b({}, state, {
knownTags: newKnownTags
});
},
[TAG_DELETE]: (state, action) => {
const { knownTags, followedTags } = state;
const { name } = action.data;
let newKnownTags = _extends$b({}, knownTags);
delete newKnownTags[name];
return _extends$b({}, state, {
knownTags: newKnownTags
});
},
[FETCH_TRENDING_STARTED]: state => _extends$b({}, state, {
fetchingTrending: true
}),
[FETCH_TRENDING_COMPLETED]: (state, action) => _extends$b({}, state, {
trending: action.data.uris,
fetchingTrending: false
}),
[FETCH_TRENDING_FAILED]: state => _extends$b({}, state, {
trending: [],
fetchingTrending: false
})
}, defaultState$7);
const selectState$5 = state => state.content || {}; const selectState$5 = state => state.content || {};
const makeSelectContentPositionForUri = uri => reselect.createSelector(selectState$5, makeSelectClaimForUri(uri), (state, claim) => { const makeSelectContentPositionForUri = uri => reselect.createSelector(selectState$5, makeSelectClaimForUri(uri), (state, claim) => {
@ -3658,14 +3844,14 @@ const makeSelectContentPositionForUri = uri => reselect.createSelector(selectSta
return state.positions[id] ? state.positions[id][outpoint] : null; return state.positions[id] ? state.positions[id][outpoint] : null;
}); });
var _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
const selectState$6 = state => state.notifications || {}; const selectState$6 = state => state.notifications || {};
const selectToast = reselect.createSelector(selectState$6, state => { const selectToast = reselect.createSelector(selectState$6, state => {
if (state.toasts.length) { if (state.toasts.length) {
const { id, params } = state.toasts[0]; const { id, params } = state.toasts[0];
return _extends$a({ return _extends$c({
id id
}, params); }, params);
} }
@ -3684,6 +3870,34 @@ const selectError = reselect.createSelector(selectState$6, state => {
return null; return null;
}); });
//
const selectState$7 = state => state.tags || {};
const selectKnownTagsByName = reselect.createSelector(selectState$7, state => state.knownTags);
const selectFollowedTagsList = reselect.createSelector(selectState$7, state => state.followedTags);
const selectFollowedTags = reselect.createSelector(selectFollowedTagsList, followedTags => followedTags.map(tag => ({ name: tag })));
const selectUnfollowedTags = reselect.createSelector(selectKnownTagsByName, selectFollowedTagsList, (tagsByName, followedTags) => {
const followedTagsSet = new Set(followedTags);
let tagsToReturn = [];
Object.keys(tagsByName).forEach(key => {
if (!followedTagsSet.has(key)) {
const { name } = tagsByName[key];
tagsToReturn.push({ name });
}
});
return tagsToReturn;
});
const selectTrendingUris = reselect.createSelector(selectState$7, state => state.trending || []);
const selectFetchingTrending = reselect.createSelector(selectState$7, state => state.fetchingTrending);
exports.ACTIONS = action_types; exports.ACTIONS = action_types;
exports.Lbry = lbryProxy; exports.Lbry = lbryProxy;
exports.PAGES = pages; exports.PAGES = pages;
@ -3700,14 +3914,17 @@ exports.contentReducer = contentReducer;
exports.convertToShareLink = convertToShareLink; exports.convertToShareLink = convertToShareLink;
exports.creditsToString = creditsToString; exports.creditsToString = creditsToString;
exports.doAbandonClaim = doAbandonClaim; exports.doAbandonClaim = doAbandonClaim;
exports.doAddTag = doAddTag;
exports.doBalanceSubscribe = doBalanceSubscribe; exports.doBalanceSubscribe = doBalanceSubscribe;
exports.doBlurSearchInput = doBlurSearchInput; exports.doBlurSearchInput = doBlurSearchInput;
exports.doCheckAddressIsMine = doCheckAddressIsMine; exports.doCheckAddressIsMine = doCheckAddressIsMine;
exports.doCreateChannel = doCreateChannel; exports.doCreateChannel = doCreateChannel;
exports.doDeletePurchasedUri = doDeletePurchasedUri; exports.doDeletePurchasedUri = doDeletePurchasedUri;
exports.doDeleteTag = doDeleteTag;
exports.doDismissError = doDismissError; exports.doDismissError = doDismissError;
exports.doDismissToast = doDismissToast; exports.doDismissToast = doDismissToast;
exports.doError = doError; exports.doError = doError;
exports.doFetchByTags = doFetchByTags;
exports.doFetchChannelListMine = doFetchChannelListMine; exports.doFetchChannelListMine = doFetchChannelListMine;
exports.doFetchClaimListMine = doFetchClaimListMine; exports.doFetchClaimListMine = doFetchClaimListMine;
exports.doFetchClaimsByChannel = doFetchClaimsByChannel; exports.doFetchClaimsByChannel = doFetchClaimsByChannel;
@ -3729,6 +3946,7 @@ exports.doSetDraftTransactionAmount = doSetDraftTransactionAmount;
exports.doSetFileListSort = doSetFileListSort; exports.doSetFileListSort = doSetFileListSort;
exports.doSetTransactionListFilter = doSetTransactionListFilter; exports.doSetTransactionListFilter = doSetTransactionListFilter;
exports.doToast = doToast; exports.doToast = doToast;
exports.doToggleTagFollow = doToggleTagFollow;
exports.doTotalBalanceSubscribe = doTotalBalanceSubscribe; exports.doTotalBalanceSubscribe = doTotalBalanceSubscribe;
exports.doUpdateBalance = doUpdateBalance; exports.doUpdateBalance = doUpdateBalance;
exports.doUpdateBlockHeight = doUpdateBlockHeight; exports.doUpdateBlockHeight = doUpdateBlockHeight;
@ -3773,6 +3991,7 @@ exports.makeSelectQueryWithOptions = makeSelectQueryWithOptions;
exports.makeSelectRecommendedContentForUri = makeSelectRecommendedContentForUri; exports.makeSelectRecommendedContentForUri = makeSelectRecommendedContentForUri;
exports.makeSelectSearchUris = makeSelectSearchUris; exports.makeSelectSearchUris = makeSelectSearchUris;
exports.makeSelectStreamingUrlForUri = makeSelectStreamingUrlForUri; exports.makeSelectStreamingUrlForUri = makeSelectStreamingUrlForUri;
exports.makeSelectTagsForUri = makeSelectTagsForUri;
exports.makeSelectThumbnailForUri = makeSelectThumbnailForUri; exports.makeSelectThumbnailForUri = makeSelectThumbnailForUri;
exports.makeSelectTitleForUri = makeSelectTitleForUri; exports.makeSelectTitleForUri = makeSelectTitleForUri;
exports.makeSelectTotalItemsForChannel = makeSelectTotalItemsForChannel; exports.makeSelectTotalItemsForChannel = makeSelectTotalItemsForChannel;
@ -3795,6 +4014,7 @@ exports.selectChannelClaimCounts = selectChannelClaimCounts;
exports.selectClaimsById = selectClaimsById; exports.selectClaimsById = selectClaimsById;
exports.selectClaimsByUri = selectClaimsByUri; exports.selectClaimsByUri = selectClaimsByUri;
exports.selectCurrentChannelPage = selectCurrentChannelPage; exports.selectCurrentChannelPage = selectCurrentChannelPage;
exports.selectDownloadedUris = selectDownloadedUris;
exports.selectDownloadingByOutpoint = selectDownloadingByOutpoint; exports.selectDownloadingByOutpoint = selectDownloadingByOutpoint;
exports.selectDownloadingFileInfos = selectDownloadingFileInfos; exports.selectDownloadingFileInfos = selectDownloadingFileInfos;
exports.selectDraftTransaction = selectDraftTransaction; exports.selectDraftTransaction = selectDraftTransaction;
@ -3804,10 +4024,12 @@ exports.selectDraftTransactionError = selectDraftTransactionError;
exports.selectError = selectError; exports.selectError = selectError;
exports.selectFailedPurchaseUris = selectFailedPurchaseUris; exports.selectFailedPurchaseUris = selectFailedPurchaseUris;
exports.selectFetchingMyChannels = selectFetchingMyChannels; exports.selectFetchingMyChannels = selectFetchingMyChannels;
exports.selectFetchingTrending = selectFetchingTrending;
exports.selectFileInfosByOutpoint = selectFileInfosByOutpoint; exports.selectFileInfosByOutpoint = selectFileInfosByOutpoint;
exports.selectFileInfosDownloaded = selectFileInfosDownloaded; exports.selectFileInfosDownloaded = selectFileInfosDownloaded;
exports.selectFileListDownloadedSort = selectFileListDownloadedSort; exports.selectFileListDownloadedSort = selectFileListDownloadedSort;
exports.selectFileListPublishedSort = selectFileListPublishedSort; exports.selectFileListPublishedSort = selectFileListPublishedSort;
exports.selectFollowedTags = selectFollowedTags;
exports.selectGettingNewAddress = selectGettingNewAddress; exports.selectGettingNewAddress = selectGettingNewAddress;
exports.selectHasTransactions = selectHasTransactions; exports.selectHasTransactions = selectHasTransactions;
exports.selectIsFetchingClaimListMine = selectIsFetchingClaimListMine; exports.selectIsFetchingClaimListMine = selectIsFetchingClaimListMine;
@ -3846,6 +4068,8 @@ exports.selectTotalDownloadProgress = selectTotalDownloadProgress;
exports.selectTransactionItems = selectTransactionItems; exports.selectTransactionItems = selectTransactionItems;
exports.selectTransactionListFilter = selectTransactionListFilter; exports.selectTransactionListFilter = selectTransactionListFilter;
exports.selectTransactionsById = selectTransactionsById; exports.selectTransactionsById = selectTransactionsById;
exports.selectTrendingUris = selectTrendingUris;
exports.selectUnfollowedTags = selectUnfollowedTags;
exports.selectUrisLoading = selectUrisLoading; exports.selectUrisLoading = selectUrisLoading;
exports.selectWalletDecryptPending = selectWalletDecryptPending; exports.selectWalletDecryptPending = selectWalletDecryptPending;
exports.selectWalletDecryptResult = selectWalletDecryptResult; exports.selectWalletDecryptResult = selectWalletDecryptResult;
@ -3859,5 +4083,6 @@ exports.selectWalletUnlockPending = selectWalletUnlockPending;
exports.selectWalletUnlockResult = selectWalletUnlockResult; exports.selectWalletUnlockResult = selectWalletUnlockResult;
exports.selectWalletUnlockSucceeded = selectWalletUnlockSucceeded; exports.selectWalletUnlockSucceeded = selectWalletUnlockSucceeded;
exports.setSearchApi = setSearchApi; exports.setSearchApi = setSearchApi;
exports.tagsReducer = tagsReducer;
exports.toQueryString = toQueryString; exports.toQueryString = toQueryString;
exports.walletReducer = walletReducer; exports.walletReducer = walletReducer;

30
dist/flow-typed/Tags.js vendored Normal file
View file

@ -0,0 +1,30 @@
declare type TagState = {
followedTags: FollowedTags,
knownTags: KnownTags,
trending: Array<string>,
fetchingTrending: boolean,
};
declare type Tag = {
name: string,
};
declare type KnownTags = {
[string]: Tag,
};
declare type FollowedTags = Array<string>;
declare type TagAction = {
type: string,
data: {
name: string,
},
};
declare type TrendingTagAction = {
type: string,
data: {
uris: Array<string>,
},
};

3
flow-typed/Claim.js vendored
View file

@ -3,8 +3,7 @@
declare type Claim = StreamClaim | ChannelClaim; declare type Claim = StreamClaim | ChannelClaim;
declare type ChannelClaim = GenericClaim & { declare type ChannelClaim = GenericClaim & {
is_channel_signature_valid?: boolean, // we may have signed channels in the future, fixes some flow issues for now. is_channel_signature_valid?: boolean, // we may have signed channels in the future
signing_channel?: ChannelClaim,
value: ChannelMetadata, value: ChannelMetadata,
}; };

30
flow-typed/Tags.js vendored Normal file
View file

@ -0,0 +1,30 @@
declare type TagState = {
followedTags: FollowedTags,
knownTags: KnownTags,
trending: Array<string>,
fetchingTrending: boolean,
};
declare type Tag = {
name: string,
};
declare type KnownTags = {
[string]: Tag,
};
declare type FollowedTags = Array<string>;
declare type TagAction = {
type: string,
data: {
name: string,
},
};
declare type TrendingTagAction = {
type: string,
data: {
uris: Array<string>,
},
};

View file

@ -88,6 +88,9 @@ export const SET_CONTENT_POSITION = 'SET_CONTENT_POSITION';
export const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED'; export const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED';
export const CLEAR_CONTENT_HISTORY_URI = 'CLEAR_CONTENT_HISTORY_URI'; export const CLEAR_CONTENT_HISTORY_URI = 'CLEAR_CONTENT_HISTORY_URI';
export const CLEAR_CONTENT_HISTORY_ALL = 'CLEAR_CONTENT_HISTORY_ALL'; export const CLEAR_CONTENT_HISTORY_ALL = 'CLEAR_CONTENT_HISTORY_ALL';
export const CLAIM_SEARCH_STARTED = 'CLAIM_SEARCH_STARTED';
export const CLAIM_SEARCH_COMPLETED = 'CLAIM_SEARCH_COMPLETED';
export const CLAIM_SEARCH_FAILED = 'CLAIM_SEARCH_FAILED';
// Files // Files
export const FILE_LIST_STARTED = 'FILE_LIST_STARTED'; export const FILE_LIST_STARTED = 'FILE_LIST_STARTED';
@ -177,21 +180,6 @@ export const FETCH_REWARD_CONTENT_COMPLETED = 'FETCH_REWARD_CONTENT_COMPLETED';
export const DOWNLOAD_LANGUAGE_SUCCEEDED = 'DOWNLOAD_LANGUAGE_SUCCEEDED'; export const DOWNLOAD_LANGUAGE_SUCCEEDED = 'DOWNLOAD_LANGUAGE_SUCCEEDED';
export const DOWNLOAD_LANGUAGE_FAILED = 'DOWNLOAD_LANGUAGE_FAILED'; export const DOWNLOAD_LANGUAGE_FAILED = 'DOWNLOAD_LANGUAGE_FAILED';
// ShapeShift
export const GET_SUPPORTED_COINS_START = 'GET_SUPPORTED_COINS_START';
export const GET_SUPPORTED_COINS_SUCCESS = 'GET_SUPPORTED_COINS_SUCCESS';
export const GET_SUPPORTED_COINS_FAIL = 'GET_SUPPORTED_COINS_FAIL';
export const GET_COIN_STATS_START = 'GET_COIN_STATS_START';
export const GET_COIN_STATS_SUCCESS = 'GET_COIN_STATS_SUCCESS';
export const GET_COIN_STATS_FAIL = 'GET_COIN_STATS_FAIL';
export const PREPARE_SHAPE_SHIFT_START = 'PREPARE_SHAPE_SHIFT_START';
export const PREPARE_SHAPE_SHIFT_SUCCESS = 'PREPARE_SHAPE_SHIFT_SUCCESS';
export const PREPARE_SHAPE_SHIFT_FAIL = 'PREPARE_SHAPE_SHIFT_FAIL';
export const GET_ACTIVE_SHIFT_START = 'GET_ACTIVE_SHIFT_START';
export const GET_ACTIVE_SHIFT_SUCCESS = 'GET_ACTIVE_SHIFT_SUCCESS';
export const GET_ACTIVE_SHIFT_FAIL = 'GET_ACTIVE_SHIFT_FAIL';
export const CLEAR_SHAPE_SHIFT = 'CLEAR_SHAPE_SHIFT';
// Subscriptions // Subscriptions
export const CHANNEL_SUBSCRIBE = 'CHANNEL_SUBSCRIBE'; export const CHANNEL_SUBSCRIBE = 'CHANNEL_SUBSCRIBE';
export const CHANNEL_UNSUBSCRIBE = 'CHANNEL_UNSUBSCRIBE'; export const CHANNEL_UNSUBSCRIBE = 'CHANNEL_UNSUBSCRIBE';
@ -229,3 +217,10 @@ export const FETCH_DATE = 'FETCH_DATE';
export const FETCH_COST_INFO_STARTED = 'FETCH_COST_INFO_STARTED'; export const FETCH_COST_INFO_STARTED = 'FETCH_COST_INFO_STARTED';
export const FETCH_COST_INFO_COMPLETED = 'FETCH_COST_INFO_COMPLETED'; export const FETCH_COST_INFO_COMPLETED = 'FETCH_COST_INFO_COMPLETED';
export const FETCH_COST_INFO_FAILED = 'FETCH_COST_INFO_FAILED'; export const FETCH_COST_INFO_FAILED = 'FETCH_COST_INFO_FAILED';
// Tags
export const TOGGLE_TAG_FOLLOW = 'TOGGLE_TAG_FOLLOW';
export const TAG_ADD = 'TAG_ADD';
export const TAG_DELETE = 'TAG_DELETE';
export const FETCH_TRENDING_STARTED = 'FETCH_TRENDING_STARTED';
export const FETCH_TRENDING_COMPLETED = 'FETCH_TRENDING_COMPLETED';
export const FETCH_TRENDING_FAILED = 'FETCH_TRENDING_FAILED';

21
src/constants/tags.js Normal file
View file

@ -0,0 +1,21 @@
export const defaultFollowedTags = [
'gaming',
'blockchain',
'news',
'learning',
'funny',
'technology',
'automotive',
'economics',
'sports',
'food',
'science',
'art',
'nature',
'beliefs',
'music',
'pop culture',
'weapons',
];
export const defaultRecommendedTags = [];

View file

@ -87,6 +87,8 @@ export {
doUpdateBlockHeight, doUpdateBlockHeight,
} from 'redux/actions/wallet'; } from 'redux/actions/wallet';
export { doToggleTagFollow, doAddTag, doDeleteTag, doFetchByTags } from 'redux/actions/tags';
// utils // utils
export { batchActions } from 'util/batchActions'; export { batchActions } from 'util/batchActions';
export { parseQueryParams, toQueryString } from 'util/query_params'; export { parseQueryParams, toQueryString } from 'util/query_params';
@ -101,6 +103,7 @@ export { notificationsReducer } from 'redux/reducers/notifications';
export { searchReducer } from 'redux/reducers/search'; export { searchReducer } from 'redux/reducers/search';
export { walletReducer } from 'redux/reducers/wallet'; export { walletReducer } from 'redux/reducers/wallet';
export { contentReducer } from 'redux/reducers/content'; export { contentReducer } from 'redux/reducers/content';
export { tagsReducer } from 'redux/reducers/tags';
// selectors // selectors
export { makeSelectContentPositionForUri } from 'redux/selectors/content'; export { makeSelectContentPositionForUri } from 'redux/selectors/content';
@ -127,6 +130,7 @@ export {
makeSelectCoverForUri, makeSelectCoverForUri,
makeSelectTitleForUri, makeSelectTitleForUri,
makeSelectDateForUri, makeSelectDateForUri,
makeSelectTagsForUri,
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
makeSelectIsUriResolving, makeSelectIsUriResolving,
makeSelectTotalItemsForChannel, makeSelectTotalItemsForChannel,
@ -177,6 +181,7 @@ export {
selectSearchDownloadUris, selectSearchDownloadUris,
selectFileListDownloadedSort, selectFileListDownloadedSort,
selectFileListPublishedSort, selectFileListPublishedSort,
selectDownloadedUris,
} from 'redux/selectors/file_info'; } from 'redux/selectors/file_info';
export { selectSearchState }; export { selectSearchState };
@ -221,3 +226,10 @@ export {
selectWalletUnlockResult, selectWalletUnlockResult,
selectTransactionListFilter, selectTransactionListFilter,
} from 'redux/selectors/wallet'; } from 'redux/selectors/wallet';
export {
selectFollowedTags,
selectUnfollowedTags,
selectTrendingUris,
selectFetchingTrending,
} from 'redux/selectors/tags';

View file

@ -7,6 +7,7 @@ import { selectMyClaimsRaw, selectResolvingUris, selectClaimsByUri } from 'redux
import { doFetchTransactions } from 'redux/actions/wallet'; import { doFetchTransactions } from 'redux/actions/wallet';
import { selectSupportsByOutpoint } from 'redux/selectors/wallet'; import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
import { creditsToString } from 'util/formatCredits'; import { creditsToString } from 'util/formatCredits';
import { batchActions } from 'util/batchActions';
export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean = false) { export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean = false) {
return (dispatch: Dispatch, getState: GetState) => { return (dispatch: Dispatch, getState: GetState) => {
@ -69,7 +70,6 @@ export function doResolveUris(uris: Array<string>, returnCachedClaims: boolean =
0; 0;
} }
} }
// $FlowFixMe // $FlowFixMe
resolveInfo[uri] = result; resolveInfo[uri] = result;
} }
@ -264,3 +264,48 @@ export function doFetchChannelListMine() {
Lbry.channel_list().then(callback); Lbry.channel_list().then(callback);
}; };
} }
export function doClaimSearch(
amount: number = 20,
options: {} = {},
cb: (?Error, ?Array<string>) => void
) {
return (dispatch: Dispatch) => {
dispatch({
type: ACTIONS.CLAIM_SEARCH_STARTED,
});
const success = (data: ClaimSearchResponse) => {
const resolveInfo = {};
const uris = [];
data.items.forEach((stream: Claim) => {
resolveInfo[stream.permanent_url] = { stream };
uris.push(stream.permanent_url);
});
dispatch({
type: ACTIONS.CLAIM_SEARCH_COMPLETED,
data: { resolveInfo },
});
if (cb) {
cb(null, uris);
}
};
const failure = err => {
dispatch({
type: ACTIONS.CLAIM_SEARCH_FAILED,
error: err,
});
if (cb) {
cb(err);
}
};
Lbry.claim_search({
page_size: amount,
...options,
}).then(success, failure);
};
}

51
src/redux/actions/tags.js Normal file
View file

@ -0,0 +1,51 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import Lbry from 'lbry';
import { doClaimSearch } from 'redux/actions/claims';
export const doToggleTagFollow = (name: string) => ({
type: ACTIONS.TOGGLE_TAG_FOLLOW,
data: {
name,
},
});
export const doAddTag = (name: string) => ({
type: ACTIONS.TAG_ADD,
data: {
name,
},
});
export const doDeleteTag = (name: string) => ({
type: ACTIONS.TAG_DELETE,
data: {
name,
},
});
export const doFetchByTags = (amount: number = 10, options: Object = {}) => {
return (dispatch: Dispatch) => {
dispatch({
type: ACTIONS.FETCH_TRENDING_STARTED,
});
const callback = (error: ?Error, uris: ?Array<string> = []) => {
if (error) {
return dispatch({
type: ACTIONS.FETCH_TRENDING_FAILED,
error,
});
}
dispatch({
type: ACTIONS.FETCH_TRENDING_COMPLETED,
data: {
uris,
},
});
};
dispatch(doClaimSearch(amount, options, callback));
};
};

View file

@ -45,7 +45,7 @@ const defaultState = {
pendingById: {}, pendingById: {},
}; };
reducers[ACTIONS.RESOLVE_URIS_COMPLETED] = (state: State, action: any): State => { function handleClaimAction(state: State, action: any): State {
const { const {
resolveInfo, resolveInfo,
}: { }: {
@ -88,6 +88,10 @@ reducers[ACTIONS.RESOLVE_URIS_COMPLETED] = (state: State, action: any): State =>
channelClaimCounts, channelClaimCounts,
resolvingUris: (state.resolvingUris || []).filter(uri => !resolveInfo[uri]), resolvingUris: (state.resolvingUris || []).filter(uri => !resolveInfo[uri]),
}); });
}
reducers[ACTIONS.RESOLVE_URIS_COMPLETED] = (state: State, action: any): State => {
return handleClaimAction(state, action);
}; };
reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED] = (state: State): State => reducers[ACTIONS.FETCH_CLAIM_LIST_MINE_STARTED] = (state: State): State =>
@ -265,6 +269,20 @@ reducers[ACTIONS.RESOLVE_URIS_STARTED] = (state: State, action: any): State => {
}); });
}; };
reducers[ACTIONS.CLAIM_SEARCH_STARTED] = (state: State): State => {
return Object.assign({}, state, {
fetchingClaimSearch: true,
});
};
reducers[ACTIONS.CLAIM_SEARCH_COMPLETED] = (state: State, action: any): State => {
return { ...handleClaimAction(state, action), fetchingClaimSearch: false };
};
reducers[ACTIONS.CLAIM_SEARCH_FAILED] = (state: State): State => {
return Object.assign({}, state, {
fetchingClaimSearch: false,
});
};
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);

View file

@ -0,0 +1,84 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import { handleActions } from 'util/redux-utils';
import { defaultRecommendedTags, defaultFollowedTags } from 'constants/tags';
function getDefaultRecommendedTags() {
return defaultFollowedTags.concat(defaultRecommendedTags).reduce(
(tagsMap, tag) => ({
...tagsMap,
[tag]: { name: tag },
}),
{}
);
}
const defaultState: TagState = {
followedTags: defaultFollowedTags,
knownTags: getDefaultRecommendedTags(),
trending: [],
fetchingTrending: false,
};
export const tagsReducer = handleActions(
{
[ACTIONS.TOGGLE_TAG_FOLLOW]: (state: TagState, action: TagAction): TagState => {
const { followedTags } = state;
const { name } = action.data;
let newFollowedTags = followedTags.slice();
if (newFollowedTags.includes(name)) {
newFollowedTags = newFollowedTags.filter(tag => tag !== name);
} else {
newFollowedTags.push(name);
}
return {
...state,
followedTags: newFollowedTags,
};
},
[ACTIONS.TAG_ADD]: (state: TagState, action: TagAction) => {
const { knownTags } = state;
const { name } = action.data;
let newKnownTags = { ...knownTags };
newKnownTags[name] = { name };
return {
...state,
knownTags: newKnownTags,
};
},
[ACTIONS.TAG_DELETE]: (state: TagState, action: TagAction) => {
const { knownTags, followedTags } = state;
const { name } = action.data;
let newKnownTags = { ...knownTags };
delete newKnownTags[name];
return {
...state,
knownTags: newKnownTags,
};
},
[ACTIONS.FETCH_TRENDING_STARTED]: (state: TagState) => ({
...state,
fetchingTrending: true,
}),
[ACTIONS.FETCH_TRENDING_COMPLETED]: (state: TagState, action: TrendingTagAction) => ({
...state,
trending: action.data.uris,
fetchingTrending: false,
}),
[ACTIONS.FETCH_TRENDING_FAILED]: (state: TagState) => ({
...state,
trending: [],
fetchingTrending: false,
}),
},
defaultState
);

View file

@ -433,3 +433,11 @@ export const makeSelectChannelForClaimUri = (uri: string, includePrefix: boolean
return includePrefix ? `lbry://${channel}` : channel; return includePrefix ? `lbry://${channel}` : channel;
} }
); );
export const makeSelectTagsForUri = (uri: string) =>
createSelector(
makeSelectMetadataForUri(uri),
(metadata: ?GenericMetadata) => {
return (metadata && metadata.tags) || [];
}
);

View file

@ -228,3 +228,9 @@ export const selectFileListDownloadedSort = createSelector(
selectState, selectState,
state => state.fileListDownloadedSort state => state.fileListDownloadedSort
); );
export const selectDownloadedUris = createSelector(
selectFileInfosDownloaded,
// We should use permament_url but it doesn't exist in file_list
info => info.map(claim => `lbry://${claim.claim_name}#${claim.claim_id}`)
);

View file

@ -0,0 +1,47 @@
// @flow
import { createSelector } from 'reselect';
const selectState = (state: { tags: TagState }) => state.tags || {};
export const selectKnownTagsByName = createSelector(
selectState,
(state: TagState): KnownTags => state.knownTags
);
export const selectFollowedTagsList = createSelector(
selectState,
(state: TagState): Array<string> => state.followedTags
);
export const selectFollowedTags = createSelector(
selectFollowedTagsList,
(followedTags: Array<string>): Array<Tag> => followedTags.map(tag => ({ name: tag }))
);
export const selectUnfollowedTags = createSelector(
selectKnownTagsByName,
selectFollowedTagsList,
(tagsByName: KnownTags, followedTags: Array<string>): Array<Tag> => {
const followedTagsSet = new Set(followedTags);
let tagsToReturn = [];
Object.keys(tagsByName).forEach(key => {
if (!followedTagsSet.has(key)) {
const { name } = tagsByName[key];
tagsToReturn.push({ name });
}
});
return tagsToReturn;
}
);
export const selectTrendingUris = createSelector(
selectState,
state => state.trending || []
);
export const selectFetchingTrending = createSelector(
selectState,
state => state.fetchingTrending
);