From 5c06c2206c5737b2b5607ccaefb1c2ede773c32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Sat, 2 Dec 2023 19:31:46 +0100 Subject: [PATCH] fix: undo/redo prevents use of unknown actions --- flake.nix | 71 ++++++++++++++++++++++++-------------------- src/lib/undo-redo.ts | 4 +-- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/flake.nix b/flake.nix index 2df11f47..5aaef448 100644 --- a/flake.nix +++ b/flake.nix @@ -4,31 +4,37 @@ rust-overlay.url = "github:oxalica/rust-overlay"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, flake-utils, rust-overlay }: - flake-utils.lib.eachDefaultSystem (system: - let - overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { inherit system overlays; }; - rust-bin = pkgs.rust-bin.stable.latest.default.override { - extensions = [ "rust-src" "rust-std" "clippy" "rust-analyzer" ]; - }; - fontMin = (pkgs.python311.withPackages(ps: with ps; [ brotli fonttools ] ++ (with fonttools.optional-dependencies; [ woff ]))); - tauriPkgs = nixpkgs.legacyPackages.${system}; - libraries = with tauriPkgs; [ - webkitgtk - gtk3 - cairo - gdk-pixbuf - glib - dbus - openssl_3 - librsvg - ]; - packages = (with pkgs; [ + outputs = { + self, + nixpkgs, + flake-utils, + rust-overlay, + }: + flake-utils.lib.eachDefaultSystem (system: let + overlays = [(import rust-overlay)]; + pkgs = import nixpkgs {inherit system overlays;}; + rust-bin = pkgs.rust-bin.stable.latest.default.override { + extensions = ["rust-src" "rust-std" "clippy" "rust-analyzer"]; + }; + fontMin = pkgs.python311.withPackages (ps: with ps; [brotli fonttools] ++ (with fonttools.optional-dependencies; [woff])); + tauriPkgs = nixpkgs.legacyPackages.${system}; + libraries = with tauriPkgs; [ + webkitgtk + gtk3 + cairo + gdk-pixbuf + glib + dbus + openssl_3 + librsvg + ]; + packages = + (with pkgs; [ nodejs_18 rust-bin fontMin - ]) ++ (with tauriPkgs; [ + ]) + ++ (with tauriPkgs; [ curl wget pkg-config @@ -39,16 +45,15 @@ libsoup webkitgtk librsvg - # serial plugin - udev + # serial plugin + udev ]); - in - { - devShell = pkgs.mkShell { - buildInputs = packages; - shellHook = '' - export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH - ''; - }; - }); + in { + devShell = pkgs.mkShell { + buildInputs = packages; + shellHook = '' + export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH + ''; + }; + }); } diff --git a/src/lib/undo-redo.ts b/src/lib/undo-redo.ts index 9e4206d5..b727e06b 100644 --- a/src/lib/undo-redo.ts +++ b/src/lib/undo-redo.ts @@ -100,7 +100,7 @@ export const chords = derived([overlay, deviceChords], ([overlay, chords]) => { return { id: chord.actions, // use the old phrase for stable editing - sortBy: chord.phrase.map(it => KEYMAP_CODES[it].id || it).join(), + sortBy: chord.phrase.map(it => KEYMAP_CODES[it]?.id ?? it).join(), actions: changedChord.actions, phrase: changedChord.phrase, actionsChanged: id !== JSON.stringify(changedChord.actions), @@ -110,7 +110,7 @@ export const chords = derived([overlay, deviceChords], ([overlay, chords]) => { } else { return { id: chord.actions, - sortBy: chord.phrase.map(it => KEYMAP_CODES[it].id || it).join(), + sortBy: chord.phrase.map(it => KEYMAP_CODES[it]?.id ?? it).join(), actions: chord.actions, phrase: chord.phrase, phraseChanged: false,