Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopping cart bug fixes 1 #144

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export class CheckoutOverlayComponent implements OnInit, OnDestroy {
(<any>val).payload?.chainReference,
);

this.removePurchasedGroupItems();
this.currentStep = StepType.COMPLETE;
this.updateStep(this.currentStep);
this.cd.markForCheck();
Expand Down Expand Up @@ -493,7 +494,8 @@ export class CheckoutOverlayComponent implements OnInit, OnDestroy {
private removePurchasedGroupItems(): void {
if (this.selectedNetwork) {
this.cartService.removeGroupItemsFromCart(this.selectedNetwork);
this.cartService.clearNetworkSelection();
} else {
this.cartService.removeGroupItemsFromCart();
}
}

Expand Down
45 changes: 39 additions & 6 deletions src/app/components/cart/services/cart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Nft,
Collection,
Transaction,
TransactionType,
MIN_AMOUNT_TO_TRANSFER,
TRANSACTION_AUTO_EXPIRY_MS,
DEFAULT_NETWORK,
Expand Down Expand Up @@ -172,13 +173,31 @@ export class CartService {
transaction.payload?.void ||
transaction.payload?.reconciled
) {
removeItem(StorageItem.CheckoutTransaction);
this.pendingTransaction$.next(undefined);
this.triggerChangeDetectionSubject$.next();
clearInterval(this.transactionCheckInterval);
this.transactionCheckInterval = null;
if (transaction.payload?.reconciled) {
this.removeGroupItemsFromCart();
this.notification.success($localize`NFT(s) successfully purchased.`, '');
this.setCurrentStep(StepType.CONFIRM);
removeItem(StorageItem.CheckoutTransaction);
this.pendingTransaction$.next(undefined);
this.triggerChangeDetectionSubject$.next();
clearInterval(this.transactionCheckInterval);
this.transactionCheckInterval = null;
} else if (transaction.payload?.void && !transaction.payload?.reconciled) {
this.notification.error($localize`NFT purchase transaction expired.`, '');
this.setCurrentStep(StepType.CONFIRM);
removeItem(StorageItem.CheckoutTransaction);
this.pendingTransaction$.next(undefined);
this.triggerChangeDetectionSubject$.next();
clearInterval(this.transactionCheckInterval);
this.transactionCheckInterval = null;
} else {
removeItem(StorageItem.CheckoutTransaction);
this.pendingTransaction$.next(undefined);
this.triggerChangeDetectionSubject$.next();
}
}
} else {
this.setCurrentStep(StepType.CONFIRM);
removeItem(StorageItem.CheckoutTransaction);
this.pendingTransaction$.next(undefined);
this.triggerChangeDetectionSubject$.next();
Expand Down Expand Up @@ -688,7 +707,21 @@ export class CartService {
return this.calc(itemPrice, discount);
}

public removeGroupItemsFromCart(tokenSymbol: string): void {
public removeGroupItemsFromCart(tokenSymbol?: string): void {
if (!tokenSymbol) {
this.selectedNetwork$.pipe(take(1)).subscribe((defaultTokenSymbol) => {
if (defaultTokenSymbol == null) {
console.warn('No default token symbol found, no updates performed.');
} else {
this.performCartUpdate(defaultTokenSymbol);
}
});
} else {
this.performCartUpdate(tokenSymbol);
}
}

private performCartUpdate(tokenSymbol: string): void {
const updatedCartItems = this.cartItemsSubject$.value.filter((item) => {
const itemTokenSymbol =
(item.nft?.placeholderNft
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ <h3 class="mb-1 text-2xl font-bold truncate">{{ getTitle() }}</h3>
>
</wen-send-funds>

<div>network print: {{ collection?.mintingData?.network }}</div>
<wen-wallet-deeplink
*ngIf="!helper.isExpired(transaction$ | async)"
class="mt-6"
Expand Down
Loading