]> cat aescling's git repositories - mastodon.git/commitdiff
Preserve hashtag casing in web UI hashtag history (#8394)
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 23 Aug 2018 19:21:15 +0000 (21:21 +0200)
committerGitHub <noreply@github.com>
Thu, 23 Aug 2018 19:21:15 +0000 (21:21 +0200)
Fix #8241

app/javascript/mastodon/actions/compose.js
app/javascript/mastodon/reducers/compose.js

index fe3e831d5fc621ee2c8bab495f23113792a4f76b..6d975cd1e4fa9022c0956fb0941d9fe94eee74c9 100644 (file)
@@ -130,7 +130,7 @@ export function submitCompose() {
         'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']),
       },
     }).then(function (response) {
-      dispatch(insertIntoTagHistory(response.data.tags));
+      dispatch(insertIntoTagHistory(response.data.tags, status));
       dispatch(submitComposeSuccess({ ...response.data }));
 
       // To make the app more responsive, immediately get the status into the columns
@@ -390,13 +390,13 @@ export function hydrateCompose() {
   };
 }
 
-function insertIntoTagHistory(tags) {
+function insertIntoTagHistory(recognizedTags, text) {
   return (dispatch, getState) => {
     const state = getState();
     const oldHistory = state.getIn(['compose', 'tagHistory']);
     const me = state.getIn(['meta', 'me']);
-    const names = tags.map(({ name }) => name);
-    const intersectedOldHistory = oldHistory.filter(name => !names.includes(name));
+    const names = recognizedTags.map(tag => text.match(new RegExp(`#${tag.name}`, 'i'))[0].slice(1));
+    const intersectedOldHistory = oldHistory.filter(name => names.findIndex(newName => newName.toLowerCase() === name.toLowerCase()) === -1);
 
     names.push(...intersectedOldHistory.toJS());
 
index 552f659c9276e7714ca60a78b8146313b1ef7e1f..67d55f66f0086d1eabc7d85ddade4889c338505f 100644 (file)
@@ -131,7 +131,7 @@ const updateSuggestionTags = (state, token) => {
 
   return state.merge({
     suggestions: state.get('tagHistory')
-      .filter(tag => tag.startsWith(prefix))
+      .filter(tag => tag.toLowerCase().startsWith(prefix.toLowerCase()))
       .slice(0, 4)
       .map(tag => '#' + tag),
     suggestion_token: token,