mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 15:27:43 +00:00
sortEmotes now prefers or disprefers emojis based on user settings
Previously, it erroneously sorted them based on the value of the emoji's codepoint sequence.
This commit is contained in:
parent
19445fd5b0
commit
c4301a234d
1 changed files with 11 additions and 2 deletions
|
@ -663,15 +663,24 @@ export default class Input extends Module {
|
||||||
// eslint-disable-next-line class-methods-use-this
|
// eslint-disable-next-line class-methods-use-this
|
||||||
sortEmotes(emotes) {
|
sortEmotes(emotes) {
|
||||||
const preferFavorites = this.chat.context.get('chat.tab-complete.prioritize-favorites');
|
const preferFavorites = this.chat.context.get('chat.tab-complete.prioritize-favorites');
|
||||||
|
const canBeTriggeredByTab = this.chat.context.get('chat.tab-complete.emotes-without-colon');
|
||||||
|
|
||||||
return emotes.sort((a, b) => {
|
return emotes.sort((a, b) => {
|
||||||
const aStr = a.replacement;
|
const aStr = a.matched || a.replacement;
|
||||||
const bStr = b.replacement;
|
const bStr = b.matched || b.replacement;
|
||||||
|
|
||||||
// Prefer favorites over non-favorites, if enabled
|
// Prefer favorites over non-favorites, if enabled
|
||||||
if (preferFavorites && (a.favorite ^ b.favorite))
|
if (preferFavorites && (a.favorite ^ b.favorite))
|
||||||
return 0 - a.favorite + b.favorite;
|
return 0 - a.favorite + b.favorite;
|
||||||
|
|
||||||
|
// Prefer emoji over emotes if tab-complete is enabled, disprefer them otherwise
|
||||||
|
const aIsEmoji = !!a.matched;
|
||||||
|
const bIsEmoji = !!b.matched;
|
||||||
|
if (aIsEmoji ^ bIsEmoji) {
|
||||||
|
if (canBeTriggeredByTab) return 0 - aIsEmoji + bIsEmoji;
|
||||||
|
else return 0 - bIsEmoji + aIsEmoji;
|
||||||
|
}
|
||||||
|
|
||||||
// Prefer case-sensitive prefix matches
|
// Prefer case-sensitive prefix matches
|
||||||
const aStartsWithInput = (a.match_type === EXACT_PREFIX_MATCH);
|
const aStartsWithInput = (a.match_type === EXACT_PREFIX_MATCH);
|
||||||
const bStartsWithInput = (b.match_type === EXACT_PREFIX_MATCH);
|
const bStartsWithInput = (b.match_type === EXACT_PREFIX_MATCH);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue