Fix list loading

This commit is contained in:
Jonathan Staab 2023-06-16 11:10:40 -07:00
parent 80386a833c
commit c937beccac
3 changed files with 19 additions and 5 deletions

View File

@ -4,6 +4,7 @@
- [x] Add note preview when composing
- [x] Merge advanced search, feed options, and lists
- [x] Fix loading lists on login
# 0.2.31

View File

@ -1,4 +1,4 @@
import {is, uniq, prop, reject, nth, uniqBy, objOf, pick, identity} from "ramda"
import {partition, is, uniq, reject, nth, objOf, pick, identity} from "ramda"
import {nip05} from "nostr-tools"
import {noop, ensurePlural, chunk} from "hurdak/lib/hurdak"
import {
@ -226,7 +226,20 @@ addHandler(
addHandler(
30001,
profileHandler("lists", (e, p) => uniqBy(prop("id"), p.lists.concat(e)))
userHandler(e => {
const profile = user.getProfile()
const listName = Tags.from(e).getMeta("d")
const [duplicates, lists] = partition(
l => Tags.from(l).getMeta("d") === listName,
profile.lists
)
if (e.created_at < duplicates[0]?.created_at) {
return
}
user.profile.set({...profile, lists: lists.concat(e)})
})
)
addHandler(

View File

@ -1,7 +1,7 @@
<script lang="ts">
import cx from "classnames"
import type {DynamicFilter} from "src/util/types"
import {prop, indexBy, objOf} from "ramda"
import {indexBy, objOf} from "ramda"
import {Tags} from "src/util/nostr"
import {modal, theme} from "src/partials/state"
import Anchor from "src/partials/Anchor.svelte"
@ -32,14 +32,14 @@
relays = urls.map(objOf("url"))
}
filter = {kinds: [1, 1985], authors: 'global'}
filter = {kinds: [1, 1985], authors: "global"} as DynamicFilter
if (authors.length > 0) {
filter = {...filter, authors}
}
if (topics.length > 0) {
filter = {...filter, '#t': topics}
filter = {...filter, "#t": topics}
}
key = Math.random()