Preserve hashtag casing in threaded mode
Inspired by f9b23a5d6247445ea5b70b431c934a4bb99213bc
This commit is contained in:
		
							parent
							
								
									14563f5167
								
							
						
					
					
						commit
						e3246cd13b
					
				@ -39,6 +39,7 @@ import { privacyPreference } from 'flavours/glitch/util/privacy_preference';
 | 
				
			|||||||
import { me } from 'flavours/glitch/util/initial_state';
 | 
					import { me } from 'flavours/glitch/util/initial_state';
 | 
				
			||||||
import { overwrite } from 'flavours/glitch/util/js_helpers';
 | 
					import { overwrite } from 'flavours/glitch/util/js_helpers';
 | 
				
			||||||
import { unescapeHTML } from 'flavours/glitch/util/html';
 | 
					import { unescapeHTML } from 'flavours/glitch/util/html';
 | 
				
			||||||
 | 
					import { recoverHashtags } from 'flavours/glitch/util/hashtag';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const totalElefriends = 3;
 | 
					const totalElefriends = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -114,8 +115,9 @@ function apiStatusToTextMentions (state, status) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function apiStatusToTextHashtags (state, status) {
 | 
					function apiStatusToTextHashtags (state, status) {
 | 
				
			||||||
  return ImmutableOrderedSet([]).union(status.tags.map(
 | 
					  const text = unescapeHTML(status.content);
 | 
				
			||||||
    ({ name }) => `#${name} `
 | 
					  return ImmutableOrderedSet([]).union(recoverHashtags(status.tags, text).map(
 | 
				
			||||||
 | 
					    (name) => `#${name} `
 | 
				
			||||||
  )).join('');
 | 
					  )).join('');
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										8
									
								
								app/javascript/flavours/glitch/util/hashtag.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								app/javascript/flavours/glitch/util/hashtag.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					export function recoverHashtags (recognizedTags, text) {
 | 
				
			||||||
 | 
					  return recognizedTags.map(tag => {
 | 
				
			||||||
 | 
					      const re = new RegExp(`(?:^|[^\/\)\w])#(${tag.name})`, 'i');
 | 
				
			||||||
 | 
					      const matched_hashtag = text.match(re);
 | 
				
			||||||
 | 
					      return matched_hashtag ? matched_hashtag[1] : tag;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user