2019-05-06 07:08:54 +02:00
|
|
|
import { removeEmoji } from './removeEmoji'
|
|
|
|
|
|
|
|
export function createAutosuggestAccessibleLabel (
|
|
|
|
autosuggestType, $omitEmojiInDisplayNames,
|
|
|
|
selectedIndex, searchResults) {
|
2019-08-03 22:49:37 +02:00
|
|
|
const selected = searchResults[selectedIndex]
|
2019-05-06 07:08:54 +02:00
|
|
|
let label
|
|
|
|
if (autosuggestType === 'emoji') {
|
|
|
|
label = `${selected.shortcode}`
|
|
|
|
} else { // account
|
|
|
|
let displayName = selected.display_name || selected.username
|
2019-08-03 22:49:37 +02:00
|
|
|
const emojis = selected.emojis || []
|
2019-05-06 07:08:54 +02:00
|
|
|
displayName = $omitEmojiInDisplayNames
|
|
|
|
? removeEmoji(displayName, emojis) || displayName
|
|
|
|
: displayName
|
|
|
|
label = `${displayName} @${selected.acct}`
|
|
|
|
}
|
|
|
|
return `${label} (${selectedIndex + 1} of ${searchResults.length}). ` +
|
|
|
|
`Press up and down arrows to review and enter to select.`
|
|
|
|
}
|