fix: FavoriteEmojiFirst (#1844)

This commit is contained in:
Syncx 2023-10-25 21:05:50 +05:30 committed by V
parent 9c60b38acc
commit b659d4e9c1

@ -39,22 +39,27 @@ export default definePlugin({
description: "Puts your favorite emoji first in the emoji autocomplete.", description: "Puts your favorite emoji first in the emoji autocomplete.",
patches: [ patches: [
{ {
find: ".activeCommandOption", find: "renderResults({results:",
replacement: [ replacement: [
{ {
// = someFunc(a.selectedIndex); ...trackEmojiSearch({ state: theState, isInPopoutExperimental: someBool }) // https://regex101.com/r/N7kpLM/1
match: /=\i\(\i\.selectedIndex\);(?=.+?state:(\i),isInPopoutExperiment:\i)/, match: /let \i=.{1,100}renderResults\({results:(\i)\.query\.results,/,
// self.sortEmojis(theState) replace: "$self.sortEmojis($1);$&"
replace: "$&$self.sortEmojis($1);"
}, },
],
},
{
find: "MAX_AUTOCOMPLETE_RESULTS+",
replacement: [
// set maxCount to Infinity so our sortEmojis callback gets the entire list, not just the first 10 // set maxCount to Infinity so our sortEmojis callback gets the entire list, not just the first 10
// and remove Discord's emojiResult slice, storing the endIndex on the array for us to use later // and remove Discord's emojiResult slice, storing the endIndex on the array for us to use later
{ {
// https://regex101.com/r/x2mobQ/1
// searchEmojis(...,maxCount: stuff) ... endEmojis = emojis.slice(0, maxCount - gifResults.length) // searchEmojis(...,maxCount: stuff) ... endEmojis = emojis.slice(0, maxCount - gifResults.length)
match: /,maxCount:(\i)(.+?)=(\i)\.slice\(0,(\1-\i\.length)\)/, match: /,maxCount:(\i)(.{1,500}\i)=(\i)\.slice\(0,(\i-\i\.length)\)/,
// ,maxCount:Infinity ... endEmojis = (emojis.sliceTo = n, emojis) // ,maxCount:Infinity ... endEmojis = (emojis.sliceTo = n, emojis)
replace: ",maxCount:Infinity$2=($3.sliceTo=$4,$3)" replace: ",maxCount:Infinity$2=($3.sliceTo = $4, $3)"
} }
] ]
} }