next try with deepcopy instead of shallow copy

This commit is contained in:
clauspeterhuebner 2025-04-30 15:42:15 +02:00
parent 90471ca06d
commit bf19ccee9b

View File

@ -240,13 +240,10 @@ onError(() => {
function setTransactionLinkInformation() { function setTransactionLinkInformation() {
console.log('TransactionLink.setTransactionLinkInformation... result=', result.value) console.log('TransactionLink.setTransactionLinkInformation... result=', result.value)
const { queryTransactionLink } = result.value const deepCopy = JSON.parse(JSON.stringify(result.value))
console.log( console.log('TransactionLink.setTransactionLinkInformation... deepCopy=', deepCopy)
'TransactionLink.setTransactionLinkInformation... queryTransactionLink=', if (deepCopy) {
queryTransactionLink, linkData.value = deepCopy
)
if (queryTransactionLink) {
linkData.value = queryTransactionLink
console.log('TransactionLink.setTransactionLinkInformation... linkData.value=', linkData.value) console.log('TransactionLink.setTransactionLinkInformation... linkData.value=', linkData.value)
if (linkData.value.__typename === 'ContributionLink' && store.state.token) { if (linkData.value.__typename === 'ContributionLink' && store.state.token) {
console.log('TransactionLink.setTransactionLinkInformation... typename === ContributionLink') console.log('TransactionLink.setTransactionLinkInformation... typename === ContributionLink')
@ -258,16 +255,12 @@ function setTransactionLinkInformation() {
function setRedeemJwtLinkInformation() { function setRedeemJwtLinkInformation() {
console.log('TransactionLink.setRedeemJwtLinkInformation... result=', result.value) console.log('TransactionLink.setRedeemJwtLinkInformation... result=', result.value)
// Make a shallow copy to break reactivity/read-only const deepCopy = JSON.parse(JSON.stringify(result.value))
const queryTransactionLink = { ...result.value } console.log('TransactionLink.setRedeemJwtLinkInformation... deepCopy=', deepCopy)
console.log( if (deepCopy) {
'TransactionLink.setRedeemJwtLinkInformation... queryTransactionLink=',
queryTransactionLink,
)
if (queryTransactionLink) {
// recipientUser is only set if the user is logged in // recipientUser is only set if the user is logged in
if (store.state.gradidoID !== null) { if (store.state.gradidoID !== null) {
queryTransactionLink.recipientUser = { deepCopy.recipientUser = {
__typename: 'User', __typename: 'User',
gradidoID: store.state.gradidoID, gradidoID: store.state.gradidoID,
firstName: store.state.firstName, firstName: store.state.firstName,
@ -276,16 +269,16 @@ function setRedeemJwtLinkInformation() {
} }
console.log( console.log(
'TransactionLink.setRedeemJwtLinkInformation... recipientUser=', 'TransactionLink.setRedeemJwtLinkInformation... recipientUser=',
queryTransactionLink.recipientUser, deepCopy.recipientUser,
) )
linkData.value = { ...queryTransactionLink } linkData.value = deepCopy
console.log('TransactionLink.setRedeemJwtLinkInformation... linkData.value=', linkData.value) console.log('TransactionLink.setRedeemJwtLinkInformation... linkData.value=', linkData.value)
} }
} }
async function mutationLink(amount) { async function mutationLink(amount) {
console.log('TransactionLink.mutationLink... params=', params) console.log('TransactionLink.mutationLink... params=', params)
if (isDisbursementLink.value) { if (isRedeemJwtLink.value) {
console.log('TransactionLink.mutationLink... trigger disbursement from recipient-community') console.log('TransactionLink.mutationLink... trigger disbursement from recipient-community')
try { try {
await disburseMutate({ await disburseMutate({