clear sessionID from URL after verification

This commit is contained in:
Abhinav-grd 2021-04-20 15:13:38 +05:30
parent 23e86be77d
commit 75a89b1d6f
2 changed files with 32 additions and 24 deletions

View file

@ -199,7 +199,7 @@ export default function Gallery(props: Props) {
setCollectionAndItsLatestFile(collectionAndItsLatestFile);
const favItemIds = await getFavItemIds(data);
setFavItemIds(favItemIds);
await checkSubscriptionPurchase(setDialogMessage);
await checkSubscriptionPurchase(setDialogMessage, router);
await syncWithRemote();
setIsFirstLoad(false);
};

View file

@ -9,6 +9,7 @@ import billingService, {
import { SUBSCRIPTION_VERIFICATION_ERROR } from './common/errorUtil';
import { getData, LS_KEYS } from './storage/localStorage';
import { MessageAttributes } from 'components/MessageDialog';
import { NextRouter } from 'next/router';
export function convertBytesToGBs(bytes, precision?): string {
return (bytes / (1024 * 1024 * 1024)).toFixed(precision ?? 2);
@ -161,8 +162,10 @@ export async function updatePaymentMethod(event, setDialogMessage, setLoading) {
}
export async function checkSubscriptionPurchase(
setDialogMessage: React.Dispatch<React.SetStateAction<MessageAttributes>>
setDialogMessage: React.Dispatch<React.SetStateAction<MessageAttributes>>,
router: NextRouter
) {
try {
const urlParams = new URLSearchParams(window.location.search);
const sessionId = urlParams.get('session_id');
if (sessionId === '-1') {
@ -189,4 +192,9 @@ export async function checkSubscriptionPurchase(
});
}
}
} catch (e) {
//ignore
} finally {
router.push('gallery', undefined, { shallow: true });
}
}