Adding parameter to indicate whether save session should be synchronous

This commit is contained in:
brydon1 2023-08-31 16:53:53 -04:00
parent 9118d59878
commit 8bbd7afb77
2 changed files with 8 additions and 3 deletions

View file

@ -17,6 +17,7 @@ import applicationConfig from '@/constants/application-config';
import analyticsMixin from '@/mixins/analytics-mixin';
import navigationScenarios from './router-constants/navigation-scenarios';
import { saveSession } from "@/helpers/order-helper.js";
import routerParams from '@/router/router-constants/router-params';
const routes = [
{
@ -93,9 +94,12 @@ router.afterEach(async (to, from) => {
store.clearSaveSessionPromise();
}
await saveSession({shouldAwaitSaveSessionQueue: true}).catch((error) => {
const saveSessionSynchronous = !!from.params[routerParams.SAVE_SESSION_SYNCHRONOUS];
await saveSession({shouldAwaitSaveSessionQueue: saveSessionSynchronous}).catch((error) => {
if (from.name === issPageValues.WELCOME_PAGE) {
router.navigate(navigationScenarios.SAVE_SESSION_FAILED, {query: {issPage: issPageValues.WELCOME_PAGE}})
router.navigate(
navigationScenarios.SAVE_SESSION_FAILED,
{query: {issPage: issPageValues.WELCOME_PAGE}});
}
});

View file

@ -1,5 +1,6 @@
const routerParams = Object.freeze({
DISPLAY_VEHICLE_CHANGE_ALERT: 'displayVehicleChangeAlert'
DISPLAY_VEHICLE_CHANGE_ALERT: 'displayVehicleChangeAlert',
SAVE_SESSION_SYNCHRONOUS: 'saveSessionSynchronous'
});
export default routerParams;