diff --git a/ui/component/commentCreate/view.jsx b/ui/component/commentCreate/view.jsx index 593c6ec6b..cdf9d12a0 100644 --- a/ui/component/commentCreate/view.jsx +++ b/ui/component/commentCreate/view.jsx @@ -484,8 +484,8 @@ export function CommentCreate(props: Props) { disabled={isFetchingChannels || disableInput} isLivestream={isLivestream} label={ -
- +
+ {(isReply ? __('Replying as') : isLivestream ? __('Chat as') : __('Comment as')) + ' '} diff --git a/ui/component/commentMenuList/view.jsx b/ui/component/commentMenuList/view.jsx index 04c7aa17f..d684022be 100644 --- a/ui/component/commentMenuList/view.jsx +++ b/ui/component/commentMenuList/view.jsx @@ -253,7 +253,7 @@ function CommentMenuList(props: Props) { )} - {isPinned && ( + {isPinned && isLiveComment && ( {__('Dismiss Pin')} diff --git a/ui/component/common/form-components/form-field.jsx b/ui/component/common/form-components/form-field.jsx index f9183d397..0e3561bb8 100644 --- a/ui/component/common/form-components/form-field.jsx +++ b/ui/component/common/form-components/form-field.jsx @@ -272,8 +272,8 @@ export class FormField extends React.PureComponent { )} -
- {!noEmojis && openEmoteMenu && ( + {!noEmojis && openEmoteMenu && ( +
+
+ )} ); default: diff --git a/ui/component/livestreamChatLayout/view.jsx b/ui/component/livestreamChatLayout/view.jsx index 926c19ccc..22ced1a9e 100644 --- a/ui/component/livestreamChatLayout/view.jsx +++ b/ui/component/livestreamChatLayout/view.jsx @@ -297,7 +297,6 @@ export default function LivestreamChatLayout(props: Props) { key={pinnedComment.comment_id} uri={uri} pushMention={setMention} - handleDismissPin={() => setShowPinned(false)} />
+ + + ); + + return ( + + ); + } + + return ; +}; + +export default TextareaSuggestionsInput; diff --git a/ui/component/textareaWithSuggestions/render-option.jsx b/ui/component/textareaWithSuggestions/render-option.jsx new file mode 100644 index 000000000..e2b9f896d --- /dev/null +++ b/ui/component/textareaWithSuggestions/render-option.jsx @@ -0,0 +1,24 @@ +// @flow +import { EMOTES_48px as EMOTES } from 'constants/emotes'; +import EMOJIS from 'emoji-dictionary'; +import React from 'react'; +import TextareaSuggestionsItem from 'component/textareaSuggestionsItem'; + +type Props = { + label: string, + isEmote?: boolean, + optionProps: any, +}; + +const TextareaSuggestionsOption = (props: Props) => { + const { label, isEmote, optionProps } = props; + + const emoteFound = isEmote && EMOTES.find(({ name }) => name === label); + const emoteValue = emoteFound ? { name: label, url: emoteFound.url } : undefined; + const emojiFound = isEmote && EMOJIS.getUnicode(label); + const emojiValue = emojiFound ? { name: label, unicode: emojiFound } : undefined; + + return ; +}; + +export default TextareaSuggestionsOption; diff --git a/ui/component/textareaWithSuggestions/view.jsx b/ui/component/textareaWithSuggestions/view.jsx index 498babd3b..356a1c8ae 100644 --- a/ui/component/textareaWithSuggestions/view.jsx +++ b/ui/component/textareaWithSuggestions/view.jsx @@ -2,22 +2,18 @@ import { EMOTES_48px as EMOTES } from 'constants/emotes'; import { matchSorter } from 'match-sorter'; import { SEARCH_OPTIONS } from 'constants/search'; -import * as ICONS from 'constants/icons'; import * as KEYCODES from 'constants/keycodes'; import Autocomplete from '@mui/material/Autocomplete'; import BusyIndicator from 'component/common/busy-indicator'; import EMOJIS from 'emoji-dictionary'; -import LbcSymbol from 'component/common/lbc-symbol'; import Popper from '@mui/material/Popper'; import React from 'react'; -import replaceAll from 'core-js-pure/features/string/replace-all'; -import TextareaSuggestionsItem from 'component/textareaSuggestionsItem'; -import TextField from '@mui/material/TextField'; import useLighthouse from 'effects/use-lighthouse'; import useThrottle from 'effects/use-throttle'; import { parseURI } from 'util/lbryURI'; -import Button from 'component/button'; -import { useIsMobile } from 'effects/use-screensize'; +import TextareaSuggestionsOption from './render-option'; +import TextareaSuggestionsInput from './render-input'; +import TextareaSuggestionsGroup from './render-group'; const SUGGESTION_REGEX = new RegExp( '((?:^| |\n)@[^\\s=&#$@%?:;/\\"<>%{}|^~[]*(?::[\\w]+)?)|((?:^| |\n):[\\w+-]*:?)', @@ -57,12 +53,11 @@ type Props = { maxLength?: number, placeholder?: string, searchQuery?: string, - showMature: boolean, type?: string, uri?: string, value: any, - doResolveUris: (Array) => void, - doSetMentionSearchResults: (string, Array) => void, + doResolveUris: (uris: Array, cache: boolean) => void, + doSetMentionSearchResults: (query: string, uris: Array) => void, onBlur: (any) => any, onChange: (any) => any, onFocus: (any) => any, @@ -88,7 +83,6 @@ export default function TextareaWithSuggestions(props: Props) { maxLength, placeholder, searchQuery, - showMature, type, value: messageValue, doResolveUris, @@ -101,18 +95,15 @@ export default function TextareaWithSuggestions(props: Props) { handleSubmit, } = props; - const isMobile = useIsMobile(); - const inputDefaultProps = { className, placeholder, maxLength, type, disabled }; const [suggestionValue, setSuggestionValue] = React.useState(undefined); const [highlightedSuggestion, setHighlightedSuggestion] = React.useState(''); const [shouldClose, setClose] = React.useState(); const [debouncedTerm, setDebouncedTerm] = React.useState(''); - // const [mostSupported, setMostSupported] = React.useState(''); const suggestionTerm = suggestionValue && suggestionValue.term; - const isEmote = suggestionValue && suggestionValue.isEmote; + const isEmote = Boolean(suggestionValue && suggestionValue.isEmote); const isMention = suggestionValue && !suggestionValue.isEmote; let invalidTerm = suggestionTerm && isMention && suggestionTerm.charAt(1) === ':'; @@ -125,7 +116,7 @@ export default function TextareaWithSuggestions(props: Props) { } const additionalOptions = { isBackgroundSearch: false, [SEARCH_OPTIONS.CLAIM_TYPE]: SEARCH_OPTIONS.INCLUDE_CHANNELS }; - const { results, loading } = useLighthouse(debouncedTerm, showMature, SEARCH_SIZE, additionalOptions, 0); + const { results, loading } = useLighthouse(debouncedTerm, false, SEARCH_SIZE, additionalOptions, 0); const stringifiedResults = JSON.stringify(results); const hasMinLength = suggestionTerm && isMention && suggestionTerm.length >= LIGHTHOUSE_MIN_CHARACTERS; @@ -180,7 +171,7 @@ export default function TextareaWithSuggestions(props: Props) { let emoteLabel; if (isEmote) { // $FlowFixMe - emoteLabel = `:${replaceAll(option, ':', '')}:`; + emoteLabel = `:${option.replace(/:/g, '')}:`; } return { @@ -316,14 +307,14 @@ export default function TextareaWithSuggestions(props: Props) { const arrayResults = JSON.parse(stringifiedResults); if (debouncedTerm && arrayResults && arrayResults.length > 0) { - doResolveUris([debouncedTerm, ...arrayResults]); + doResolveUris([debouncedTerm, ...arrayResults], true); doSetMentionSearchResults(debouncedTerm, arrayResults); } }, [debouncedTerm, doResolveUris, doSetMentionSearchResults, stringifiedResults, suggestionTerm]); // Only resolve commentors on Livestreams when first trying to mention/looking for it React.useEffect(() => { - if (isLivestream && commentorUris && suggestionTerm) doResolveUris(commentorUris); + if (isLivestream && commentorUris && suggestionTerm) doResolveUris(commentorUris, true); }, [commentorUris, doResolveUris, isLivestream, suggestionTerm]); // Allow selecting with TAB key @@ -371,58 +362,6 @@ export default function TextareaWithSuggestions(props: Props) { /** Render **/ /** ------ **/ - const renderGroup = (groupName: string, children: any) => ( -
- - {children} -
-
- ); - - const renderInput = (params: any) => { - const { InputProps, disabled, fullWidth, id, inputProps: autocompleteInputProps } = params; - - if (isMobile) { - InputProps.startAdornment =