Addressing problems
This commit is contained in:
parent
81ec8d4d14
commit
9118d59878
4 changed files with 13 additions and 43 deletions
|
|
@ -112,9 +112,7 @@ function setISSCookieProperties(properties) {
|
|||
Will update the cookie if present, or create a new one if not.
|
||||
*/
|
||||
export function updateOrCreateISSCookie() {
|
||||
console.log('in cookie function');
|
||||
const store = useMainStore();
|
||||
console.log(store);
|
||||
|
||||
// Set up cookie with all the props.
|
||||
setISSCookieProperties({
|
||||
|
|
|
|||
|
|
@ -6,54 +6,23 @@ import { updateOrCreateISSCookie } from '@/helpers/cookie-helper';
|
|||
This will also set Referral information in the store after saving, and then
|
||||
update the cookie. To force synchronous behavior pass in 'true' for shouldAwaitSaveSessionQueue
|
||||
*/
|
||||
// encapsulate when you transition back into heritage
|
||||
// we need eon from first call to get pricing
|
||||
// eon is a number that some services require
|
||||
// save session takes time
|
||||
// not necessary for much throughout the flow
|
||||
// we want each save session call to happen sequentially, but asynchronously
|
||||
export async function saveSession({ shouldAwaitSaveSessionQueue = false }) {
|
||||
const store = useMainStore();
|
||||
console.log('order helper');
|
||||
console.log(store);
|
||||
var saveSessionPromise;
|
||||
if (store.applicationUser.saveSessionPromise){
|
||||
console.log('if promise exists');
|
||||
console.log(store.applicationUser.saveSessionPromise);
|
||||
var saveSessionPromise = store.applicationUser.saveSessionPromise
|
||||
? store.applicationUser.saveSessionPromise.then(() => { return saveSessionHelper(store); })
|
||||
: saveSessionHelper(store);
|
||||
|
||||
// .then returns another promise but waiting for another to finish
|
||||
saveSessionPromise = store.applicationUser.saveSessionPromise
|
||||
.then(() => {
|
||||
console.log('then');
|
||||
return saveSessionHelper(store);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("saveSessionPromise failed: " + error.message);
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log('else');
|
||||
saveSessionPromise = saveSessionHelper(store);
|
||||
}
|
||||
// var saveSessionPromise =
|
||||
// store.applicationUser.saveSessionPromise
|
||||
// ? store.applicationUser.saveSessionPromise.then(() => { return saveSessionHelper(store); })
|
||||
// : saveSessionHelper(store);
|
||||
console.log('promise exists');
|
||||
store.setSaveSessionPromise(saveSessionPromise);
|
||||
console.log('set information');
|
||||
|
||||
if (!store.applicationUser.savedSessionId || shouldAwaitSaveSessionQueue) {
|
||||
console.log('pre await');
|
||||
await saveSessionPromise;
|
||||
}
|
||||
console.log('done');
|
||||
}
|
||||
|
||||
/*
|
||||
Encapsulates asynchronous Save Session logic inside a promise to allow for Save Session queuing
|
||||
*/
|
||||
async function saveSessionHelper(store) {
|
||||
console.log('helper helper called');
|
||||
const savedSessionInfo = await store.saveSession();
|
||||
store.setSaveSessionInfo(savedSessionInfo.data);
|
||||
updateOrCreateISSCookie();
|
||||
|
|
|
|||
|
|
@ -88,13 +88,12 @@ router.afterEach(async (to, from) => {
|
|||
const store = useMainStore();
|
||||
// Update lastPageVisited in the store
|
||||
store.updateLastPageVisited(to.name);
|
||||
console.log('after each');
|
||||
|
||||
if (from.redirectedFrom == undefined){
|
||||
store.clearSaveSessionPromise();
|
||||
}
|
||||
|
||||
await saveSession({shouldAwaitSaveSessionQueue: true}).then(() => {
|
||||
console.log('then');
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
console.log("catch");
|
||||
await saveSession({shouldAwaitSaveSessionQueue: true}).catch((error) => {
|
||||
if (from.name === issPageValues.WELCOME_PAGE) {
|
||||
router.navigate(navigationScenarios.SAVE_SESSION_FAILED, {query: {issPage: issPageValues.WELCOME_PAGE}})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -806,6 +806,10 @@ export const useMainStore = defineStore({
|
|||
this.applicationUser.saveSessionPromise = promise;
|
||||
},
|
||||
|
||||
clearSaveSessionPromise(){
|
||||
this.applicationUser.saveSessionPromise = null;
|
||||
},
|
||||
|
||||
saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount) {
|
||||
const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
|
||||
const isGlassToReplaceTheSame
|
||||
|
|
|
|||
Loading…
Reference in a new issue