From 073b86be155425af28adf64a2a40f6ef62a81e44 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 25 Mar 2020 22:12:49 +0100 Subject: [PATCH] link-store: don't send update if not new We were taking care not to re-add something to our data store if we already had it in there, but were still sending out an update regardless. With this, we only send out an update if we weren't previously aware of the content. --- pkg/arvo/app/link-store.hoon | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/app/link-store.hoon b/pkg/arvo/app/link-store.hoon index 69e1b10df..9828e5731 100644 --- a/pkg/arvo/app/link-store.hoon +++ b/pkg/arvo/app/link-store.hoon @@ -320,7 +320,10 @@ :: add link to group submissions :: =/ =links (~(gut by by-group) path *links) - =. submissions.links + =^ added submissions.links + ?: ?=(^ (find ~[submission] submissions.links)) + [| submissions.links] + :- & (submissions:merge submissions.links ~[submission]) =. by-group (~(put by by-group) path links) :: add submission to global sites @@ -330,6 +333,7 @@ :: send updates to subscribers :: :_ state + ?. added ~ :_ ~ :+ %give %fact :+ :~ /submissions @@ -346,13 +350,17 @@ :: =/ urls (~(gut by discussions) path *(map ^url discussion)) =/ =discussion (~(gut by urls) url *discussion) - =. comments.discussion + =^ added comments.discussion + ?: ?=(^ (find ~[comment] comments.discussion)) + [| comments.discussion] + :- & (comments:merge comments.discussion ~[comment]) =. urls (~(put by urls) url discussion) =. discussions (~(put by discussions) path urls) :: send updates to subscribers :: :_ state + ?. added ~ :_ ~ :+ %give %fact :+ :~ /discussions