diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index efbf534..727e1d6 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -65,6 +65,9 @@ jobs: - name: Install dependencies run: pnpm install + - name: ESlint + run: pnpm run lint + - name: Build run: | pnpm run build diff --git a/assets/ts/main.ts b/assets/ts/main.ts index ae1302d..1177033 100644 --- a/assets/ts/main.ts +++ b/assets/ts/main.ts @@ -14,9 +14,19 @@ initNav() if (ijs.length > 0) { if (!isMobile()) { import('./desktop/init') - .then((d) => d.initDesktop(ijs)) - .catch((e) => console.log(e)) + .then((d) => { + d.initDesktop(ijs) + }) + .catch((e) => { + console.log(e) + }) } else { - import('./mobile/init').then((m) => m.initMobile(ijs)).catch((e) => console.log(e)) + import('./mobile/init') + .then((m) => { + m.initMobile(ijs) + }) + .catch((e) => { + console.log(e) + }) } } diff --git a/assets/ts/state.ts b/assets/ts/state.ts index e6341a7..21eaa58 100644 --- a/assets/ts/state.ts +++ b/assets/ts/state.ts @@ -21,10 +21,8 @@ const thresholds = [ const defaultState = { index: -1, length: 0, - threshold: - thresholds[parseInt(sessionStorage.getItem('thresholdsIndex') || '2')].threshold, - trailLength: - thresholds[parseInt(sessionStorage.getItem('thresholdsIndex') || '2')].trailLength + threshold: thresholds[getThresholdSessionIndex()].threshold, + trailLength: thresholds[getThresholdSessionIndex()].trailLength } export const state = new Watchable(defaultState) @@ -75,7 +73,7 @@ export function decThreshold(): void { */ function updateThreshold(state: State, inc: number): State { - let i = thresholds.findIndex((t) => state.threshold === t.threshold) + inc + const i = thresholds.findIndex((t) => state.threshold === t.threshold) + inc // out of bounds if (i < 0 || i >= thresholds.length) return state // storage the index so we can restore it even if we go to another page @@ -83,3 +81,9 @@ function updateThreshold(state: State, inc: number): State { const newItems = thresholds[i] return { ...state, ...newItems } } + +function getThresholdSessionIndex(): number { + const s = sessionStorage.getItem('thresholdsIndex') + if (s === null) return 2 + return parseInt(s) +}