diff --git a/src/utils/array.ts b/src/utils/array.ts new file mode 100644 index 00000000..e493ed04 --- /dev/null +++ b/src/utils/array.ts @@ -0,0 +1,14 @@ + +/** + * Utility function to remove an element from an array in-place. + * I'm not a fan of this kind of practices, but Obsidian is higly OOP + * and relies in mutation heavily, as as Svelte (the used UI library). + * This is the simplest way to make sure the data in the UI represents + * the data in the app. +**/ +export function remove_inplace(arr: Array, value: T): void { + const index = arr.indexOf(value); + if (index > -1) { + arr.splice(index, 1); + } +} diff --git a/src/views/components/MultiSelect.svelte b/src/views/components/MultiSelect.svelte index 0231257d..84173e0d 100644 --- a/src/views/components/MultiSelect.svelte +++ b/src/views/components/MultiSelect.svelte @@ -1,5 +1,6 @@