From ee2bfdcb36380204c664614cf00dd9fb5620d37e Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Wed, 2 Apr 2025 16:27:42 -0700 Subject: [PATCH 1/2] fix: integrate sendType into account and purchase stores --- web/store/account.ts | 11 +++++++++++ web/store/purchase.ts | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/web/store/account.ts b/web/store/account.ts index c64b3a666a..4e135cab73 100644 --- a/web/store/account.ts +++ b/web/store/account.ts @@ -31,6 +31,7 @@ export const useAccountStore = defineStore('account', () => { const serverAccountPayload = computed(() => serverStore.serverAccountPayload); const inIframe = computed(() => serverStore.inIframe); + const sendType = computed(() => callbackStore.sendType); // State const accountAction = ref(); @@ -84,6 +85,7 @@ export const useAccountStore = defineStore('account', () => { type: 'downgradeOs', }], inIframe.value ? 'newTab' : (autoRedirectReplace ? 'replace' : undefined), + sendType.value, ); }; @@ -97,6 +99,7 @@ export const useAccountStore = defineStore('account', () => { type: 'manage', }], inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const myKeys = async () => { @@ -114,6 +117,7 @@ export const useAccountStore = defineStore('account', () => { type: 'myKeys', }], inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const linkKey = async () => { @@ -131,6 +135,7 @@ export const useAccountStore = defineStore('account', () => { type: 'linkKey', }], inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const recover = () => { @@ -143,6 +148,7 @@ export const useAccountStore = defineStore('account', () => { type: 'recover', }], inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const replace = () => { @@ -155,6 +161,7 @@ export const useAccountStore = defineStore('account', () => { type: 'replace', }], inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const signIn = () => { @@ -167,6 +174,7 @@ export const useAccountStore = defineStore('account', () => { type: 'signIn', }], inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const signOut = () => { @@ -179,6 +187,7 @@ export const useAccountStore = defineStore('account', () => { type: 'signOut', }], inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const trialExtend = () => { @@ -191,6 +200,7 @@ export const useAccountStore = defineStore('account', () => { type: 'trialExtend', }], inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const trialStart = () => { @@ -203,6 +213,7 @@ export const useAccountStore = defineStore('account', () => { type: 'trialStart', }], inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; diff --git a/web/store/purchase.ts b/web/store/purchase.ts index 625d4be26d..bc19bc5b77 100644 --- a/web/store/purchase.ts +++ b/web/store/purchase.ts @@ -24,6 +24,7 @@ export const usePurchaseStore = defineStore('purchase', () => { type: 'activate', }], serverStore.inIframe ? 'newTab' : undefined, + callbackStore.sendType, ); }; const redeem = () => { @@ -36,6 +37,7 @@ export const usePurchaseStore = defineStore('purchase', () => { type: 'redeem', }], serverStore.inIframe ? 'newTab' : undefined, + callbackStore.sendType, ); }; const purchase = () => { @@ -48,6 +50,7 @@ export const usePurchaseStore = defineStore('purchase', () => { type: 'purchase', }], serverStore.inIframe ? 'newTab' : undefined, + callbackStore.sendType, ); }; const upgrade = () => { @@ -60,6 +63,7 @@ export const usePurchaseStore = defineStore('purchase', () => { type: 'upgrade', }], serverStore.inIframe ? 'newTab' : undefined, + callbackStore.sendType, ); }; const renew = () => { @@ -72,6 +76,7 @@ export const usePurchaseStore = defineStore('purchase', () => { type: 'renew', }], serverStore.inIframe ? 'newTab' : undefined, + callbackStore.sendType, ); }; From 4aa2b548f513461d49de081b48f630412a46e05b Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Wed, 2 Apr 2025 16:35:39 -0700 Subject: [PATCH 2/2] refactor: streamline purchase store logic by using computed properties --- web/store/purchase.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/web/store/purchase.ts b/web/store/purchase.ts index bc19bc5b77..b346cd4ccb 100644 --- a/web/store/purchase.ts +++ b/web/store/purchase.ts @@ -14,17 +14,21 @@ export const usePurchaseStore = defineStore('purchase', () => { const callbackStore = useCallbackActionsStore(); const serverStore = useServerStore(); + const serverPurchasePayload = computed(() => serverStore.serverPurchasePayload); + const inIframe = computed(() => serverStore.inIframe); + const sendType = computed(() => callbackStore.sendType); + const activate = () => { callbackStore.send( PURCHASE_CALLBACK.toString(), [{ server: { - ...serverStore.serverPurchasePayload, + ...serverPurchasePayload.value, }, type: 'activate', }], - serverStore.inIframe ? 'newTab' : undefined, - callbackStore.sendType, + inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const redeem = () => { @@ -32,12 +36,12 @@ export const usePurchaseStore = defineStore('purchase', () => { PURCHASE_CALLBACK.toString(), [{ server: { - ...serverStore.serverPurchasePayload, + ...serverPurchasePayload.value, }, type: 'redeem', }], - serverStore.inIframe ? 'newTab' : undefined, - callbackStore.sendType, + inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const purchase = () => { @@ -45,12 +49,12 @@ export const usePurchaseStore = defineStore('purchase', () => { PURCHASE_CALLBACK.toString(), [{ server: { - ...serverStore.serverPurchasePayload, + ...serverPurchasePayload.value, }, type: 'purchase', }], - serverStore.inIframe ? 'newTab' : undefined, - callbackStore.sendType, + inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const upgrade = () => { @@ -58,12 +62,12 @@ export const usePurchaseStore = defineStore('purchase', () => { PURCHASE_CALLBACK.toString(), [{ server: { - ...serverStore.serverPurchasePayload, + ...serverPurchasePayload.value, }, type: 'upgrade', }], - serverStore.inIframe ? 'newTab' : undefined, - callbackStore.sendType, + inIframe.value ? 'newTab' : undefined, + sendType.value, ); }; const renew = () => { @@ -71,12 +75,12 @@ export const usePurchaseStore = defineStore('purchase', () => { PURCHASE_CALLBACK.toString(), [{ server: { - ...serverStore.serverPurchasePayload, + ...serverPurchasePayload.value, }, type: 'renew', }], - serverStore.inIframe ? 'newTab' : undefined, - callbackStore.sendType, + inIframe.value ? 'newTab' : undefined, + sendType.value, ); };