From 82718f73f706529a3575ffe75de550be6dc1a072 Mon Sep 17 00:00:00 2001 From: YeonV Date: Sun, 19 Jan 2025 16:53:18 +0100 Subject: [PATCH] add examples for future_blade --- src/store/migrate.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/store/migrate.ts b/src/store/migrate.ts index fbab05e7..ef4205c5 100644 --- a/src/store/migrate.ts +++ b/src/store/migrate.ts @@ -1,5 +1,8 @@ /* eslint-disable no-unused-vars */ /* eslint-disable @typescript-eslint/no-unused-vars */ + +import { produce } from 'immer' + export interface MigrationState { [key: string]: any } @@ -9,14 +12,17 @@ interface Migrations { } export const migrations: Migrations = { - // Removes an existing function (deprecatedFunction) - 13: (state) => { - const { deprecatedFunction, ...rest } = state - return { - ...rest - // Remove a deprecated function + // Adds a new key + 11: produce((draft) => { + draft.uiPersist = draft.uiPersist || {} + draft.uiPersist.testZustand = { test: true } + }), + // Removes a key + 12: produce((draft) => { + if (draft.uiPersist) { + delete draft.uiPersist.testZustand } - }, + }), // Removes an existing value (deprecatedValue) and repositions an existing value (existingValue) based on another value (anotherValue) 14: (state) => { @@ -38,8 +44,5 @@ export const migrations: Migrations = { }), 16: (state) => ({ ...state }), - 17: (state) => ({ - ...state - // Add new state properties or transform existing ones - }) + 17: (state) => ({ ...state }) }