[Glitch] Fix case-sensitive check for previously used hashtags

Port 4da5f77d92 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
main
Dean Bassett 2 years ago committed by Claire
parent 58291b31fa
commit 40fc917a86

@ -273,11 +273,12 @@ const ignoreSuggestion = (state, position, token, completion, path) => {
}; };
const sortHashtagsByUse = (state, tags) => { const sortHashtagsByUse = (state, tags) => {
const personalHistory = state.get('tagHistory'); const personalHistory = state.get('tagHistory').map(tag => tag.toLowerCase());
return tags.sort((a, b) => { const tagsWithLowercase = tags.map(t => ({ ...t, lowerName: t.name.toLowerCase() }));
const usedA = personalHistory.includes(a.name); const sorted = tagsWithLowercase.sort((a, b) => {
const usedB = personalHistory.includes(b.name); const usedA = personalHistory.includes(a.lowerName);
const usedB = personalHistory.includes(b.lowerName);
if (usedA === usedB) { if (usedA === usedB) {
return 0; return 0;
@ -287,6 +288,8 @@ const sortHashtagsByUse = (state, tags) => {
return 1; return 1;
} }
}); });
sorted.forEach(tag => delete tag.lowerName);
return sorted;
}; };
const insertEmoji = (state, position, emojiData) => { const insertEmoji = (state, position, emojiData) => {

Loading…
Cancel
Save