Skip to content

Commit

Permalink
refactor(suggestion): cache emojimart data import
Browse files Browse the repository at this point in the history
  • Loading branch information
shuuji3 committed Jan 21, 2024
1 parent f9d8ed0 commit c6c8004
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions composables/tiptap/suggestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ export const TiptapEmojiSuggestion: Partial<SuggestionOptions> = {

const lowerCaseQuery = query.toLowerCase()

const emojis = await import('@emoji-mart/data')
.then(r => r.default as EmojiMartData)
.then(data => Object.values(data.emojis).filter(({ id }) => id.toLowerCase().startsWith(lowerCaseQuery)))
const { data } = await useAsyncData<EmojiMartData>('emoji-data', () => import('@emoji-mart/data').then(r => r.default))

Check failure on line 67 in composables/tiptap/suggestion.ts

View workflow job for this annotation

GitHub Actions / ci

No overload matches this call.
const emojis: Emoji[] = Object.values(data.value.emojis).filter(({ id }) => id.toLowerCase().startsWith(lowerCaseQuery))

Check failure on line 68 in composables/tiptap/suggestion.ts

View workflow job for this annotation

GitHub Actions / ci

'data.value' is possibly 'null'.

Check failure on line 68 in composables/tiptap/suggestion.ts

View workflow job for this annotation

GitHub Actions / ci

Property 'emojis' does not exist on type 'NonNullable<PickFrom<ResT, KeysOf<DataT>>>'.

Check failure on line 68 in composables/tiptap/suggestion.ts

View workflow job for this annotation

GitHub Actions / ci

No overload matches this call.

const customEmojis: CustomEmoji[] = currentCustomEmojis.value.emojis
.filter(emoji => emoji.shortcode.toLowerCase().startsWith(lowerCaseQuery))
Expand Down

0 comments on commit c6c8004

Please sign in to comment.