mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-29 08:21:20 +00:00
Fix toSpliced and creating a list based on a feed selection
This commit is contained in:
parent
3be28bd615
commit
49ecaf4d99
@ -11,7 +11,21 @@
|
||||
export let feed
|
||||
export let onChange
|
||||
|
||||
const list = (() => {
|
||||
const openForm = () => {
|
||||
formIsOpen = true
|
||||
}
|
||||
|
||||
const closeForm = event => {
|
||||
formIsOpen = false
|
||||
|
||||
if (event) {
|
||||
onChange(makeListFeed({addresses: [getAddress(event)]}))
|
||||
}
|
||||
}
|
||||
|
||||
let formIsOpen = false
|
||||
|
||||
$: list = (() => {
|
||||
if (isAuthorFeed(feed)) {
|
||||
return makeList({kind: NAMED_PEOPLE, tags: feed.slice(1).map(mention)})
|
||||
} else if (isMentionFeed(feed)) {
|
||||
@ -27,20 +41,6 @@
|
||||
throw new Error(`Invalid feed type ${feed[0]} passed to FeedFormSaveAsList`)
|
||||
}
|
||||
})()
|
||||
|
||||
const openForm = () => {
|
||||
formIsOpen = true
|
||||
}
|
||||
|
||||
const closeForm = event => {
|
||||
formIsOpen = false
|
||||
|
||||
if (event) {
|
||||
onChange(makeListFeed({addresses: [getAddress(event)]}))
|
||||
}
|
||||
}
|
||||
|
||||
let formIsOpen = false
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col items-end">
|
||||
|
@ -97,7 +97,7 @@ export class FeedLoader {
|
||||
|
||||
await Promise.all(
|
||||
Array.from(getRequestItems({relays, filters})).map(opts =>
|
||||
load({...opts, onEvent, tracker, signal, skipCache: true}),
|
||||
load({...opts, onEvent, tracker, signal, skipCache: Boolean(relays)}),
|
||||
),
|
||||
)
|
||||
},
|
||||
|
@ -362,14 +362,5 @@ export class SearchHelper<T, V> {
|
||||
|
||||
export const fromCsv = s => (s || "").split(",").filter(identity)
|
||||
|
||||
export const toSpliced = <T>(xs: T[], start: number, deleteCount?: number, ...items: T[]) => {
|
||||
const copy = [...xs]
|
||||
|
||||
if (deleteCount) {
|
||||
copy.splice(start, deleteCount, ...items)
|
||||
} else {
|
||||
copy.splice(start)
|
||||
}
|
||||
|
||||
return copy
|
||||
}
|
||||
export const toSpliced = <T>(xs: T[], start: number, deleteCount: number = 0, ...items: T[]) =>
|
||||
[...xs.slice(0, start), ...items, ...xs.slice(start + deleteCount)]
|
||||
|
Loading…
Reference in New Issue
Block a user