[Glitch] Add autosuggestions for hashtags

Port cfb2ed7823 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
This commit is contained in:
Eugen Rochko
2019-07-28 14:37:52 +02:00
committed by ThibG
parent 147e90f35d
commit 3380e96449
6 changed files with 105 additions and 26 deletions

View File

@ -1,6 +1,7 @@
import React from 'react';
import AutosuggestAccountContainer from 'flavours/glitch/features/compose/containers/autosuggest_account_container';
import AutosuggestEmoji from './autosuggest_emoji';
import AutosuggestHashtag from './autosuggest_hashtag';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { isRtl } from 'flavours/glitch/util/rtl';
@ -167,12 +168,12 @@ export default class AutosuggestInput extends ImmutablePureComponent {
const { selectedSuggestion } = this.state;
let inner, key;
if (typeof suggestion === 'object') {
if (typeof suggestion === 'object' && suggestion.shortcode) {
inner = <AutosuggestEmoji emoji={suggestion} />;
key = suggestion.id;
} else if (suggestion[0] === '#') {
inner = suggestion;
key = suggestion;
} else if (typeof suggestion === 'object' && suggestion.name) {
inner = <AutosuggestHashtag tag={suggestion} />;
key = suggestion.name;
} else {
inner = <AutosuggestAccountContainer id={suggestion} />;
key = suggestion;