Skip to content

Commit 8ea9803

Browse files
authored
fix(composables): Correct inverted logic in version check causing infinite loop thus OOM (#421)
Corrects the `satisfiesVersionBy` logic in the `useVersionedLocalStorage` composable. The previous implementation (`v !== '1.0.2'`) was inverted, causing it to return `false` for the valid version. This triggered the `onVersionMismatch` handler, which reset the data, re-triggered the `watch` effect, and resulted in an infinite recursive update loop, crashing the application. The condition has been changed to `v === '1.0.2' to correctly validate the version and prevent the loop. I though this is tauri fault, but kek just silly mistake Fix #414 #375 #400
1 parent 7f2ab0e commit 8ea9803

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/stage-tamagotchi/src/stores/shortcuts.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const useShortcutsStore = defineStore('shortcuts', () => {
7373
const shortcuts = ref([
7474
{
7575
name: 'tamagotchi.settings.pages.themes.window-shortcuts.toggle-move.label',
76-
shortcut: useVersionedLocalStorage('shortcuts/window/move', 'Shift+Alt+N', { defaultVersion: '1.0.2', satisfiesVersionBy: v => v !== '1.0.2', onVersionMismatch: () => ({ action: 'reset' }) }), // Shift + Alt + N
76+
shortcut: useVersionedLocalStorage('shortcuts/window/move', 'Shift+Alt+N', { defaultVersion: '1.0.2', satisfiesVersionBy: v => v === '1.0.2', onVersionMismatch: () => ({ action: 'reset' }) }), // Shift + Alt + N
7777
group: 'window',
7878
type: 'move',
7979
handle: async () => {
@@ -82,7 +82,7 @@ export const useShortcutsStore = defineStore('shortcuts', () => {
8282
},
8383
{
8484
name: 'tamagotchi.settings.pages.themes.window-shortcuts.toggle-resize.label',
85-
shortcut: useVersionedLocalStorage('shortcuts/window/resize', 'Shift+Alt+A', { defaultVersion: '1.0.2', satisfiesVersionBy: v => v !== '1.0.2', onVersionMismatch: () => ({ action: 'reset' }) }), // Shift + Alt + A
85+
shortcut: useVersionedLocalStorage('shortcuts/window/resize', 'Shift+Alt+A', { defaultVersion: '1.0.2', satisfiesVersionBy: v => v === '1.0.2', onVersionMismatch: () => ({ action: 'reset' }) }), // Shift + Alt + A
8686
group: 'window',
8787
type: 'resize',
8888
handle: async () => {
@@ -91,7 +91,7 @@ export const useShortcutsStore = defineStore('shortcuts', () => {
9191
},
9292
{
9393
name: 'tamagotchi.settings.pages.themes.window-shortcuts.toggle-ignore-mouse-event.label',
94-
shortcut: useVersionedLocalStorage('shortcuts/window/debug', 'Shift+Alt+I', { defaultVersion: '1.0.2', satisfiesVersionBy: v => v !== '1.0.2', onVersionMismatch: () => ({ action: 'reset' }) }), // Shift + Alt + I
94+
shortcut: useVersionedLocalStorage('shortcuts/window/debug', 'Shift+Alt+I', { defaultVersion: '1.0.2', satisfiesVersionBy: v => v === '1.0.2', onVersionMismatch: () => ({ action: 'reset' }) }), // Shift + Alt + I
9595
group: 'window',
9696
type: 'ignore-mouse-event',
9797
handle: async () => {

0 commit comments

Comments
 (0)