From 17eaef99bc62a8259c47b81627a8da2629f9dbb8 Mon Sep 17 00:00:00 2001 From: moderato-app <158245807+moderato-app@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:35:49 +0800 Subject: [PATCH] fix: name of shortcuts are not correct --- package.json | 2 +- src/state/app-state.ts | 1 + src/state/migration.ts | 19 ++++++++++++++++++- vite.config.ts | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c2681cb..fdcc321 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "talk-vite", "private": true, - "version": "2.0.2", + "version": "2.0.3", "type": "module", "scripts": { "dev": "vite", diff --git a/src/state/app-state.ts b/src/state/app-state.ts index c06bb58..97b9269 100644 --- a/src/state/app-state.ts +++ b/src/state/app-state.ts @@ -115,6 +115,7 @@ const apply = (as: AppState | null) => { console.debug("restoring from db, key:", key) const error = migrateAppState(as) if (error) { + console.error(error) throw error } // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/src/state/migration.ts b/src/state/migration.ts index 1f91f72..09a69f4 100644 --- a/src/state/migration.ts +++ b/src/state/migration.ts @@ -1,7 +1,7 @@ import {AppState} from "./app-state.ts" import * as packageJson from '../../package.json' import {defaultOption} from "../data-structure/client-option.tsx" -import {defaultShortcuts} from "./shortcuts.ts"; +import {defaultShortcuts, KeyCombo, Shortcuts} from "./shortcuts.ts"; import semver from "semver/preload"; const currentVersion = packageJson.version @@ -79,6 +79,23 @@ const steps: Step[] = [ } return null } + }, + { + fromVersion: "2.0.0", + toVersion: "2.0.3", + action: (app: AppState): Error | null => { + const dft = defaultShortcuts() + Object.keys(app.pref.shortcuts).forEach((field) => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + const shortcut = dft[field] as KeyCombo|undefined + if (!shortcut){ + return Error(`${field} was not found in defaultShortcuts`) + } + app.pref.shortcuts[field as keyof Shortcuts].name = shortcut.name + }) + return null + } } ] diff --git a/vite.config.ts b/vite.config.ts index 069d09a..60c5beb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,7 +3,7 @@ import react from '@vitejs/plugin-react' import svgr from 'vite-plugin-svgr' import {visualizer} from 'rollup-plugin-visualizer'; -const VISUALIZER = true; // change to see the current bundle. +const VISUALIZER = false; // change to see the current bundle. const bigPackages = [ 'prompt.ts',