From c937beccac4555d017535efc22d89f9ba6c064f3 Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Fri, 16 Jun 2023 11:10:40 -0700 Subject: [PATCH] Fix list loading --- CHANGELOG.md | 1 + src/agent/sync.ts | 17 +++++++++++++++-- src/app/views/Feeds.svelte | 6 +++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 425b6ce4..1dd84eae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/agent/sync.ts b/src/agent/sync.ts index eef32705..85409f15 100644 --- a/src/agent/sync.ts +++ b/src/agent/sync.ts @@ -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( diff --git a/src/app/views/Feeds.svelte b/src/app/views/Feeds.svelte index f9d5749e..d9aae730 100644 --- a/src/app/views/Feeds.svelte +++ b/src/app/views/Feeds.svelte @@ -1,7 +1,7 @@