Skip to content

Commit bc5597b

Browse files
committed
Improves cart addition logic and library loading
Eliminates redundant cart item quantity merging to prevent overcounting and ensures the payment library loads with the client key after mount. These updates enhance reliability of cart handling and payment setup.
1 parent 336875b commit bc5597b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/Pay.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import { Strings } from './i18n'
7171
import PosMp4 from './images/pos-terminal.mp4'
7272
import { Signer } from 'ethers'
7373
import { PluginId } from './constants'
74+
import { loadLibrary } from './utils'
7475
7576
const props = defineProps<{
7677
cart?: boolean
@@ -105,6 +106,11 @@ let signer: Signer | undefined
105106
106107
onMounted(async () => {
107108
i18n.value = i18nBase(navigator.languages)
109+
110+
whenDefined(import.meta.env.PUBLIC_POP_CLIENT_KEY, (clientKey) => {
111+
loadLibrary({ clientKey })
112+
})
113+
108114
const { connection } = await import('@devprotocol/clubs-core/connection')
109115
110116
connection().account.subscribe(async (acc) => {

src/api/add-cart.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { bytes32Hex, ClubsOffering } from '@devprotocol/clubs-core'
99
import { verify } from '../utils/account'
1010
import { CartItem } from '../types'
11-
import { getCartItem, getLatestSession, updateCart } from '../db/cart'
11+
import { getLatestSession, updateCart } from '../db/cart'
1212
import { headers } from '../fixtures/url/json'
1313

1414
/**
@@ -70,20 +70,14 @@ export const addCartHandler: ({
7070
getLatestSession({ scope, eoa: user }).catch((err) => new Error(err)),
7171
)
7272

73-
const existingItem = await whenNotErrorAll(
74-
[props, eoa, session],
75-
([{ payload }, _eoa, _session]) =>
76-
getCartItem({ scope, eoa: _eoa, payload, session: _session }),
77-
)
78-
7973
const item = whenNotErrorAll(
80-
[eoa, props, existingItem, session, exists],
81-
([_eoa, _props, _existingItem, _session]) =>
74+
[eoa, props, session, exists],
75+
([_eoa, _props, _session]) =>
8276
({
8377
scope,
8478
eoa: _eoa,
8579
payload: _props.payload,
86-
quantity: _props.quantity + (_existingItem?.quantity ?? 0),
80+
quantity: _props.quantity,
8781
session: _session,
8882
}) satisfies CartItem,
8983
)

0 commit comments

Comments
 (0)