From 8c0bfbb2f4299ef9cc1daffc7ec2a63a2bb8071c Mon Sep 17 00:00:00 2001 From: Sanskar Soni Date: Tue, 19 Sep 2023 14:51:46 +0530 Subject: [PATCH 1/3] Improved: ShopifyImg component now created with Vue composition API style (#170) --- src/components/ShopifyImg.ts | 52 ----------------------------------- src/components/ShopifyImg.vue | 47 +++++++++++++++++++++++++++++++ src/components/index.ts | 5 +++- src/index.ts | 3 +- 4 files changed, 52 insertions(+), 55 deletions(-) delete mode 100644 src/components/ShopifyImg.ts create mode 100644 src/components/ShopifyImg.vue diff --git a/src/components/ShopifyImg.ts b/src/components/ShopifyImg.ts deleted file mode 100644 index 4323be3..0000000 --- a/src/components/ShopifyImg.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { defineComponent } from "vue" -import { shopifyImgContext as context } from "../index"; - -export default defineComponent({ - template: ` - - `, - data() { - return { - imageUrl: context.defaultImgUrl - } - }, - props: ['src', 'size'], - mounted() { - this.setImageUrl(); - }, - updated() { - this.setImageUrl(); - }, - methods: { - prepareImgUrl(src: string, size?: string) { - // return original size if no size is given - if (!size) return src - // remove any current image size then add the new image size - return src - .replace(/_(pico|icon|thumb|small|compact|medium|large|grande|original|1024x1024|2048x2048|master)+\./g, '.') - .replace(/\.jpg|\.png|\.gif|\.jpeg/g, function (match) { - return '_' + size + match; - }) - }, - checkIfImageExists(src: string) { - return new Promise((resolve, reject) => { - const img = new Image(); - img.onload = function () { - resolve(true); - } - img.onerror = function () { - reject(false); - } - img.src = src; - }) - }, - setImageUrl() { - if (this.src) { - const src: string = this.prepareImgUrl(this.src, this.size) - this.checkIfImageExists(src).then(() => { - this.imageUrl = src; - }) - } - } - } -}) \ No newline at end of file diff --git a/src/components/ShopifyImg.vue b/src/components/ShopifyImg.vue new file mode 100644 index 0000000..c7d1b4d --- /dev/null +++ b/src/components/ShopifyImg.vue @@ -0,0 +1,47 @@ + + + \ No newline at end of file diff --git a/src/components/index.ts b/src/components/index.ts index a0faf49..f38b094 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -14,5 +14,8 @@ import '@ionic/vue/css/text-transformation.css'; import '@ionic/vue/css/flex-utils.css'; import '@ionic/vue/css/display.css'; -export { default as ProductIdentifier } from "./ProductIdentifier.vue"; +import ProductIdentifier from './ProductIdentifier.vue'; +import ShopifyImg from './ShopifyImg.vue'; + +export { ProductIdentifier, ShopifyImg }; diff --git a/src/index.ts b/src/index.ts index ddace5c..24dca7a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,12 +3,11 @@ import { useProductIdentificationStore } from "./store/productIdentification"; import { useAuthStore } from "./store/auth"; import Login from "./components/Login"; -import ShopifyImg from "./components/ShopifyImg"; import { goToOms } from "./utils"; import { initialiseFirebaseApp } from "./utils/firebase" import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' -import { ProductIdentifier } from "./components"; +import { ProductIdentifier, ShopifyImg } from "./components"; // TODO: handle cases when the store from app or pinia store are not available // creating a pinia store for the plugin From dd93585c3604f1ed1bcbc0207e6b0a150bd7a177 Mon Sep 17 00:00:00 2001 From: k2maan Date: Wed, 20 Sep 2023 11:28:41 +0530 Subject: [PATCH 2/3] Fixed: firebase error on login if app is not configured for notifications support --- src/components/Login.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/Login.ts b/src/components/Login.ts index 6635636..90e41e4 100644 --- a/src/components/Login.ts +++ b/src/components/Login.ts @@ -63,13 +63,16 @@ export default defineComponent({ try { await context.login({ token, oms }) - // initialising and connecting firebase app for notification support - await initialiseFirebaseApp( - noitificationContext.appFirebaseConfig, - noitificationContext.appFirebaseVapidKey, - noitificationContext.storeClientRegistrationToken, - noitificationContext.addNotification, - ) + // check if firebase if configurations are there + if (noitificationContext.appFirebaseConfig) { + // initialising and connecting firebase app for notification support + await initialiseFirebaseApp( + noitificationContext.appFirebaseConfig, + noitificationContext.appFirebaseVapidKey, + noitificationContext.storeClientRegistrationToken, + noitificationContext.addNotification, + ) + } this.router.push('/') } catch (error) { From 60cc38c5556c99fcfb9e7c37d63f18526d55942a Mon Sep 17 00:00:00 2001 From: k2maan Date: Thu, 21 Sep 2023 10:53:01 +0530 Subject: [PATCH 3/3] Fixed: typo in comment --- src/components/Login.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Login.ts b/src/components/Login.ts index 90e41e4..03d9784 100644 --- a/src/components/Login.ts +++ b/src/components/Login.ts @@ -63,7 +63,7 @@ export default defineComponent({ try { await context.login({ token, oms }) - // check if firebase if configurations are there + // check if firebase configurations are there if (noitificationContext.appFirebaseConfig) { // initialising and connecting firebase app for notification support await initialiseFirebaseApp(