mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-09-16 01:56:55 +00:00
Fix tab-complete not sorting favored emotes from add-ons (#639)
Additionally, there's no early return in the `getMatchedEmotes` method anymore, since it could be that the results we get from Twitch could exceed 25 emotes and thus would cause potential favored FFZ Emotes / Add-On Emotes / Emoji to not show up at the top of the list
This commit is contained in:
parent
60e8fad4fa
commit
f32b2efd1a
1 changed files with 24 additions and 31 deletions
|
@ -339,8 +339,6 @@ export default class Input extends Module {
|
||||||
inst.getMatchedEmotes = function(input) {
|
inst.getMatchedEmotes = function(input) {
|
||||||
const limitResults = t.chat.context.get('chat.tab-complete.limit-results');
|
const limitResults = t.chat.context.get('chat.tab-complete.limit-results');
|
||||||
let results = t.getTwitchEmoteSuggestions(input, this);
|
let results = t.getTwitchEmoteSuggestions(input, this);
|
||||||
if ( limitResults && results.length >= 25 )
|
|
||||||
return t.sortFavorites(results).slice(0, 25);
|
|
||||||
|
|
||||||
if ( t.chat.context.get('chat.tab-complete.ffz-emotes') ) {
|
if ( t.chat.context.get('chat.tab-complete.ffz-emotes') ) {
|
||||||
const ffz_emotes = t.getEmoteSuggestions(input, this);
|
const ffz_emotes = t.getEmoteSuggestions(input, this);
|
||||||
|
@ -348,15 +346,11 @@ export default class Input extends Module {
|
||||||
results = results.concat(ffz_emotes);
|
results = results.concat(ffz_emotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( limitResults && results.length >= 25 )
|
if ( t.chat.context.get('chat.tab-complete.emoji') ) {
|
||||||
return t.sortFavorites(results).slice(0, 25);
|
const emoji = t.getEmojiSuggestions(input, this);
|
||||||
|
if ( Array.isArray(emoji) && emoji.length )
|
||||||
if ( ! t.chat.context.get('chat.tab-complete.emoji') )
|
results = Array.isArray(results) ? results.concat(emoji) : emoji;
|
||||||
return results;
|
}
|
||||||
|
|
||||||
const emoji = t.getEmojiSuggestions(input, this);
|
|
||||||
if ( Array.isArray(emoji) && emoji.length )
|
|
||||||
results = Array.isArray(results) ? results.concat(emoji) : emoji;
|
|
||||||
|
|
||||||
results = t.sortFavorites(results);
|
results = t.sortFavorites(results);
|
||||||
return limitResults && results.length > 25 ? results.slice(0, 25) : results;
|
return limitResults && results.length > 25 ? results.slice(0, 25) : results;
|
||||||
|
@ -405,12 +399,10 @@ export default class Input extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
return results.sort((a, b) => {
|
return results.sort((a, b) => {
|
||||||
const a_fav = a.favorite;
|
if (a.favorite) {
|
||||||
const b_fav = b.favorite;
|
return b.favorite ? a.replacement.localeCompare(b.replacement) : -1;
|
||||||
if (a_fav) {
|
|
||||||
return b_fav ? a.replacement.localeCompare(b.replacement) : -1;
|
|
||||||
}
|
}
|
||||||
else if (b_fav) {
|
else if (b.favorite) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -528,28 +520,29 @@ export default class Input extends Module {
|
||||||
|
|
||||||
const search = input.startsWith(':') ? input.slice(1) : input,
|
const search = input.startsWith(':') ? input.slice(1) : input,
|
||||||
results = [],
|
results = [],
|
||||||
emotes = this.emotes.getEmotes(
|
sets = this.emotes.getSets(
|
||||||
user && user.id,
|
user && user.id,
|
||||||
user && user.login,
|
user && user.login,
|
||||||
channel_id,
|
channel_id,
|
||||||
channel_login
|
channel_login
|
||||||
);
|
);
|
||||||
|
|
||||||
for(const emote of Object.values(emotes))
|
for(const set of sets)
|
||||||
if ( inst.doesEmoteMatchTerm(emote, search) ) {
|
for(const emote of Object.values(set.emotes))
|
||||||
const favorite = this.emotes.isFavorite(emote.token.provider, emote.id);
|
if ( inst.doesEmoteMatchTerm(emote, search) ) {
|
||||||
results.push({
|
const favorite = this.emotes.isFavorite(set.source || 'ffz', emote.id);
|
||||||
current: input,
|
results.push({
|
||||||
replacement: emote.name,
|
current: input,
|
||||||
element: inst.renderEmoteSuggestion({
|
replacement: emote.name,
|
||||||
token: emote.name,
|
element: inst.renderEmoteSuggestion({
|
||||||
id: `${emote.token.provider}-${emote.id}`,
|
token: emote.name,
|
||||||
srcSet: emote.srcSet,
|
id: `${set.source}-${emote.id}`,
|
||||||
|
srcSet: emote.srcSet,
|
||||||
|
favorite
|
||||||
|
}),
|
||||||
favorite
|
favorite
|
||||||
}),
|
});
|
||||||
favorite
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue