1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-03 00:18:31 +00:00

Adds toggle for new emote sorting behavior

This commit is contained in:
cfinegan 2022-01-20 21:48:43 -05:00
parent c4301a234d
commit 0ea064ad68

View file

@ -128,6 +128,15 @@ export default class Input extends Module {
}
});
this.settings.add('chat.tab-complete.prioritize-prefix-matches', {
default: false,
ui: {
path: 'Chat > Input >> Tab Completion',
title: 'Prioritize emotes that start with user input.',
component: 'setting-check-box'
}
});
// Components
@ -664,6 +673,7 @@ export default class Input extends Module {
sortEmotes(emotes) {
const preferFavorites = this.chat.context.get('chat.tab-complete.prioritize-favorites');
const canBeTriggeredByTab = this.chat.context.get('chat.tab-complete.emotes-without-colon');
const prioritizePrefixMatches = this.chat.context.get('chat.tab-complete.prioritize-prefix-matches');
return emotes.sort((a, b) => {
const aStr = a.matched || a.replacement;
@ -673,6 +683,7 @@ export default class Input extends Module {
if (preferFavorites && (a.favorite ^ b.favorite))
return 0 - a.favorite + b.favorite;
if (prioritizePrefixMatches) {
// Prefer emoji over emotes if tab-complete is enabled, disprefer them otherwise
const aIsEmoji = !!a.matched;
const bIsEmoji = !!b.matched;
@ -699,6 +710,10 @@ export default class Input extends Module {
// Else alphabetize
return locale.compare(aStr, bStr);
}
// Keep unsorted order for non-favorite items if prefix matching is not enabled.
return 0;
});
}