Merge pull request #280 from lbryio/enforce-channel-comments
Enforce channel comments
This commit is contained in:
commit
a2304c00ca
8 changed files with 111 additions and 47 deletions
43
dist/bundle.es.js
vendored
43
dist/bundle.es.js
vendored
|
@ -1618,7 +1618,14 @@ var _extends$2 = Object.assign || function (target) { for (var i = 1; i < argume
|
||||||
|
|
||||||
function extractUserState(rawObj) {
|
function extractUserState(rawObj) {
|
||||||
if (rawObj && rawObj.version === '0.1' && rawObj.value) {
|
if (rawObj && rawObj.version === '0.1' && rawObj.value) {
|
||||||
const { subscriptions, tags, blocked, settings, app_welcome_version, sharing_3P } = rawObj.value;
|
const {
|
||||||
|
subscriptions,
|
||||||
|
tags,
|
||||||
|
blocked,
|
||||||
|
settings,
|
||||||
|
app_welcome_version,
|
||||||
|
sharing_3P
|
||||||
|
} = rawObj.value;
|
||||||
|
|
||||||
return _extends$2({}, subscriptions ? { subscriptions } : {}, tags ? { tags } : {}, blocked ? { blocked } : {}, settings ? { settings } : {}, app_welcome_version ? { app_welcome_version } : {}, sharing_3P ? { sharing_3P } : {});
|
return _extends$2({}, subscriptions ? { subscriptions } : {}, tags ? { tags } : {}, blocked ? { blocked } : {}, settings ? { settings } : {}, app_welcome_version ? { app_welcome_version } : {}, sharing_3P ? { sharing_3P } : {});
|
||||||
}
|
}
|
||||||
|
@ -1628,10 +1635,24 @@ function extractUserState(rawObj) {
|
||||||
|
|
||||||
function doPopulateSharedUserState(sharedSettings) {
|
function doPopulateSharedUserState(sharedSettings) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
const { subscriptions, tags, blocked, settings, app_welcome_version, sharing_3P } = extractUserState(sharedSettings);
|
const {
|
||||||
|
subscriptions,
|
||||||
|
tags,
|
||||||
|
blocked,
|
||||||
|
settings,
|
||||||
|
app_welcome_version,
|
||||||
|
sharing_3P
|
||||||
|
} = extractUserState(sharedSettings);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: USER_STATE_POPULATE,
|
type: USER_STATE_POPULATE,
|
||||||
data: { subscriptions, tags, blocked, settings, welcomeVersion: app_welcome_version, allowAnalytics: sharing_3P }
|
data: {
|
||||||
|
subscriptions,
|
||||||
|
tags,
|
||||||
|
blocked,
|
||||||
|
settings,
|
||||||
|
welcomeVersion: app_welcome_version,
|
||||||
|
allowAnalytics: sharing_3P
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4365,9 +4386,23 @@ function doCommentCreate(comment = '', claim_id = '', channel, parent_id) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: COMMENT_CREATE_STARTED
|
type: COMMENT_CREATE_STARTED
|
||||||
});
|
});
|
||||||
|
|
||||||
const myChannels = selectMyChannelClaims(state);
|
const myChannels = selectMyChannelClaims(state);
|
||||||
const namedChannelClaim = myChannels && myChannels.find(myChannel => myChannel.name === channel);
|
const namedChannelClaim = myChannels && myChannels.find(myChannel => myChannel.name === channel);
|
||||||
const channel_id = namedChannelClaim ? namedChannelClaim.claim_id : null;
|
const channel_id = namedChannelClaim.claim_id;
|
||||||
|
|
||||||
|
if (channel_id == null) {
|
||||||
|
dispatch({
|
||||||
|
type: COMMENT_CREATE_FAILED,
|
||||||
|
data: {}
|
||||||
|
});
|
||||||
|
dispatch(doToast({
|
||||||
|
message: 'Channel cannot be anonymous, please select a channel and try again.',
|
||||||
|
isError: true
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return lbryProxy.comment_create({
|
return lbryProxy.comment_create({
|
||||||
comment: comment,
|
comment: comment,
|
||||||
claim_id: claim_id,
|
claim_id: claim_id,
|
||||||
|
|
|
@ -42,7 +42,7 @@ export function doCommentList(uri: string, page: number = 1, pageSize: number =
|
||||||
export function doCommentCreate(
|
export function doCommentCreate(
|
||||||
comment: string = '',
|
comment: string = '',
|
||||||
claim_id: string = '',
|
claim_id: string = '',
|
||||||
channel: ?string,
|
channel: string,
|
||||||
parent_id?: string
|
parent_id?: string
|
||||||
) {
|
) {
|
||||||
return (dispatch: Dispatch, getState: GetState) => {
|
return (dispatch: Dispatch, getState: GetState) => {
|
||||||
|
@ -50,10 +50,26 @@ export function doCommentCreate(
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.COMMENT_CREATE_STARTED,
|
type: ACTIONS.COMMENT_CREATE_STARTED,
|
||||||
});
|
});
|
||||||
|
|
||||||
const myChannels = selectMyChannelClaims(state);
|
const myChannels = selectMyChannelClaims(state);
|
||||||
const namedChannelClaim =
|
const namedChannelClaim =
|
||||||
myChannels && myChannels.find(myChannel => myChannel.name === channel);
|
myChannels && myChannels.find(myChannel => myChannel.name === channel);
|
||||||
const channel_id = namedChannelClaim ? namedChannelClaim.claim_id : null;
|
const channel_id = namedChannelClaim.claim_id;
|
||||||
|
|
||||||
|
if (channel_id == null) {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.COMMENT_CREATE_FAILED,
|
||||||
|
data: {},
|
||||||
|
});
|
||||||
|
dispatch(
|
||||||
|
doToast({
|
||||||
|
message: 'Channel cannot be anonymous, please select a channel and try again.',
|
||||||
|
isError: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return Lbry.comment_create({
|
return Lbry.comment_create({
|
||||||
comment: comment,
|
comment: comment,
|
||||||
claim_id: claim_id,
|
claim_id: claim_id,
|
||||||
|
|
|
@ -119,12 +119,12 @@ export const doUploadThumbnail = (
|
||||||
.then(json =>
|
.then(json =>
|
||||||
json.success
|
json.success
|
||||||
? dispatch({
|
? dispatch({
|
||||||
type: ACTIONS.UPDATE_PUBLISH_FORM,
|
type: ACTIONS.UPDATE_PUBLISH_FORM,
|
||||||
data: {
|
data: {
|
||||||
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
|
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
|
||||||
thumbnail: `${json.data.url}.${fileExt}`,
|
thumbnail: `${json.data.url}.${fileExt}`,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
: uploadError(json.message)
|
: uploadError(json.message)
|
||||||
)
|
)
|
||||||
.catch(err => uploadError(err.message));
|
.catch(err => uploadError(err.message));
|
||||||
|
@ -159,12 +159,12 @@ export const doUploadThumbnail = (
|
||||||
.then(json =>
|
.then(json =>
|
||||||
json.success
|
json.success
|
||||||
? dispatch({
|
? dispatch({
|
||||||
type: ACTIONS.UPDATE_PUBLISH_FORM,
|
type: ACTIONS.UPDATE_PUBLISH_FORM,
|
||||||
data: {
|
data: {
|
||||||
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
|
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
|
||||||
thumbnail: `${json.data.url}${fileExt}`,
|
thumbnail: `${json.data.url}${fileExt}`,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
: uploadError(json.message)
|
: uploadError(json.message)
|
||||||
)
|
)
|
||||||
.catch(err => uploadError(err.message));
|
.catch(err => uploadError(err.message));
|
||||||
|
|
|
@ -16,7 +16,14 @@ type SharedData = {
|
||||||
|
|
||||||
function extractUserState(rawObj: SharedData) {
|
function extractUserState(rawObj: SharedData) {
|
||||||
if (rawObj && rawObj.version === '0.1' && rawObj.value) {
|
if (rawObj && rawObj.version === '0.1' && rawObj.value) {
|
||||||
const { subscriptions, tags, blocked, settings, app_welcome_version, sharing_3P } = rawObj.value;
|
const {
|
||||||
|
subscriptions,
|
||||||
|
tags,
|
||||||
|
blocked,
|
||||||
|
settings,
|
||||||
|
app_welcome_version,
|
||||||
|
sharing_3P,
|
||||||
|
} = rawObj.value;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...(subscriptions ? { subscriptions } : {}),
|
...(subscriptions ? { subscriptions } : {}),
|
||||||
|
@ -24,7 +31,7 @@ function extractUserState(rawObj: SharedData) {
|
||||||
...(blocked ? { blocked } : {}),
|
...(blocked ? { blocked } : {}),
|
||||||
...(settings ? { settings } : {}),
|
...(settings ? { settings } : {}),
|
||||||
...(app_welcome_version ? { app_welcome_version } : {}),
|
...(app_welcome_version ? { app_welcome_version } : {}),
|
||||||
...(sharing_3P ? { sharing_3P} : {}),
|
...(sharing_3P ? { sharing_3P } : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,10 +40,24 @@ function extractUserState(rawObj: SharedData) {
|
||||||
|
|
||||||
export function doPopulateSharedUserState(sharedSettings: any) {
|
export function doPopulateSharedUserState(sharedSettings: any) {
|
||||||
return (dispatch: Dispatch) => {
|
return (dispatch: Dispatch) => {
|
||||||
const { subscriptions, tags, blocked, settings, app_welcome_version, sharing_3P } = extractUserState(sharedSettings);
|
const {
|
||||||
|
subscriptions,
|
||||||
|
tags,
|
||||||
|
blocked,
|
||||||
|
settings,
|
||||||
|
app_welcome_version,
|
||||||
|
sharing_3P,
|
||||||
|
} = extractUserState(sharedSettings);
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.USER_STATE_POPULATE,
|
type: ACTIONS.USER_STATE_POPULATE,
|
||||||
data: { subscriptions, tags, blocked, settings, welcomeVersion: app_welcome_version, allowAnalytics: sharing_3P },
|
data: {
|
||||||
|
subscriptions,
|
||||||
|
tags,
|
||||||
|
blocked,
|
||||||
|
settings,
|
||||||
|
welcomeVersion: app_welcome_version,
|
||||||
|
allowAnalytics: sharing_3P,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,12 +233,12 @@ export const makeSelectSearchDownloadUrlsForPage = (query, page = 1) =>
|
||||||
|
|
||||||
return matchingFileInfos && matchingFileInfos.length
|
return matchingFileInfos && matchingFileInfos.length
|
||||||
? matchingFileInfos.slice(start, end).map(fileInfo =>
|
? matchingFileInfos.slice(start, end).map(fileInfo =>
|
||||||
buildURI({
|
buildURI({
|
||||||
streamName: fileInfo.claim_name,
|
streamName: fileInfo.claim_name,
|
||||||
channelName: fileInfo.channel_name,
|
channelName: fileInfo.channel_name,
|
||||||
channelClaimId: fileInfo.channel_claim_id,
|
channelClaimId: fileInfo.channel_claim_id,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -77,10 +77,10 @@ export const selectMyClaimForUri = createSelector(
|
||||||
return isStillEditing
|
return isStillEditing
|
||||||
? claimsById[editClaimId]
|
? claimsById[editClaimId]
|
||||||
: myClaims.find(claim =>
|
: myClaims.find(claim =>
|
||||||
!contentName
|
!contentName
|
||||||
? claim.name === claimName
|
? claim.name === claimName
|
||||||
: claim.name === contentName || claim.name === claimName
|
: claim.name === contentName || claim.name === claimName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -172,21 +172,15 @@ type CustomOptions = {
|
||||||
from?: number,
|
from?: number,
|
||||||
related_to?: string,
|
related_to?: string,
|
||||||
nsfw?: boolean,
|
nsfw?: boolean,
|
||||||
}
|
};
|
||||||
|
|
||||||
export const makeSelectQueryWithOptions = (
|
export const makeSelectQueryWithOptions = (customQuery: ?string, options: CustomOptions) =>
|
||||||
customQuery: ?string,
|
|
||||||
options: CustomOptions,
|
|
||||||
) =>
|
|
||||||
createSelector(
|
createSelector(
|
||||||
selectSearchValue,
|
selectSearchValue,
|
||||||
selectSearchOptions,
|
selectSearchOptions,
|
||||||
(query, defaultOptions) => {
|
(query, defaultOptions) => {
|
||||||
const searchOptions = { ...defaultOptions, ...options };
|
const searchOptions = { ...defaultOptions, ...options };
|
||||||
const queryString = getSearchQueryString(
|
const queryString = getSearchQueryString(customQuery || query, searchOptions);
|
||||||
customQuery || query,
|
|
||||||
searchOptions,
|
|
||||||
);
|
|
||||||
|
|
||||||
return queryString;
|
return queryString;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,7 @@ export function toQueryString(params: { [string]: string | number }) {
|
||||||
return parts.join('&');
|
return parts.join('&');
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSearchQueryString = (
|
export const getSearchQueryString = (query: string, options: any = {}) => {
|
||||||
query: string,
|
|
||||||
options: any = {},
|
|
||||||
) => {
|
|
||||||
const encodedQuery = encodeURIComponent(query);
|
const encodedQuery = encodeURIComponent(query);
|
||||||
const queryParams = [
|
const queryParams = [
|
||||||
`s=${encodedQuery}`,
|
`s=${encodedQuery}`,
|
||||||
|
@ -44,7 +41,8 @@ export const getSearchQueryString = (
|
||||||
`from=${options.from || DEFAULT_SEARCH_RESULT_FROM}`,
|
`from=${options.from || DEFAULT_SEARCH_RESULT_FROM}`,
|
||||||
];
|
];
|
||||||
const { isBackgroundSearch } = options;
|
const { isBackgroundSearch } = options;
|
||||||
const includeUserOptions = typeof isBackgroundSearch === 'undefined' ? false : !isBackgroundSearch;
|
const includeUserOptions =
|
||||||
|
typeof isBackgroundSearch === 'undefined' ? false : !isBackgroundSearch;
|
||||||
|
|
||||||
if (includeUserOptions) {
|
if (includeUserOptions) {
|
||||||
const claimType = options[SEARCH_OPTIONS.CLAIM_TYPE];
|
const claimType = options[SEARCH_OPTIONS.CLAIM_TYPE];
|
||||||
|
@ -70,7 +68,7 @@ export const getSearchQueryString = (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const additionalOptions = {}
|
const additionalOptions = {};
|
||||||
const { related_to } = options;
|
const { related_to } = options;
|
||||||
const { nsfw } = options;
|
const { nsfw } = options;
|
||||||
if (related_to) additionalOptions['related_to'] = related_to;
|
if (related_to) additionalOptions['related_to'] = related_to;
|
||||||
|
|
Loading…
Reference in a new issue