hark-graph-hook: watch individual indices

This commit is contained in:
Liam Fitzgerald 2020-11-10 11:41:19 +10:00
parent 5eb1aa4327
commit 9eec477e0e
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
6 changed files with 49 additions and 33 deletions

View File

@ -12,7 +12,7 @@
::
+$ state-0
$: %0
watching=(set resource)
watching=(set [resource index:post])
mentions=_&
watch-on-self=_&
==
@ -83,16 +83,16 @@
%set-watch-on-self (set-watch-on-self +.action)
==
++ listen
|= graph=resource
|= [graph=resource =index:post]
^- (quip card _state)
:- (give:ha ~[/updates] [%listen graph])
state(watching (~(put in watching) graph))
:- (give:ha ~[/updates] [%listen graph index])
state(watching (~(put in watching) [graph index]))
::
++ ignore
|= graph=resource
|= [graph=resource =index:post]
^- (quip card _state)
:- (give:ha ~[/updates] [%ignore graph])
state(watching (~(del in watching) graph))
:- (give:ha ~[/updates] [%ignore graph index])
state(watching (~(del in watching) [graph index]))
::
++ set-mentions
|= ment=?
@ -127,10 +127,18 @@
(graph-update !<(update:graph-store q.cage.sign))
[cards this]
==
++ add-graph
|= rid=resource
^- (quip card _state)
?. &(watch-on-self =(our.bowl entity.rid))
[~ state]
`state(watching (~(put in watching) [rid ~]))
::
++ graph-update
|= =update:graph-store
^- (quip card _state)
?: ?=(%add-graph -.q.update)
(add-graph resource.q.update)
?. ?=(%add-nodes -.q.update)
[~ state]
=/ group=resource
@ -187,15 +195,19 @@
(self-post node)
:_ state
(weld child-cards self-cards)
=+ !<(notif-kind=(unit @t) (tube !>([0 post.node])))
=+ !< notif-kind=(unit [name=@t parent-lent=@ud])
(tube !>([0 post.node]))
?~ notif-kind
[child-cards state]
=/ desc=@t
?: (is-mention contents.post.node)
%mention
u.notif-kind
name.u.notif-kind
=/ parent=index:post
(scag parent-lent.u.notif-kind index.post.node)
~& parent
?. ?| =(desc %mention)
(~(has in watching) rid)
(~(has in watching) [rid parent])
==
[child-cards state]
=/ notif-index=index:store
@ -222,7 +234,7 @@
^- (quip card _state)
?. ?=(%.y watch-on-self)
[~ state]
`state(watching (~(put in watching) rid))
`state(watching (~(put in watching) [rid index.post.node]))
::
++ add-unread
|= [=index:store =notification:store]

View File

@ -52,6 +52,7 @@
++ index
|= i=^index
^- json
?: =(~ i) s+'/'
=/ j=^tape ""
|-
?~ i [%s (crip j)]

View File

@ -1,4 +1,4 @@
/- sur=hark-graph-hook
/- sur=hark-graph-hook, post
/+ graph-store, resource
^?
=< [. sur]
@ -9,20 +9,20 @@
=, dejs:format
|%
::
++ graph-indices
%- ot
:~ graph+dejs-path:resource
indices+(as graph-index)
==
::
++ graph-index
++ index
^- $-(json index:graph-store)
(su ;~(pfix net (more net dem)))
::
++ graph-index
%- ot
:~ graph+dejs-path:resource
index+index
==
::
++ action
%- of
:~ listen+dejs-path:resource
ignore+dejs-path:resource
:~ listen+graph-index
ignore+graph-index
set-mentions+bo
set-watch-on-self+bo
==
@ -31,11 +31,11 @@
=, enjs:format
|%
::
++ graph-indices
|= [graph=resource indices=(set index:graph-store)]
++ graph-index
|= [graph=resource =index:post]
%- pairs
:~ graph+s+(enjs-path:resource graph)
indices+a+(turn ~(tap in indices) index:enjs:graph-store)
index+(index:enjs:graph-store index)
==
::
++ action
@ -45,9 +45,11 @@
?- -.act
%set-watch-on-self b+watch-on-self.act
%set-mentions b+mentions.act
?(%listen %ignore) s+(enjs-path:resource graph.act)
?(%listen %ignore) (graph-index graph.act index.act)
==
::
::
::
++ update
|= upd=^update
^- json
@ -57,7 +59,8 @@
%- pairs
:~ 'watchOnSelf'^b+watch-on-self.upd
'mentions'^b+mentions.upd
watching+a+(turn ~(tap in watching.upd) |=(r=resource s+(enjs-path:resource r)))
:+ %watching %a
(turn ~(tap in watching.upd) graph-index)
==
--
--

View File

@ -5,8 +5,8 @@
++ noun i
++ notification-kind
?+ index.p.i ~
[@ ~] `%link
[@ @ ~] `%comment
[@ ~] `[%link 0]
[@ @ ~] `[%comment 1]
==
--
++ grab

View File

@ -8,8 +8,8 @@
::
++ notification-kind
?+ index.p.i ~
[@ %1 @ ~] `%note
[@ %2 @ ~] `%comment
[@ %1 @ ~] `[%note 0]
[@ %2 @ ~] `[%comment 1]
==
--
++ grab

View File

@ -1,10 +1,10 @@
/- *resource, graph-store
/- *resource, graph-store, post
^?
|%
::
+$ action
$%
[?(%listen %ignore) graph=resource]
[?(%listen %ignore) graph=resource =index:post]
[%set-mentions mentions=?]
[%set-watch-on-self watch-on-self=?]
==
@ -13,7 +13,7 @@
$%
action
$: %initial
watching=(set resource)
watching=(set [resource index:post])
mentions=_&
watch-on-self=_&
==