Make code better
refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171423739 refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171424596 refs: https://github.com/syuilo/misskey/pull/3117#pullrequestreview-171425303
This commit is contained in:
		
							parent
							
								
									200ebefe92
								
							
						
					
					
						commit
						31b7626d01
					
				
					 3 changed files with 10 additions and 6 deletions
				
			
		| 
						 | 
					@ -5,6 +5,11 @@
 | 
				
			||||||
<script lang="ts">
 | 
					<script lang="ts">
 | 
				
			||||||
import Vue from 'vue';
 | 
					import Vue from 'vue';
 | 
				
			||||||
import { lib } from 'emojilib';
 | 
					import { lib } from 'emojilib';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const findCustomEmoji = (x, emoji) =>
 | 
				
			||||||
 | 
						x.name === emoji ||
 | 
				
			||||||
 | 
						x.aliases && x.aliases.includes(emoji);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default Vue.extend({
 | 
					export default Vue.extend({
 | 
				
			||||||
	props: {
 | 
						props: {
 | 
				
			||||||
		emoji: {
 | 
							emoji: {
 | 
				
			||||||
| 
						 | 
					@ -33,7 +38,8 @@ export default Vue.extend({
 | 
				
			||||||
		exec() {
 | 
							exec() {
 | 
				
			||||||
			const { emoji, raw, customEmojis } = this;
 | 
								const { emoji, raw, customEmojis } = this;
 | 
				
			||||||
			this.name = emoji || raw;
 | 
								this.name = emoji || raw;
 | 
				
			||||||
			this.url = !raw && customEmojis && customEmojis.length ? customEmojis.find(e => e.name === emoji || e.aliases && e.aliases.includes(emoji)).url : null;
 | 
								if (!raw && customEmojis && customEmojis.length)
 | 
				
			||||||
 | 
									this.url = customEmojis.find(x => findCustomEmoji(x, emoji)).url;
 | 
				
			||||||
			if (!this.url) {
 | 
								if (!this.url) {
 | 
				
			||||||
				const char = raw || lib[emoji] && lib[emoji].char;
 | 
									const char = raw || lib[emoji] && lib[emoji].char;
 | 
				
			||||||
				if (char) {
 | 
									if (char) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								src/mfm/parse/elements/emoji.regex.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/mfm/parse/elements/emoji.regex.ts
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue