diff --git a/packages/pockethost.io/src/routes/app/instances/[instanceId]/Secrets/stores.ts b/packages/pockethost.io/src/routes/app/instances/[instanceId]/Secrets/stores.ts index 8490bfb0..22a820cb 100644 --- a/packages/pockethost.io/src/routes/app/instances/[instanceId]/Secrets/stores.ts +++ b/packages/pockethost.io/src/routes/app/instances/[instanceId]/Secrets/stores.ts @@ -1,3 +1,4 @@ +import { logger } from '@pockethost/common' import { scaleOrdinal } from 'd3-scale' import { schemeTableau10 } from 'd3-scale-chromatic' import { writable } from 'svelte/store' @@ -35,6 +36,8 @@ const sanitize = (item: SecretItem) => { // create a custom store fulfilling the CRUD operations function createItems(initialItems: SecretsArray) { + const { dbg } = logger().create(`Secrets/store.ts`) + const { subscribe, set, update } = writable(initialItems) return { @@ -44,6 +47,7 @@ function createItems(initialItems: SecretsArray) { }, // create: add an object for the item at the end of the store's array create: (item: SecretItem) => { + dbg(`Creating`, item) const { name, value } = sanitize(item) return update((n) => { n = [ @@ -56,18 +60,10 @@ function createItems(initialItems: SecretsArray) { return formatInput(n) }) }, - // update: increase the value of the selected item - update: (item: SecretItem) => { - const { name, value } = sanitize(item) - return update((n) => { - const index = n.findIndex((item) => item.name === name) - n[index].value += value - return formatInput(n) - }) - }, // delete: remove the item from the array delete: (name: string) => { + dbg(`Delete`, name) return update((n) => { const index = n.findIndex((item) => item.name === name) n = [...n.slice(0, index), ...n.slice(index + 1)]