Browse Source

Fix emoji autosuggestions (#11442)

Regression from cfb2ed7823
master
Eugen Rochko 5 years ago
committed by GitHub
parent
commit
784c88e16d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 17 deletions
  1. +4
    -4
      app/javascript/mastodon/actions/compose.js
  2. +5
    -5
      app/javascript/mastodon/components/autosuggest_input.js
  3. +5
    -5
      app/javascript/mastodon/components/autosuggest_textarea.js
  4. +3
    -3
      app/javascript/mastodon/reducers/compose.js

+ 4
- 4
app/javascript/mastodon/actions/compose.js View File

@ -418,16 +418,16 @@ export function selectComposeSuggestion(position, token, suggestion, path) {
return (dispatch, getState) => { return (dispatch, getState) => {
let completion, startPosition; let completion, startPosition;
if (typeof suggestion === 'object' && suggestion.id) {
if (suggestion.type === 'emoji') {
completion = suggestion.native || suggestion.colons; completion = suggestion.native || suggestion.colons;
startPosition = position - 1; startPosition = position - 1;
dispatch(useEmoji(suggestion)); dispatch(useEmoji(suggestion));
} else if (typeof suggestion === 'object' && suggestion.name) {
} else if (suggestion.type === 'hashtag') {
completion = `#${suggestion.name}`; completion = `#${suggestion.name}`;
startPosition = position - 1; startPosition = position - 1;
} else {
completion = getState().getIn(['accounts', suggestion, 'acct']);
} else if (suggestion.type === 'account') {
completion = getState().getIn(['accounts', suggestion.id, 'acct']);
startPosition = position; startPosition = position;
} }

+ 5
- 5
app/javascript/mastodon/components/autosuggest_input.js View File

@ -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 {
inner = <AutosuggestAccountContainer id={suggestion} />;
key = suggestion;
} else if (suggestion.type === 'account') {
inner = <AutosuggestAccountContainer id={suggestion.id} />;
key = suggestion.id;
} }
return ( return (

+ 5
- 5
app/javascript/mastodon/components/autosuggest_textarea.js View File

@ -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 {
inner = <AutosuggestAccountContainer id={suggestion} />;
key = suggestion;
} else if (suggestion.type === 'account') {
inner = <AutosuggestAccountContainer id={suggestion.id} />;
key = suggestion.id;
} }
return ( return (

+ 3
- 3
app/javascript/mastodon/reducers/compose.js View File

@ -207,11 +207,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…
Cancel
Save