From 535bd8d8400e837837b8bea66d5acdaf73b2a433 Mon Sep 17 00:00:00 2001 From: Elias Ruiz Monserrat Date: Mon, 24 Jan 2022 00:01:28 +0100 Subject: [PATCH] Improved performance on rendering icons --- package.json | 2 +- src/App.vue | 10 ++- src/components/Home.vue | 92 +++++++++++----------- src/components/ResourcesCard.vue | 10 ++- src/components/UserIconCard.vue | 126 ++++++++++++++++--------------- src/components/UserIconGrid.vue | 34 +-------- src/main.js | 4 + src/store/store.js | 113 +++++++++++++++++---------- src/views/LearningResource.vue | 11 +-- src/views/ResourceView.vue | 12 +-- 10 files changed, 217 insertions(+), 197 deletions(-) diff --git a/package.json b/package.json index 3269d82d..057965d9 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,10 @@ "sass": "^1.45.1", "simple-git": "^2.47.0", "smoothscroll-polyfill": "^0.4.4", - "v-lazy-image": "^2.0.1", "vite": "^2.7.3", "vue": "^3.1.0", "vue-mobile-detection": "^2.0.1", + "vue3-lazyload": "^0.2.5-beta", "vuex": "^4.0.2" }, "devDependencies": { diff --git a/src/App.vue b/src/App.vue index bf812a03..6219865c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -29,6 +29,7 @@ import Footer from '@/components/Footer.vue' import Header from '@/components/Header.vue' import StickyBanner from '@/components/StickyBanner.vue' +import { mapActions } from 'vuex' import { Toast } from '@adobe/coral-spectrum/coral-component-toast' const appBody = document.getElementById('app') @@ -83,6 +84,11 @@ export default { methods:{ + ...mapActions([ + 'setDataToArr', + 'pushDataToArr', + ]), + async fetchSavedIcons(){ if (!Parse.User.current()){ return @@ -97,7 +103,7 @@ export default { let savedIcons = userSavedIconData.map(( icons ) => icons); let iconsToShow = [] - fetchSavedIcons.forEach(icon => { + savedIcons.forEach(icon => { let newIcon = {} for(let prop in icon.attributes){ newIcon[prop] = icon.attributes[prop] @@ -107,7 +113,7 @@ export default { newIcon.id = icon.id; }) - // this.pushDataToArr({ data: iconsToShow, arr: "savedIcons" }) + this.pushDataToArr({ data: iconsToShow, arr: "savedIcons" }) console.log(savedIconCount); return iconsToShow }, diff --git a/src/components/Home.vue b/src/components/Home.vue index 7a0c4b90..0e719249 100644 --- a/src/components/Home.vue +++ b/src/components/Home.vue @@ -1,11 +1,11 @@