improvements
This commit is contained in:
parent
220b717fc1
commit
5ff2491e78
9 changed files with 72 additions and 52 deletions
51
dist/bundle.es.js
vendored
51
dist/bundle.es.js
vendored
|
@ -262,7 +262,7 @@ const TAG_DELETE = 'TAG_DELETE';
|
|||
const TOGGLE_BLOCK_CHANNEL = 'TOGGLE_BLOCK_CHANNEL';
|
||||
|
||||
// Sync
|
||||
const USER_SETTINGS_POPULATE = 'USER_SETTINGS_POPULATE';
|
||||
const USER_STATE_POPULATE = 'USER_STATE_POPULATE';
|
||||
|
||||
var action_types = /*#__PURE__*/Object.freeze({
|
||||
WINDOW_FOCUSED: WINDOW_FOCUSED,
|
||||
|
@ -469,7 +469,7 @@ var action_types = /*#__PURE__*/Object.freeze({
|
|||
TAG_ADD: TAG_ADD,
|
||||
TAG_DELETE: TAG_DELETE,
|
||||
TOGGLE_BLOCK_CHANNEL: TOGGLE_BLOCK_CHANNEL,
|
||||
USER_SETTINGS_POPULATE: USER_SETTINGS_POPULATE
|
||||
USER_STATE_POPULATE: USER_STATE_POPULATE
|
||||
});
|
||||
|
||||
const CC_LICENSES = [{
|
||||
|
@ -1469,7 +1469,7 @@ const selectCurrentChannelPage = reselect.createSelector(selectState$2, state =>
|
|||
|
||||
const selectCreatingChannel = reselect.createSelector(selectState$2, state => state.creatingChannel);
|
||||
|
||||
const createChannelError = reselect.createSelector(selectState$2, state => state.createChannelError);
|
||||
const selectCreateChannelError = reselect.createSelector(selectState$2, state => state.createChannelError);
|
||||
|
||||
const selectClaimsByUri = reselect.createSelector(selectState$2, selectClaimsById, (state, byId) => {
|
||||
const byUri = state.claimsByUri || {};
|
||||
|
@ -1668,9 +1668,12 @@ const selectMyClaimsOutpoints = reselect.createSelector(selectMyClaims, myClaims
|
|||
const selectFetchingMyChannels = reselect.createSelector(selectState$2, state => state.fetchingMyChannels);
|
||||
|
||||
const selectMyChannelClaims = reselect.createSelector(selectState$2, selectClaimsById, (state, byId) => {
|
||||
const ids = state.myChannelClaims || [];
|
||||
const claims = [];
|
||||
const ids = state.myChannelClaims;
|
||||
if (!ids) {
|
||||
return ids;
|
||||
}
|
||||
|
||||
const claims = [];
|
||||
ids.forEach(id => {
|
||||
if (byId[id]) {
|
||||
// I'm not sure why this check is necessary, but it ought to be a quick fix for https://github.com/lbryio/lbry-desktop/issues/544
|
||||
|
@ -2454,7 +2457,7 @@ function doCreateChannel(name, amount, optionalParams) {
|
|||
}).catch(error => {
|
||||
dispatch({
|
||||
type: CREATE_CHANNEL_FAILED,
|
||||
data: error
|
||||
data: error.message
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -3556,8 +3559,8 @@ const doToggleBlockChannel = uri => ({
|
|||
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; };
|
||||
|
||||
function extractSettings(rawObj) {
|
||||
if (rawObj && rawObj.version && rawObj.app) {
|
||||
const { subscriptions, tags } = rawObj.app;
|
||||
if (rawObj && rawObj.version === '0' && rawObj.shared) {
|
||||
const { subscriptions, tags } = rawObj.shared;
|
||||
return _extends$5({}, subscriptions ? { subscriptions } : {}, tags ? { tags } : {});
|
||||
}
|
||||
|
||||
|
@ -3567,7 +3570,7 @@ function extractSettings(rawObj) {
|
|||
function doPopulateUserSettings(settings) {
|
||||
return dispatch => {
|
||||
const { subscriptions, tags } = extractSettings(settings);
|
||||
dispatch({ type: USER_SETTINGS_POPULATE, data: { subscriptions, tags } });
|
||||
dispatch({ type: USER_STATE_POPULATE, data: { subscriptions, tags } });
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3583,7 +3586,7 @@ const defaultState = {
|
|||
resolvingUris: [],
|
||||
// This should not be a Set
|
||||
// Storing sets in reducers can cause issues
|
||||
myChannelClaims: new Set(),
|
||||
myChannelClaims: undefined,
|
||||
fetchingMyChannels: false,
|
||||
abandoningById: {},
|
||||
pendingById: {},
|
||||
|
@ -3716,13 +3719,20 @@ reducers[FETCH_CHANNEL_LIST_STARTED] = state => Object.assign({}, state, { fetch
|
|||
|
||||
reducers[FETCH_CHANNEL_LIST_COMPLETED] = (state, action) => {
|
||||
const { claims } = action.data;
|
||||
const myChannelClaims = new Set(state.myChannelClaims);
|
||||
const byId = Object.assign({}, state.byId);
|
||||
|
||||
claims.forEach(claim => {
|
||||
myChannelClaims.add(claim.claim_id);
|
||||
byId[claim.claim_id] = claim;
|
||||
});
|
||||
let myChannelClaims;
|
||||
let byId = Object.assign({}, state.byId);
|
||||
if (!claims.length) {
|
||||
// $FlowFixMe
|
||||
myChannelClaims = null;
|
||||
} else {
|
||||
myChannelClaims = new Set(state.myChannelClaims);
|
||||
claims.forEach(claim => {
|
||||
// $FlowFixMe
|
||||
myChannelClaims.add(claim.claim_id);
|
||||
byId[claim.claim_id] = claim;
|
||||
});
|
||||
}
|
||||
|
||||
return Object.assign({}, state, {
|
||||
byId,
|
||||
|
@ -4512,14 +4522,14 @@ const tagsReducer = handleActions({
|
|||
followedTags: newFollowedTags
|
||||
});
|
||||
},
|
||||
[USER_SETTINGS_POPULATE]: (state, action) => {
|
||||
[USER_STATE_POPULATE]: (state, action) => {
|
||||
const { tags } = action.data;
|
||||
let newTags;
|
||||
|
||||
if (!tags) {
|
||||
newTags = state.followedTags || DEFAULT_FOLLOWED_TAGS;
|
||||
newTags = state.followedTags.length ? state.followedTags : DEFAULT_FOLLOWED_TAGS;
|
||||
} else {
|
||||
if (!state.followedTags || !state.followedTags.length) {
|
||||
if (!state.followedTags.length) {
|
||||
newTags = tags;
|
||||
} else {
|
||||
const map = {};
|
||||
|
@ -4890,7 +4900,6 @@ const selectFollowedTags = reselect.createSelector(selectFollowedTagsList, follo
|
|||
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];
|
||||
|
@ -4938,7 +4947,6 @@ exports.claimsReducer = claimsReducer;
|
|||
exports.commentReducer = commentReducer;
|
||||
exports.contentReducer = contentReducer;
|
||||
exports.convertToShareLink = convertToShareLink;
|
||||
exports.createChannelError = createChannelError;
|
||||
exports.createNormalizedClaimSearchKey = createNormalizedClaimSearchKey;
|
||||
exports.creditsToString = creditsToString;
|
||||
exports.doAbandonClaim = doAbandonClaim;
|
||||
|
@ -5072,6 +5080,7 @@ exports.selectClaimSearchByQuery = selectClaimSearchByQuery;
|
|||
exports.selectClaimSearchByQueryLastPageReached = selectClaimSearchByQueryLastPageReached;
|
||||
exports.selectClaimsById = selectClaimsById;
|
||||
exports.selectClaimsByUri = selectClaimsByUri;
|
||||
exports.selectCreateChannelError = selectCreateChannelError;
|
||||
exports.selectCreatingChannel = selectCreatingChannel;
|
||||
exports.selectCurrentChannelPage = selectCurrentChannelPage;
|
||||
exports.selectDownloadedUris = selectDownloadedUris;
|
||||
|
|
|
@ -239,4 +239,4 @@ export const TAG_DELETE = 'TAG_DELETE';
|
|||
export const TOGGLE_BLOCK_CHANNEL = 'TOGGLE_BLOCK_CHANNEL';
|
||||
|
||||
// Sync
|
||||
export const USER_SETTINGS_POPULATE = 'USER_SETTINGS_POPULATE';
|
||||
export const USER_STATE_POPULATE = 'USER_STATE_POPULATE';
|
||||
|
|
|
@ -205,7 +205,7 @@ export {
|
|||
selectUpdatingChannel,
|
||||
selectUpdateChannelError,
|
||||
selectCreatingChannel,
|
||||
createChannelError,
|
||||
selectCreateChannelError,
|
||||
} from 'redux/selectors/claims';
|
||||
|
||||
export { makeSelectCommentsForUri } from 'redux/selectors/comments';
|
||||
|
|
|
@ -275,7 +275,7 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an
|
|||
.catch(error => {
|
||||
dispatch({
|
||||
type: ACTIONS.CREATE_CHANNEL_FAILED,
|
||||
data: error,
|
||||
data: error.message,
|
||||
});
|
||||
})
|
||||
);
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
// @flow
|
||||
import * as ACTIONS from 'constants/action_types';
|
||||
|
||||
function extractSettings(rawObj: {
|
||||
version: string,
|
||||
app: {},
|
||||
}): {
|
||||
subscriptions?: Array<string>,
|
||||
tags?: Array<string>,
|
||||
} {
|
||||
if (rawObj && rawObj.version && rawObj.app) {
|
||||
const { subscriptions, tags } = rawObj.app;
|
||||
type v0Data = {
|
||||
version: '0',
|
||||
shared: {
|
||||
subscriptions?: Array<string>,
|
||||
tags?: Array<string>,
|
||||
},
|
||||
};
|
||||
|
||||
function extractSettings(rawObj: v0Data) {
|
||||
if (rawObj && rawObj.version === '0' && rawObj.shared) {
|
||||
const { subscriptions, tags } = rawObj.shared;
|
||||
return {
|
||||
...(subscriptions ? { subscriptions } : {}),
|
||||
...(tags ? { tags } : {}),
|
||||
|
@ -20,8 +22,8 @@ function extractSettings(rawObj: {
|
|||
}
|
||||
|
||||
export function doPopulateUserSettings(settings: any) {
|
||||
return dispatch => {
|
||||
return (dispatch: Dispatch) => {
|
||||
const { subscriptions, tags } = extractSettings(settings);
|
||||
dispatch({ type: ACTIONS.USER_SETTINGS_POPULATE, data: { subscriptions, tags } });
|
||||
dispatch({ type: ACTIONS.USER_STATE_POPULATE, data: { subscriptions, tags } });
|
||||
};
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ type State = {
|
|||
byId: { [string]: Claim },
|
||||
resolvingUris: Array<string>,
|
||||
pendingById: { [string]: Claim },
|
||||
myChannelClaims: Set<string>,
|
||||
myChannelClaims: ?Set<string>,
|
||||
abandoningById: { [string]: boolean },
|
||||
fetchingChannelClaims: { [string]: number },
|
||||
fetchingMyChannels: boolean,
|
||||
|
@ -46,7 +46,7 @@ const defaultState = {
|
|||
resolvingUris: [],
|
||||
// This should not be a Set
|
||||
// Storing sets in reducers can cause issues
|
||||
myChannelClaims: new Set(),
|
||||
myChannelClaims: undefined,
|
||||
fetchingMyChannels: false,
|
||||
abandoningById: {},
|
||||
pendingById: {},
|
||||
|
@ -190,13 +190,20 @@ reducers[ACTIONS.FETCH_CHANNEL_LIST_STARTED] = (state: State): State =>
|
|||
|
||||
reducers[ACTIONS.FETCH_CHANNEL_LIST_COMPLETED] = (state: State, action: any): State => {
|
||||
const { claims }: { claims: Array<ChannelClaim> } = action.data;
|
||||
const myChannelClaims = new Set(state.myChannelClaims);
|
||||
const byId = Object.assign({}, state.byId);
|
||||
|
||||
claims.forEach(claim => {
|
||||
myChannelClaims.add(claim.claim_id);
|
||||
byId[claim.claim_id] = claim;
|
||||
});
|
||||
let myChannelClaims;
|
||||
let byId = Object.assign({}, state.byId);
|
||||
if (!claims.length) {
|
||||
// $FlowFixMe
|
||||
myChannelClaims = null;
|
||||
} else {
|
||||
myChannelClaims = new Set(state.myChannelClaims);
|
||||
claims.forEach(claim => {
|
||||
// $FlowFixMe
|
||||
myChannelClaims.add(claim.claim_id);
|
||||
byId[claim.claim_id] = claim;
|
||||
});
|
||||
}
|
||||
|
||||
return Object.assign({}, state, {
|
||||
byId,
|
||||
|
|
|
@ -65,7 +65,7 @@ export const tagsReducer = handleActions(
|
|||
followedTags: newFollowedTags,
|
||||
};
|
||||
},
|
||||
[ACTIONS.USER_SETTINGS_POPULATE]: (
|
||||
[ACTIONS.USER_STATE_POPULATE]: (
|
||||
state: TagState,
|
||||
action: { data: { tags: ?Array<string> } }
|
||||
) => {
|
||||
|
@ -73,9 +73,9 @@ export const tagsReducer = handleActions(
|
|||
let newTags;
|
||||
|
||||
if (!tags) {
|
||||
newTags = state.followedTags || DEFAULT_FOLLOWED_TAGS;
|
||||
newTags = state.followedTags.length ? state.followedTags : DEFAULT_FOLLOWED_TAGS;
|
||||
} else {
|
||||
if (!state.followedTags || !state.followedTags.length) {
|
||||
if (!state.followedTags.length) {
|
||||
newTags = tags;
|
||||
} else {
|
||||
const map = {};
|
||||
|
|
|
@ -23,7 +23,7 @@ export const selectCreatingChannel = createSelector(
|
|||
state => state.creatingChannel
|
||||
);
|
||||
|
||||
export const createChannelError = createSelector(
|
||||
export const selectCreateChannelError = createSelector(
|
||||
selectState,
|
||||
state => state.createChannelError
|
||||
);
|
||||
|
@ -240,8 +240,8 @@ export const makeSelectDateForUri = (uri: string) =>
|
|||
(claim.value.release_time
|
||||
? claim.value.release_time * 1000
|
||||
: claim.meta && claim.meta.creation_timestamp
|
||||
? claim.meta.creation_timestamp * 1000
|
||||
: null);
|
||||
? claim.meta.creation_timestamp * 1000
|
||||
: null);
|
||||
if (!timestamp) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -360,9 +360,12 @@ export const selectMyChannelClaims = createSelector(
|
|||
selectState,
|
||||
selectClaimsById,
|
||||
(state, byId) => {
|
||||
const ids = state.myChannelClaims || [];
|
||||
const claims = [];
|
||||
const ids = state.myChannelClaims;
|
||||
if (!ids) {
|
||||
return ids;
|
||||
}
|
||||
|
||||
const claims = [];
|
||||
ids.forEach(id => {
|
||||
if (byId[id]) {
|
||||
// I'm not sure why this check is necessary, but it ought to be a quick fix for https://github.com/lbryio/lbry-desktop/issues/544
|
||||
|
|
|
@ -27,7 +27,6 @@ export const selectUnfollowedTags = createSelector(
|
|||
(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];
|
||||
|
|
Loading…
Add table
Reference in a new issue