diff options
Diffstat (limited to 'app/lib/mutations')
| -rw-r--r-- | app/lib/mutations/trill.hoon | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/app/lib/mutations/trill.hoon b/app/lib/mutations/trill.hoon index 40cce1e..cfedecf 100644 --- a/app/lib/mutations/trill.hoon +++ b/app/lib/mutations/trill.hoon @@ -3,6 +3,7 @@ /+ appjs=json-nostrill, lib=nostrill, + trill-feed, trill=trill-post, njs=json-nostr, postlib=trill-post, @@ -22,11 +23,26 @@ ++ add-to-feed |= p=post:post =. feed.state (put:orm:feed feed.state id.p p) state +++ headsup-poke + |= [poke=post-poke:ui:sur p=post:post] ^- (unit engagement:comms) + ?- -.poke + %add ~ + ::: TODO del-reply + %del ~ + %quote `[%quote id.poke p] + %reply `[%reply id.poke p] + %rp `[%rp id.poke id.p] + %reaction `[%reaction id.poke reaction.poke] + == ++ handle-post |= poke=post-poke:ui:sur ^- (quip card _state) =/ profile (~(get by profiles.state) [%urbit our.bowl]) =/ pubkey pub.i.keys.state + ?: ?=(%del -.poke) + =. feed.state =< + (del:orm:feed feed.state id.poke) + :: TODO + `state =/ p=post:post ?- -.poke %add @@ -45,23 +61,36 @@ =/ sp (build-sp:trill host.poke our.bowl '' ~ ~) =. contents.sp ~[quote] (build-post:trill now.bowl pubkey sp) + %reaction + =/ p (got:orm:feed feed.state id.poke) + =. reacts.engagement.p %+ ~(put by reacts.engagement.p) + our.bowl [reaction.poke *signature:post] + p == + =. state (add-to-feed p) =/ pw [p (some pubkey) ~ ~ profile] =/ jfact=fact:ui:sur [%post %add pw] =/ ui-card (update-ui:cards:lib jfact) - :: only update followers when we are updating our own feed - ?. .=(our.bowl host.p) [~[ui-card] state] - =. state (add-to-feed p) - =/ =fact:comms [%post %add p] - =/ fact-card (update-followers:cards:lib fact) + =/ crds ~(. cards:lib bowl) + =/ engagement-poke (headsup-poke poke p) + =/ base-cards + ?~ engagement-poke :~(ui-card) + =/ poke [%eng u.engagement-poke] + =/ eng-card (poke-host:crds host.p poke) + :~(ui-card eng-card) + :: if our own post we update followers, if someone elses post we send an engagement poke :_ state - :~ ui-card - fact-card - == - + ?: .=(our.bowl host.p) + :: + =/ =fact:comms [%post %add p] + =/ fact-card (update-followers:cards:lib fact) + :- fact-card base-cards + :: + base-cards ++ handle-post-fact |= pf=post-fact:comms ^- (quip card _state) + ~& handle-post-fact=pf =/ =user:sur [%urbit src.bowl] =/ fed (~(get by following.state) user) ?~ fed ~& "emmm not following ya" `state @@ -72,6 +101,10 @@ :: =/ =user:nsur [%urbit host.p.pdf] (put:orm:feed u.fed id.p.pf p.pf) =. following.state (~(put by following.state) user nf) + =. following2.state + ?: ?=(%del -.pf) + =< + (del:orm:feed following2.state id.pf) + (insert-to-global:trill-feed nf p.pf) :: TODO update the ui with the changes :_ state ~ -- |
