Fix repository delete on duplicate

This commit is contained in:
Jon Staab 2024-06-04 17:40:03 -07:00
parent d3f47950a7
commit 22e6af3dde
2 changed files with 5 additions and 6 deletions

View File

@ -55,11 +55,11 @@
"@fortawesome/fontawesome-free": "^6.5.2",
"@getalby/bitcoin-connect": "^3.2.2",
"@scure/base": "^1.1.6",
"@welshman/content": "^0.0.2",
"@welshman/content": "^0.0.3",
"@welshman/feeds": "^0.0.9",
"@welshman/lib": "^0.0.8",
"@welshman/net": "^0.0.11",
"@welshman/util": "^0.0.11",
"@welshman/util": "^0.0.12",
"classnames": "^2.5.1",
"compressorjs": "^1.2.1",
"date-picker-svelte": "^2.12.0",

View File

@ -1,5 +1,5 @@
import {derived} from "svelte/store"
import {nth, identity, partition, first} from "@welshman/lib"
import {nth, uniqBy, identity, partition, first} from "@welshman/lib"
import {Repository, Relay, matchFilters, getIdAndAddress, getIdFilters} from "@welshman/util"
import type {Filter, TrustedEvent} from "@welshman/util"
import {custom} from "src/util/misc"
@ -64,10 +64,9 @@ export const deriveEventsMapped = <T>({
}
}
const onDelete = (event: TrustedEvent) => {
const ids = new Set(event.tags.map(nth(1)))
const onDelete = (values: Set<string>) => {
const [deleted, ok] = partition(
(item: T) => getIdAndAddress(itemToEvent(item)).some(id => ids.has(id)),
(item: T) => getIdAndAddress(itemToEvent(item)).some(id => values.has(id)),
data,
)