Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] fixed picker component slowing down other Vue components #38

Merged
merged 3 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/components/emoji/nimbleEmoji.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ export default {
required: true
}
},
data() {
return {
mutableData: this.data.compressed ? uncompress(this.data) : this.data,
}
},
computed: {
parsedData() {
return this.data.compressed ? uncompress(this.data) : this.data
},
emojiData() {
return getData(this.emoji, this.skin, this.set, this.parsedData)
return getData(this.emoji, this.skin, this.set, this.mutableData)
},
sanitizedData() {
return getSanitizedData(this.emoji, this.skin, this.set, this.parsedData)
return getSanitizedData(this.emoji, this.skin, this.set, this.mutableData)
},
canRender() {
return this.isCustom || this.isNative || this.hasEmoji || this.fallback
Expand Down
36 changes: 16 additions & 20 deletions src/components/picker/nimblePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="emoji-mart" :style="customStyles">
<div class="emoji-mart-bar" v-if="showCategories">
<anchors
:data="parsedData"
:i18n="mergedI18n"
:data="mutableData"
:i18n="mutableI18n"
:color="color"
:categories="filteredCategories"
:active-category="activeCategory"
Expand All @@ -15,8 +15,8 @@
<search
v-if="showSearch"
ref="search"
:data="parsedData"
:i18n="mergedI18n"
:data="mutableData"
:i18n="mutableI18n"
:emojis-to-show-filter="emojisToShowFilter"
:include="include"
:exclude="exclude"
Expand All @@ -29,8 +29,8 @@
<div class="emoji-mart-scroll" ref="scroll" @scroll="onScroll">
<category
v-show="searchEmojis"
:data="parsedData"
:i18n="mergedI18n"
:data="mutableData"
:i18n="mutableI18n"
id="search"
name="Search"
:emojis="searchEmojis"
Expand All @@ -41,8 +41,8 @@
v-show="!searchEmojis && (infiniteScroll || category == activeCategory)"
ref="categories"
:key="category.id"
:data="parsedData"
:i18n="mergedI18n"
:data="mutableData"
:i18n="mutableI18n"
:id="category.id"
:name="category.name"
:emojis="category.emojis"
Expand All @@ -52,7 +52,7 @@

<div class="emoji-mart-bar" v-if="showPreview">
<preview
:data="parsedData"
:data="mutableData"
:title="title"
:emoji="previewEmoji"
:idle-emoji="emoji"
Expand Down Expand Up @@ -132,11 +132,13 @@ export default {
}

if (this.emojisToShowFilter) {
customEmojis = customEmojis.filter(e => this.emojisToShowFilter(this.parsedData.emojis[e] || e))
recentEmojis = recentEmojis.filter(e => this.emojisToShowFilter(this.parsedData.emojis[e] || e))
customEmojis = customEmojis.filter(e => this.emojisToShowFilter(this.mutableData.emojis[e] || e))
recentEmojis = recentEmojis.filter(e => this.emojisToShowFilter(this.mutableData.emojis[e] || e))
}

return {
mutableData: this.data.compressed ? uncompress(this.data) : this.data,
mutableI18n: deepMerge(I18N, this.i18n),
activeSkin: this.skin || store.get('skin') || this.defaultSkin,
categories: [],
activeCategory: null,
Expand All @@ -147,9 +149,6 @@ export default {
}
},
computed: {
parsedData() {
return this.data.compressed ? uncompress(this.data) : this.data
},
customStyles() {
return {
width: this.calculateWidth + 'px',
Expand Down Expand Up @@ -187,23 +186,20 @@ export default {

if (this.emojisToShowFilter) {
hasEmojis = category.emojis.some((emoji) => {
return this.emojisToShowFilter(this.parsedData.emojis[emoji] || emoji)
return this.emojisToShowFilter(this.mutableData.emojis[emoji] || emoji)
})
}

return isIncluded && !isExcluded && hasEmojis
})
},
mergedI18n() {
return deepMerge(I18N, this.i18n)
}
},
created() {
let categories = this.parsedData.categories.map(c => {
let categories = this.mutableData.categories.map(c => {
let { id, name, emojis } = c

if (this.emojisToShowFilter) {
emojis = c.emojis.filter(e => this.emojisToShowFilter(this.parsedData.emojis[e] || e))
emojis = c.emojis.filter(e => this.emojisToShowFilter(this.data.emojis[e] || e))
}

return { id, name, emojis }
Expand Down