[Glitch] Fix emoji autosuggestions
Port 32d2260a8c to glitch-soc
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
			
			
This commit is contained in:
		
							parent
							
								
									c3c61f3011
								
							
						
					
					
						commit
						f0c559250c
					
				
					 4 changed files with 17 additions and 17 deletions
				
			
		| 
						 | 
					@ -444,13 +444,13 @@ export const readyComposeSuggestionsTags = (token, tags) => ({
 | 
				
			||||||
export function selectComposeSuggestion(position, token, suggestion, path) {
 | 
					export function selectComposeSuggestion(position, token, suggestion, path) {
 | 
				
			||||||
  return (dispatch, getState) => {
 | 
					  return (dispatch, getState) => {
 | 
				
			||||||
    let completion;
 | 
					    let completion;
 | 
				
			||||||
    if (typeof suggestion === 'object' && suggestion.id) {
 | 
					    if (suggestion.type === 'emoji') {
 | 
				
			||||||
      dispatch(useEmoji(suggestion));
 | 
					      dispatch(useEmoji(suggestion));
 | 
				
			||||||
      completion = suggestion.native || suggestion.colons;
 | 
					      completion = suggestion.native || suggestion.colons;
 | 
				
			||||||
    } else if (typeof suggestion === 'object' && suggestion.name) {
 | 
					    } else if (suggestion.type === 'hashtag') {
 | 
				
			||||||
      completion = `#${suggestion.name}`;
 | 
					      completion = `#${suggestion.name}`;
 | 
				
			||||||
    } else {
 | 
					    } else if (suggestion.type === 'account') {
 | 
				
			||||||
      completion = '@' + getState().getIn(['accounts', suggestion, 'acct']);
 | 
					      completion = '@' + getState().getIn(['accounts', suggestion.id, 'acct']);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dispatch({
 | 
					    dispatch({
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -168,15 +168,15 @@ export default class AutosuggestInput extends ImmutablePureComponent {
 | 
				
			||||||
    const { selectedSuggestion } = this.state;
 | 
					    const { selectedSuggestion } = this.state;
 | 
				
			||||||
    let inner, key;
 | 
					    let inner, key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (typeof suggestion === 'object' && suggestion.shortcode) {
 | 
					    if (suggestion.type === 'emoji') {
 | 
				
			||||||
      inner = <AutosuggestEmoji emoji={suggestion} />;
 | 
					      inner = <AutosuggestEmoji emoji={suggestion} />;
 | 
				
			||||||
      key   = suggestion.id;
 | 
					      key   = suggestion.id;
 | 
				
			||||||
    } else if (typeof suggestion === 'object' && suggestion.name) {
 | 
					    } else if (suggestion.type ==='hashtag') {
 | 
				
			||||||
      inner = <AutosuggestHashtag tag={suggestion} />;
 | 
					      inner = <AutosuggestHashtag tag={suggestion} />;
 | 
				
			||||||
      key   = suggestion.name;
 | 
					      key   = suggestion.name;
 | 
				
			||||||
    } else {
 | 
					    } else if (suggestion.type === 'account') {
 | 
				
			||||||
      inner = <AutosuggestAccountContainer id={suggestion} />;
 | 
					      inner = <AutosuggestAccountContainer id={suggestion.id} />;
 | 
				
			||||||
      key   = suggestion;
 | 
					      key   = suggestion.id;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -174,15 +174,15 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
 | 
				
			||||||
    const { selectedSuggestion } = this.state;
 | 
					    const { selectedSuggestion } = this.state;
 | 
				
			||||||
    let inner, key;
 | 
					    let inner, key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (typeof suggestion === 'object' && suggestion.shortcode) {
 | 
					    if (suggestion.type === 'emoji') {
 | 
				
			||||||
      inner = <AutosuggestEmoji emoji={suggestion} />;
 | 
					      inner = <AutosuggestEmoji emoji={suggestion} />;
 | 
				
			||||||
      key   = suggestion.id;
 | 
					      key   = suggestion.id;
 | 
				
			||||||
    } else if (typeof suggestion === 'object' && suggestion.name) {
 | 
					    } else if (suggestion.type === 'hashtag') {
 | 
				
			||||||
      inner = <AutosuggestHashtag tag={suggestion} />;
 | 
					      inner = <AutosuggestHashtag tag={suggestion} />;
 | 
				
			||||||
      key   = suggestion.name;
 | 
					      key   = suggestion.name;
 | 
				
			||||||
    } else {
 | 
					    } else if (suggestion.type === 'account') {
 | 
				
			||||||
      inner = <AutosuggestAccountContainer id={suggestion} />;
 | 
					      inner = <AutosuggestAccountContainer id={suggestion.id} />;
 | 
				
			||||||
      key   = suggestion;
 | 
					      key   = suggestion.id;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -288,11 +288,11 @@ const expiresInFromExpiresAt = expires_at => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const normalizeSuggestions = (state, { accounts, emojis, tags }) => {
 | 
					const normalizeSuggestions = (state, { accounts, emojis, tags }) => {
 | 
				
			||||||
  if (accounts) {
 | 
					  if (accounts) {
 | 
				
			||||||
    return accounts.map(item => item.id);
 | 
					    return accounts.map(item => ({ id: item.id, type: 'account' }));
 | 
				
			||||||
  } else if (emojis) {
 | 
					  } else if (emojis) {
 | 
				
			||||||
    return emojis;
 | 
					    return emojis.map(item => ({ ...item, type: 'emoji' }));
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    return sortHashtagsByUse(state, tags);
 | 
					    return sortHashtagsByUse(state, tags.map(item => ({ ...item, type: 'hashtag' })));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue