lbry-desktop/ui/component/textareaWithSuggestions/index.js

47 lines
1.6 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { doResolveUris } from 'redux/actions/claims';
2021-12-07 19:17:29 +01:00
import { doSetMentionSearchResults } from 'redux/actions/search';
import { makeSelectWinningUriForQuery } from 'redux/selectors/search';
import { MAX_LIVESTREAM_COMMENTS } from 'constants/livestream';
import { selectChannelMentionData } from 'redux/selectors/comments';
import { selectShowMatureContent } from 'redux/selectors/settings';
import { withRouter } from 'react-router';
2021-12-10 21:03:53 +01:00
import replaceAll from 'core-js-pure/features/string/replace-all';
import TextareaWithSuggestions from './view';
const select = (state, props) => {
const { pathname } = props.location;
2021-12-10 21:03:53 +01:00
const uri = `lbry:/${replaceAll(pathname, ':', '#')}`;
2021-12-07 19:17:29 +01:00
const maxComments = props.isLivestream ? MAX_LIVESTREAM_COMMENTS : -1;
const data = selectChannelMentionData(state, uri, maxComments);
2021-12-07 15:51:55 +01:00
const {
canonicalCommentors,
canonicalCreatorUri,
canonicalSearch,
canonicalSubscriptions,
commentorUris,
hasNewResolvedResults,
2021-12-07 19:17:29 +01:00
query,
2021-12-07 15:51:55 +01:00
} = data;
return {
canonicalCommentors,
canonicalCreatorUri,
canonicalSearch,
canonicalSubscriptions,
2021-12-07 19:17:29 +01:00
canonicalTop: makeSelectWinningUriForQuery(query)(state),
commentorUris,
2021-12-07 15:51:55 +01:00
hasNewResolvedResults,
2021-12-07 19:17:29 +01:00
searchQuery: query,
showMature: selectShowMatureContent(state),
};
};
const perform = (dispatch) => ({
doResolveUris: (uris) => dispatch(doResolveUris(uris, true)),
2021-12-07 19:17:29 +01:00
doSetMentionSearchResults: (query, uris) => dispatch(doSetMentionSearchResults(query, uris)),
});
export default withRouter(connect(select, perform)(TextareaWithSuggestions));