diff --git a/package.json b/package.json index 17a87785..22e4f87a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ledfx", - "version": "2.0.107-b8", + "version": "2.0.108-b1", "description": "LedFx v2 - BladeMOD!", "author": "YeonV aka Blade", "private": true, diff --git a/src/store/migrate.ts b/src/store/migrate.ts index 0fcd3231..2fe19b01 100644 --- a/src/store/migrate.ts +++ b/src/store/migrate.ts @@ -46,37 +46,64 @@ export const migrations: Migrations = { 16: (state) => ({ ...state }), 17: (state) => ({ ...state }), - 18: (state) => ({ - ...state, - updateScene: async ( - name: string, - id: string, - scene_image?: string | null, - scene_tags?: string | null, - scene_puturl?: string | null, - scene_payload?: string | null, - scene_midiactivate?: string | null, - virtuals?: Record - ) => - virtuals - ? await Ledfx('/api/scenes', 'POST', { - name, - id, - scene_image, - scene_tags, - scene_puturl, - scene_payload, - scene_midiactivate, - virtuals - }) - : await Ledfx('/api/scenes', 'POST', { - name, - id, - scene_image, - scene_tags, - scene_puturl, - scene_payload, - scene_midiactivate - }) - }) + 18: (state) => ({ ...state }), + 19: (state) => { + const { variants, ...rest } = state.uiPersist.pixelGraphSettings + return { + ...state, + uiPersist: { + ...state.uiPersist, + pixelGraphSettings: { + ...rest + } + } + } + }, + 20: (state) => { + return { + ...state, + uiPersist: { + ...state.uiPersist, + pixelGraphSettings: { + ...state.uiPersist.pixelGraphSettings, + variants: 'canvas' + } + } + } + }, + 21: (state) => { + return { + ...state, + updateScene: async ( + name: string, + id: string, + scene_image?: string | null, + scene_tags?: string | null, + scene_puturl?: string | null, + scene_payload?: string | null, + scene_midiactivate?: string | null, + virtuals?: Record + ) => + virtuals + ? await Ledfx('/api/scenes', 'POST', { + name, + id, + scene_image, + scene_tags, + scene_puturl, + scene_payload, + scene_midiactivate, + virtuals + }) + : await Ledfx('/api/scenes', 'POST', { + name, + id, + scene_image, + scene_tags, + scene_puturl, + scene_payload, + scene_midiactivate + }) + } + } } diff --git a/src/store/ui-persist/storeUIpersist.tsx b/src/store/ui-persist/storeUIpersist.tsx index eaf120f3..9881471f 100644 --- a/src/store/ui-persist/storeUIpersist.tsx +++ b/src/store/ui-persist/storeUIpersist.tsx @@ -7,7 +7,7 @@ export const PixelGraphVariants = [ ] type PixelGraphVariant = (typeof PixelGraphVariants)[number] -const storeUIPersist = (set: any) => ({ +const storeUIPersist = () => ({ infoAlerts: { scenes: true, devices: true, diff --git a/src/store/useStore.ts b/src/store/useStore.ts index 168ee02a..d9d1c735 100644 --- a/src/store/useStore.ts +++ b/src/store/useStore.ts @@ -30,7 +30,7 @@ import storeVideo from './ui/storeVideo' import storeUIPersist from './ui-persist/storeUIpersist' import storeUIPersistActions from './ui-persist/storeUIpersistActions' import storeSongDectector from './ui/storeSongDectector' -import { frontendConfig } from '../utils/helpers' +import { frontendConfig, log } from '../utils/helpers' import { migrations, MigrationState } from './migrate' const useStore = create( @@ -42,7 +42,7 @@ const useStore = create( }, (set, get) => ({ ui: storeUI(set), - uiPersist: storeUIPersist(set), + uiPersist: storeUIPersist(), spotify: storeSpotify(), qlc: storeQLC(), user: storeUser(set), @@ -77,10 +77,18 @@ const useStore = create( name: 'ledfx-storage', version: frontendConfig, migrate: (persistedState, version) => { - if (version < frontendConfig) { - return migrations[frontendConfig](persistedState as MigrationState) + log( + 'infoConfig Migrator', + `Migrating from version ${version} to ${frontendConfig}` + ) + let state = persistedState as MigrationState + for (let i = version + 1; i <= frontendConfig; i++) { + if (migrations[i]) { + state = migrations[i](state) + } } - return persistedState + + return state }, partialize: (state) => Object.fromEntries( diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index f7a654af..c3430d93 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -3,7 +3,7 @@ import { IMCell } from '../pages/Devices/EditVirtuals/EditMatrix/M.utils' export const drawerWidth = 240 -export const frontendConfig = 18 +export const frontendConfig = 21 export const formatTime = (dura: number) => { let seconds: string | number