Skip to content

Commit

Permalink
refactor: Improve error handling and initialization logic in init.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyzen committed Aug 19, 2024
1 parent b8bebd6 commit 966b83f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions woonuxt_base/app/plugins/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
initialised = true;

const { refreshCart } = useCart();
const success = await refreshCart();
const success: boolean = await refreshCart();

useGqlError((err: any) => {
const serverErrors = ['The iss do not match with this server', 'Invalid session token'];
Expand Down Expand Up @@ -54,10 +54,10 @@ export default defineNuxtPlugin(async (nuxtApp) => {

// If we are in development mode, we want to initialise the store immediately
const isDev = process.env.NODE_ENV === 'development';

// Check if the current route path is one of the pages that need immediate initialization
const pagesToInitializeRightAway = ['/checkout', '/my-account', '/order-summary'];
const isPathThatRequiresInit = pagesToInitializeRightAway.some(page => useRoute().path.includes(page));
const isPathThatRequiresInit = pagesToInitializeRightAway.some((page) => useRoute().path.includes(page));

const shouldInit = isDev || isPathThatRequiresInit || !storeSettings.initStoreOnUserActionToReduceServerLoad;

Expand Down

0 comments on commit 966b83f

Please sign in to comment.