Merge pull request #261 from lbryio/publish-language

Publish language fix (@Yamboy1's changes)
This commit is contained in:
Sean Yesmunt 2020-01-16 11:01:43 -05:00 committed by GitHub
commit a93b09c6bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 151 additions and 131 deletions

233
dist/bundle.es.js vendored

File diff suppressed because one or more lines are too long

View file

@ -43,7 +43,7 @@ const defaultState: PublishState = {
thumbnailPath: '',
uploadThumbnailStatus: THUMBNAIL_STATUSES.API_DOWN,
description: '',
language: 'en',
language: '',
nsfw: false,
channel: CHANNEL_ANONYMOUS,
channelId: '',

View file

@ -9,23 +9,9 @@ import {
const selectState = state => state.publish || {};
export const selectPublishFormValues = createSelector(
selectState,
state => {
const { pendingPublish, ...formValues } = state;
return formValues;
}
);
export const makeSelectPublishFormValue = item =>
createSelector(
selectState,
state => state[item]
);
// Is the current uri the same as the uri they clicked "edit" on
export const selectIsStillEditing = createSelector(
selectPublishFormValues,
selectState,
publishState => {
const { editingURI, uri } = publishState;
@ -52,6 +38,29 @@ export const selectIsStillEditing = createSelector(
}
);
export const selectPublishFormValues = createSelector(
selectState,
selectIsStillEditing,
(state, isStillEditing) => {
const { pendingPublish, language, languages, ...formValues } = state;
let actualLanguage;
// Sets default if editing a claim with a set language
if (!language && isStillEditing && languages[0]) {
actualLanguage = languages[0];
} else {
actualLanguage = language || 'en';
}
return { ...formValues, language: actualLanguage };
}
);
export const makeSelectPublishFormValue = item =>
createSelector(
selectState,
state => state[item]
);
export const selectMyClaimForUri = createSelector(
selectPublishFormValues,
selectIsStillEditing,
@ -68,10 +77,10 @@ export const selectMyClaimForUri = createSelector(
return isStillEditing
? claimsById[editClaimId]
: myClaims.find(claim =>
!contentName
? claim.name === claimName
: claim.name === contentName || claim.name === claimName
);
!contentName
? claim.name === claimName
: claim.name === contentName || claim.name === claimName
);
}
);