mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 13:54:20 +03:00
wip
This commit is contained in:
parent
0ab9af0679
commit
610a8730b7
@ -1,7 +1,7 @@
|
|||||||
:: hark-graph-hook: notifications for graph-store [landscape]
|
:: hark-graph-hook: notifications for graph-store [landscape]
|
||||||
::
|
::
|
||||||
/- store=hark-store, post, group-store, metadata-store, hook=hark-graph-hook
|
/- post, group-store, metadata-store, hook=hark-graph-hook
|
||||||
/+ resource, metadata, default-agent, dbug, graph-store, graph, grouplib=group
|
/+ resource, metadata, default-agent, dbug, graph-store, graph, grouplib=group, store=hark-store
|
||||||
::
|
::
|
||||||
::
|
::
|
||||||
~% %hark-graph-hook-top ..part ~
|
~% %hark-graph-hook-top ..part ~
|
||||||
@ -191,7 +191,8 @@
|
|||||||
==
|
==
|
||||||
=/ group=(unit resource)
|
=/ group=(unit resource)
|
||||||
(group-from-app-resource:met %graph rid)
|
(group-from-app-resource:met %graph rid)
|
||||||
?~ group `state
|
?~ group
|
||||||
|
`state
|
||||||
=/ metadata=(unit metadata:metadata-store)
|
=/ metadata=(unit metadata:metadata-store)
|
||||||
(peek-metadata:met %graph u.group rid)
|
(peek-metadata:met %graph u.group rid)
|
||||||
?~ metadata `state
|
?~ metadata `state
|
||||||
@ -327,7 +328,7 @@
|
|||||||
?: =(our.bowl author.post.node)
|
?: =(our.bowl author.post.node)
|
||||||
(self-post node notif-index [mode watch]:not-kind)
|
(self-post node notif-index [mode watch]:not-kind)
|
||||||
=. update-core
|
=. update-core
|
||||||
(update-unread-count mode.not-kind notif-index [time-sent index]:post.node)
|
(update-unread-count not-kind notif-index [time-sent index]:post.node)
|
||||||
=? update-core
|
=? update-core
|
||||||
?| =(desc %mention)
|
?| =(desc %mention)
|
||||||
(~(has in watching) [rid parent])
|
(~(has in watching) [rid parent])
|
||||||
@ -338,10 +339,13 @@
|
|||||||
update-core
|
update-core
|
||||||
::
|
::
|
||||||
++ update-unread-count
|
++ update-unread-count
|
||||||
|= [mode=?(%count %each %none) =index:store time=@da ref=index:graph-store]
|
|= [=notif-kind =index:store time=@da ref=index:graph-store]
|
||||||
?- mode
|
=. description.index name.notif-kind
|
||||||
%count (hark %unread-count index time)
|
=/ =stats-index:store
|
||||||
%each (hark %unread-each index ref time)
|
(to-stats-index:store index)
|
||||||
|
?- mode.notif-kind
|
||||||
|
%count (hark %unread-count stats-index time)
|
||||||
|
%each (hark %unread-each stats-index ref time)
|
||||||
%none update-core
|
%none update-core
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -352,10 +356,12 @@
|
|||||||
watch=?
|
watch=?
|
||||||
==
|
==
|
||||||
^+ update-core
|
^+ update-core
|
||||||
|
=/ =stats-index:store
|
||||||
|
(to-stats-index:store index)
|
||||||
=. update-core
|
=. update-core
|
||||||
(hark %seen-index time-sent.post.node index)
|
(hark %seen-index time-sent.post.node stats-index)
|
||||||
=? update-core ?=(%count mode)
|
=? update-core ?=(%count mode)
|
||||||
(hark %read-count index)
|
(hark %read-count stats-index)
|
||||||
=? update-core &(watch watch-on-self)
|
=? update-core &(watch watch-on-self)
|
||||||
(new-watch index.post.node)
|
(new-watch index.post.node)
|
||||||
update-core
|
update-core
|
||||||
|
@ -19,29 +19,30 @@
|
|||||||
+$ card card:agent:gall
|
+$ card card:agent:gall
|
||||||
+$ versioned-state
|
+$ versioned-state
|
||||||
$% state:state-zero:store
|
$% state:state-zero:store
|
||||||
state-1
|
state:state-one:store
|
||||||
|
state-2
|
||||||
==
|
==
|
||||||
+$ unread-stats
|
+$ unread-stats
|
||||||
[indices=(set index:graph-store) last=@da]
|
[indices=(set index:graph-store) last=@da]
|
||||||
::
|
::
|
||||||
+$ state-1
|
+$ state-2
|
||||||
$: %1
|
$: unreads-each=(jug stats-index:store index:graph-store)
|
||||||
unreads-each=(jug index:store index:graph-store)
|
unreads-count=(map stats-index:store @ud)
|
||||||
unreads-count=(map index:store @ud)
|
last-seen=(map stats-index:store @da)
|
||||||
last-seen=(map index:store @da)
|
|
||||||
=notifications:store
|
=notifications:store
|
||||||
archive=notifications:store
|
archive=notifications:store
|
||||||
current-timebox=@da
|
current-timebox=@da
|
||||||
dnd=_|
|
dnd=_|
|
||||||
==
|
==
|
||||||
|
::
|
||||||
+$ inflated-state
|
+$ inflated-state
|
||||||
$: state-1
|
$: state-2
|
||||||
cache
|
cache
|
||||||
==
|
==
|
||||||
:: $cache: useful to have precalculated, but can be derived from state
|
:: $cache: useful to have precalculated, but can be derived from state
|
||||||
:: albeit expensively
|
:: albeit expensively
|
||||||
+$ cache
|
+$ cache
|
||||||
$: by-index=(jug index:store @da)
|
$: by-index=(jug stats-index:store @da)
|
||||||
~
|
~
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -76,8 +77,10 @@
|
|||||||
=| cards=(list card)
|
=| cards=(list card)
|
||||||
|^
|
|^
|
||||||
?- -.old
|
?- -.old
|
||||||
|
%2 [cards this]
|
||||||
|
::
|
||||||
%1
|
%1
|
||||||
[cards this(+.state (inflate-cache:ha old), -.state old)]
|
$(old *state-two)
|
||||||
::
|
::
|
||||||
%0
|
%0
|
||||||
|
|
||||||
@ -92,6 +95,16 @@
|
|||||||
==
|
==
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
|
::
|
||||||
|
++ clear-mention-unreads
|
||||||
|
|* =mold
|
||||||
|
|= unreads=(map index mold)
|
||||||
|
%+ murn
|
||||||
|
~(gas by unreads)
|
||||||
|
|= [=index value=mold]
|
||||||
|
?. ?=(%graph -.index) `[index value]
|
||||||
|
?: =(description.index 'mention') ~
|
||||||
|
`[index value]
|
||||||
++ convert-notifications-1
|
++ convert-notifications-1
|
||||||
|= old=notifications:state-zero:store
|
|= old=notifications:state-zero:store
|
||||||
%+ gas:orm *notifications:store
|
%+ gas:orm *notifications:store
|
||||||
@ -388,7 +401,7 @@
|
|||||||
(~(put ^in indices) unread)
|
(~(put ^in indices) unread)
|
||||||
::
|
::
|
||||||
++ read-index-each
|
++ read-index-each
|
||||||
|= [=index:store ref=index:graph-store]
|
|= [=stats-index:store ref=index:graph-store]
|
||||||
%+ read-boxes index
|
%+ read-boxes index
|
||||||
%+ skim
|
%+ skim
|
||||||
~(tap ^in (~(get ju by-index) index))
|
~(tap ^in (~(get ju by-index) index))
|
||||||
@ -415,11 +428,11 @@
|
|||||||
poke-core(unreads-each (jub index f))
|
poke-core(unreads-each (jub index f))
|
||||||
::
|
::
|
||||||
++ unread-count
|
++ unread-count
|
||||||
|= [=index:store time=@da]
|
|= [=stats-index:store time=@da]
|
||||||
=/ new-count
|
=/ new-count
|
||||||
+((~(gut by unreads-count) index 0))
|
+((~(gut by unreads-count) stats-index 0))
|
||||||
=. unreads-count
|
=. unreads-count
|
||||||
(~(put by unreads-count) index new-count)
|
(~(put by unreads-count) stats-index new-count)
|
||||||
(seen-index:(give %unread-count index time) time index)
|
(seen-index:(give %unread-count index time) time index)
|
||||||
::
|
::
|
||||||
++ read-count
|
++ read-count
|
||||||
@ -428,16 +441,29 @@
|
|||||||
(give:(read-index index) %read-count index)
|
(give:(read-index index) %read-count index)
|
||||||
::
|
::
|
||||||
++ read-index
|
++ read-index
|
||||||
|= =index:store
|
|= =stats-index:store
|
||||||
(read-boxes index ~(tap ^in (~(get ju by-index) index)))
|
(read-boxes stats-index ~(tap ^in (~(get ju by-index) stats-index)))
|
||||||
::
|
::
|
||||||
++ read-boxes
|
++ read-boxes
|
||||||
|= [=index:store boxes=(list @da)]
|
|= [=stats-index:store boxes=(list @da)]
|
||||||
?~ boxes poke-core
|
?~ boxes poke-core
|
||||||
=/ core=_poke-core
|
=/ core=_poke-core
|
||||||
(read-note i.boxes index)
|
(read-note i.boxes index)
|
||||||
$(poke-core core, boxes t.boxes)
|
$(poke-core core, boxes t.boxes)
|
||||||
::
|
::
|
||||||
|
++ read-stats-index
|
||||||
|
|= [time=@da =stats-index]
|
||||||
|
=/ keys
|
||||||
|
~(tap in ~(key by (get:orm notifications time)))
|
||||||
|
|- ^+ poke-core
|
||||||
|
?~ read-note
|
||||||
|
poke-core
|
||||||
|
?. (stats-index-is-index:store stats-index i.keys)
|
||||||
|
$(keys t.keys)
|
||||||
|
=/ core
|
||||||
|
(read-note time i.keys)
|
||||||
|
$(poke-core core, keys t.keys)
|
||||||
|
::
|
||||||
++ seen-index
|
++ seen-index
|
||||||
|= [time=@da =index:store]
|
|= [time=@da =index:store]
|
||||||
=/ new-time=@da
|
=/ new-time=@da
|
||||||
@ -522,6 +548,7 @@
|
|||||||
^- (list [@da timebox:store])
|
^- (list [@da timebox:store])
|
||||||
%+ skim (tap:orm notifications)
|
%+ skim (tap:orm notifications)
|
||||||
|=([@da =timebox:store] !=(~(wyt by timebox) 0))
|
|=([@da =timebox:store] !=(~(wyt by timebox) 0))
|
||||||
|
|
||||||
::
|
::
|
||||||
++ upd-cache
|
++ upd-cache
|
||||||
|= [read=? time=@da =index:store]
|
|= [read=? time=@da =index:store]
|
||||||
@ -529,7 +556,7 @@
|
|||||||
%_ +.state
|
%_ +.state
|
||||||
::
|
::
|
||||||
by-index
|
by-index
|
||||||
%. [index time]
|
%. [(to-stats-index:store index) time]
|
||||||
?: read
|
?: read
|
||||||
~(del ju by-index)
|
~(del ju by-index)
|
||||||
~(put ju by-index)
|
~(put ju by-index)
|
||||||
|
@ -27,6 +27,17 @@
|
|||||||
description+so
|
description+so
|
||||||
index+(su ;~(pfix fas (more fas dem)))
|
index+(su ;~(pfix fas (more fas dem)))
|
||||||
==
|
==
|
||||||
|
::
|
||||||
|
++ stats-index
|
||||||
|
%- of
|
||||||
|
:~ graph+graph-stats-index
|
||||||
|
group+dejs:resource
|
||||||
|
==
|
||||||
|
++ graph-stats-index
|
||||||
|
%- ot
|
||||||
|
:~ graph+dejs:resource
|
||||||
|
index+graph-index
|
||||||
|
==
|
||||||
:: parse date as @ud
|
:: parse date as @ud
|
||||||
:: TODO: move to zuse
|
:: TODO: move to zuse
|
||||||
++ sd
|
++ sd
|
||||||
@ -41,6 +52,8 @@
|
|||||||
:~ time+sd
|
:~ time+sd
|
||||||
index+index
|
index+index
|
||||||
==
|
==
|
||||||
|
++ graph-index
|
||||||
|
(su ;~(pfix fas (more fas dem)))
|
||||||
::
|
::
|
||||||
++ add
|
++ add
|
||||||
|= jon=json
|
|= jon=json
|
||||||
@ -48,8 +61,8 @@
|
|||||||
::
|
::
|
||||||
++ read-graph-index
|
++ read-graph-index
|
||||||
%- ot
|
%- ot
|
||||||
:~ index+index
|
:~ index+stats-index
|
||||||
target+(su ;~(pfix fas (more fas dem)))
|
target+graph-index
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ action
|
++ action
|
||||||
@ -61,7 +74,7 @@
|
|||||||
read-note+notif-ref
|
read-note+notif-ref
|
||||||
add-note+add
|
add-note+add
|
||||||
set-dnd+bo
|
set-dnd+bo
|
||||||
read-count+index
|
read-count+stats-index
|
||||||
read-each+read-graph-index
|
read-each+read-graph-index
|
||||||
==
|
==
|
||||||
--
|
--
|
||||||
@ -81,7 +94,7 @@
|
|||||||
%count (numb count.upd)
|
%count (numb count.upd)
|
||||||
%more (more +.upd)
|
%more (more +.upd)
|
||||||
%read-each (read-each +.upd)
|
%read-each (read-each +.upd)
|
||||||
%read-count (index +.upd)
|
%read-count (stats-index +.upd)
|
||||||
%unread-each (unread-each +.upd)
|
%unread-each (unread-each +.upd)
|
||||||
%unread-count (unread-count +.upd)
|
%unread-count (unread-count +.upd)
|
||||||
%seen-index (seen-index +.upd)
|
%seen-index (seen-index +.upd)
|
||||||
@ -91,16 +104,33 @@
|
|||||||
(notif-ref +.upd)
|
(notif-ref +.upd)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
|
++ stats-index
|
||||||
|
|= s=^stats-index
|
||||||
|
%+ frond -.s
|
||||||
|
|^
|
||||||
|
?- -.s
|
||||||
|
%graph (graph-stats-index +.s)
|
||||||
|
%group (enjs:resource +.s)
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ graph-stats-index
|
||||||
|
|= [graph=resource =index:graph-store]
|
||||||
|
%- pairs
|
||||||
|
:~ graph+(enjs:resource graph)
|
||||||
|
index+(index:enjs:graph-store index)
|
||||||
|
==
|
||||||
|
--
|
||||||
|
::
|
||||||
++ unreads
|
++ unreads
|
||||||
|= l=(list [^index ^index-stats])
|
|= l=(list [^stats-index ^stats])
|
||||||
^- json
|
^- json
|
||||||
:- %a
|
:- %a
|
||||||
^- (list json)
|
^- (list json)
|
||||||
%+ turn l
|
%+ turn l
|
||||||
|= [idx=^index stats=^index-stats]
|
|= [idx=^stats-index s=^stats]
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ stats+(index-stats stats)
|
:~ stats+(stats s)
|
||||||
index+(index idx)
|
index+(stats-index idx)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ unread
|
++ unread
|
||||||
@ -114,13 +144,13 @@
|
|||||||
(numb num.unreads)
|
(numb num.unreads)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ index-stats
|
++ stats
|
||||||
|= stats=^index-stats
|
|= s=^stats
|
||||||
^- json
|
^- json
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ unreads+(unread unreads.stats)
|
:~ unreads+(unread unreads.s)
|
||||||
notifications+(numb notifications.stats)
|
notifications+(numb notifications.s)
|
||||||
last+(time last-seen.stats)
|
last+(time last-seen.s)
|
||||||
==
|
==
|
||||||
++ added
|
++ added
|
||||||
|= [tim=@da idx=^index not=^notification]
|
|= [tim=@da idx=^index not=^notification]
|
||||||
@ -139,11 +169,11 @@
|
|||||||
index+(index idx)
|
index+(index idx)
|
||||||
==
|
==
|
||||||
++ seen-index
|
++ seen-index
|
||||||
|= [tim=@da idx=^index]
|
|= [tim=@da idx=^stats-index]
|
||||||
^- json
|
^- json
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ time+(time tim)
|
:~ time+(time tim)
|
||||||
index+(index idx)
|
index+(stats-index idx)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ more
|
++ more
|
||||||
@ -244,26 +274,45 @@
|
|||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ read-each
|
++ read-each
|
||||||
|= [=^index target=index:graph-store]
|
|= [s=^stats-index target=index:graph-store]
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ index+(^index index)
|
:~ index+(stats-index s)
|
||||||
target+(index:enjs:graph-store target)
|
target+(index:enjs:graph-store target)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ unread-each
|
++ unread-each
|
||||||
|= [=^index target=index:graph-store tim=@da]
|
|= [s=^stats-index target=index:graph-store tim=@da]
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ index+(^index index)
|
:~ index+(stats-index s)
|
||||||
target+(index:enjs:graph-store target)
|
target+(index:enjs:graph-store target)
|
||||||
last+(time tim)
|
last+(time tim)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ unread-count
|
++ unread-count
|
||||||
|= [=^index tim=@da]
|
|= [s=^stats-index tim=@da]
|
||||||
%- pairs
|
%- pairs
|
||||||
:~ index+(^index index)
|
:~ index+(stats-index s)
|
||||||
last+(time tim)
|
last+(time tim)
|
||||||
==
|
==
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
::
|
||||||
|
++ to-stats-index
|
||||||
|
|= =index
|
||||||
|
^- stats-index
|
||||||
|
?- -.index
|
||||||
|
%graph [%graph graph.index index.index]
|
||||||
|
%group [%group group.index]
|
||||||
|
==
|
||||||
|
++ stats-index-is-index
|
||||||
|
|= [=stats-index =index]
|
||||||
|
?- -.index
|
||||||
|
%graph
|
||||||
|
?. ?=(%graph -.stats-index) %.n
|
||||||
|
=([graph index]:index [graph index]:stats-index)
|
||||||
|
::
|
||||||
|
%group
|
||||||
|
?. ?=(%group -.stats-index) %.n
|
||||||
|
=(group:index group:stats-index)
|
||||||
|
==
|
||||||
--
|
--
|
||||||
|
@ -35,6 +35,19 @@
|
|||||||
[date=@da read=? =contents]
|
[date=@da read=? =contents]
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
|
++ state-one
|
||||||
|
|%
|
||||||
|
+$ state-1
|
||||||
|
$: unreads-each=(jug index index:graph-store)
|
||||||
|
unreads-count=(map index @ud)
|
||||||
|
last-seen=(map index @da)
|
||||||
|
=notifications
|
||||||
|
archive=notifications
|
||||||
|
current-timebox=@da
|
||||||
|
dnd=_|
|
||||||
|
==
|
||||||
|
--
|
||||||
|
::
|
||||||
+$ index
|
+$ index
|
||||||
$% $: %graph
|
$% $: %graph
|
||||||
group=resource
|
group=resource
|
||||||
@ -70,26 +83,32 @@
|
|||||||
$% [%add-note =index =notification]
|
$% [%add-note =index =notification]
|
||||||
[%archive time=@da index]
|
[%archive time=@da index]
|
||||||
::
|
::
|
||||||
[%unread-count =index =time]
|
[%unread-count =stats-index =time]
|
||||||
[%read-count =index]
|
[%read-count =stats-index]
|
||||||
::
|
::
|
||||||
[%unread-each =index ref=index:graph-store time=@da]
|
::
|
||||||
[%read-each index ref=index:graph-store]
|
[%unread-each =stats-index ref=index:graph-store time=@da]
|
||||||
|
[%read-each =stats-index ref=index:graph-store]
|
||||||
::
|
::
|
||||||
[%read-note time=@da index]
|
[%read-note time=@da index]
|
||||||
[%unread-note time=@da index]
|
[%unread-note time=@da index]
|
||||||
::
|
::
|
||||||
[%seen-index time=@da =index]
|
[%seen-index time=@da =stats-index]
|
||||||
::
|
::
|
||||||
[%read-all ~]
|
[%read-all ~]
|
||||||
[%set-dnd dnd=?]
|
[%set-dnd dnd=?]
|
||||||
[%seen ~]
|
[%seen ~]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
|
++ stats-index
|
||||||
|
$% [%graph graph=resource =index:graph-store]
|
||||||
|
[%group group=resource]
|
||||||
|
==
|
||||||
|
::
|
||||||
+$ indexed-notification
|
+$ indexed-notification
|
||||||
[index notification]
|
[index notification]
|
||||||
::
|
::
|
||||||
+$ index-stats
|
+$ stats
|
||||||
[notifications=@ud =unreads last-seen=@da]
|
[notifications=@ud =unreads last-seen=@da]
|
||||||
::
|
::
|
||||||
+$ unreads
|
+$ unreads
|
||||||
@ -103,6 +122,6 @@
|
|||||||
[%added time=@da =index =notification]
|
[%added time=@da =index =notification]
|
||||||
[%timebox time=@da archived=? =(list [index notification])]
|
[%timebox time=@da archived=? =(list [index notification])]
|
||||||
[%count count=@ud]
|
[%count count=@ud]
|
||||||
[%unreads unreads=(list [index index-stats])]
|
[%unreads unreads=(list [stats-index stats])]
|
||||||
==
|
==
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user