diff options
author | Dean Bassett <dean@dbassett.dev> | 2023-02-13 05:54:08 -0800 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2023-02-13 20:05:36 +0100 |
commit | 40fc917a8616898b842ab9f59c81e67a464c3483 (patch) | |
tree | b6bf560ee1418475a4c034661d1abebe2ea36e1e /app/javascript/flavours | |
parent | 58291b31fa8eff7bb5dd76b605377a33a977fa5a (diff) |
[Glitch] Fix case-sensitive check for previously used hashtags
Port 4da5f77d929d6b83c134cae1eefbc8ba2db752f8 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours')
-rw-r--r-- | app/javascript/flavours/glitch/reducers/compose.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index c31cc5694..109e4c723 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -273,11 +273,12 @@ const ignoreSuggestion = (state, position, token, completion, path) => { }; const sortHashtagsByUse = (state, tags) => { - const personalHistory = state.get('tagHistory'); + const personalHistory = state.get('tagHistory').map(tag => tag.toLowerCase()); - return tags.sort((a, b) => { - const usedA = personalHistory.includes(a.name); - const usedB = personalHistory.includes(b.name); + const tagsWithLowercase = tags.map(t => ({ ...t, lowerName: t.name.toLowerCase() })); + const sorted = tagsWithLowercase.sort((a, b) => { + const usedA = personalHistory.includes(a.lowerName); + const usedB = personalHistory.includes(b.lowerName); if (usedA === usedB) { return 0; @@ -287,6 +288,8 @@ const sortHashtagsByUse = (state, tags) => { return 1; } }); + sorted.forEach(tag => delete tag.lowerName); + return sorted; }; const insertEmoji = (state, position, emojiData) => { |