From b50cbd047b81717be6e43ef17b54123f242b8607 Mon Sep 17 00:00:00 2001 From: Phil Kuang Date: Thu, 23 Dec 2021 20:11:09 -0500 Subject: [PATCH] fix(shortcuts): make writable copies of saved shortcuts from storageApi Signed-off-by: Phil Kuang --- .changeset/hip-hounds-remember.md | 5 +++++ plugins/shortcuts/src/api/LocalStoredShortcuts.ts | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 .changeset/hip-hounds-remember.md diff --git a/.changeset/hip-hounds-remember.md b/.changeset/hip-hounds-remember.md new file mode 100644 index 0000000000..c600c88b3f --- /dev/null +++ b/.changeset/hip-hounds-remember.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-shortcuts': patch +--- + +Properly read saved shortcuts from StorageApi diff --git a/plugins/shortcuts/src/api/LocalStoredShortcuts.ts b/plugins/shortcuts/src/api/LocalStoredShortcuts.ts index 8a713b9b8f..ef54f68acd 100644 --- a/plugins/shortcuts/src/api/LocalStoredShortcuts.ts +++ b/plugins/shortcuts/src/api/LocalStoredShortcuts.ts @@ -82,11 +82,9 @@ export class LocalStoredShortcuts implements ShortcutApi { }; private get() { - return ( - (this.storageApi.get('items') as Shortcut[])?.sort((a, b) => - a.title >= b.title ? 1 : -1, - ) ?? [] - ); + return Array.from( + this.storageApi.snapshot('items').value ?? [], + ).sort((a, b) => (a.title >= b.title ? 1 : -1)); } private notify() {