mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 04:52:06 +03:00
hark: cleanup notifications on leave
This commit is contained in:
parent
69c555c4b5
commit
6b6e9a7be2
@ -158,6 +158,36 @@
|
||||
(graph-update !<(update:graph-store q.cage.sign))
|
||||
[cards this]
|
||||
==
|
||||
::
|
||||
++ graph-update
|
||||
|= =update:graph-store
|
||||
^- (quip card _state)
|
||||
?+ -.q.update `state
|
||||
%add-graph (add-graph resource.q.update)
|
||||
::
|
||||
?(%remove-graph %archive-graph)
|
||||
(remove-graph resource.q.update)
|
||||
::
|
||||
%add-nodes
|
||||
=* rid resource.q.update
|
||||
(check-nodes ~(val by nodes.q.update) rid)
|
||||
==
|
||||
::
|
||||
++ remove-graph
|
||||
|= rid=resource
|
||||
=/ unwatched
|
||||
%- ~(gas in *_watching)
|
||||
%+ skim ~(tap in watching)
|
||||
|= [r=resource idx=index:graph-store]
|
||||
=(r rid)
|
||||
:_ state(watching (~(dif in watching) unwatched))
|
||||
^- (list card)
|
||||
:- (poke-hark:ha %remove-graph rid)
|
||||
%- zing
|
||||
%+ turn ~(tap in unwatched)
|
||||
|= [r=resource =index:graph-store]
|
||||
(give:ha ~[/updates] %ignore r index)
|
||||
::
|
||||
++ add-graph
|
||||
|= rid=resource
|
||||
^- (quip card _state)
|
||||
@ -181,15 +211,6 @@
|
||||
:_ state(watching (~(put in watching) [rid ~]))
|
||||
(weld cards (give:ha ~[/updates] %listen [rid ~]))
|
||||
::
|
||||
++ graph-update
|
||||
|= =update:graph-store
|
||||
^- (quip card _state)
|
||||
?: ?=(%add-graph -.q.update)
|
||||
(add-graph resource.q.update)
|
||||
?. ?=(%add-nodes -.q.update)
|
||||
[~ state]
|
||||
=* rid resource.q.update
|
||||
(check-nodes ~(val by nodes.q.update) rid)
|
||||
::
|
||||
++ check-nodes
|
||||
|= $: nodes=(list node:graph-store)
|
||||
@ -198,8 +219,10 @@
|
||||
=/ group=(unit resource)
|
||||
(group-from-app-resource:met %graph rid)
|
||||
?~ group
|
||||
~& no-group+rid
|
||||
`state
|
||||
=/ metadata=(unit metadata:metadata-store)
|
||||
~& no-metadata+rid
|
||||
(peek-metadata:met %graph u.group rid)
|
||||
?~ metadata `state
|
||||
abet:check:(abed:handle-update:ha rid nodes u.group module.u.metadata)
|
||||
|
@ -326,6 +326,7 @@
|
||||
%unread-note (unread-note +.in)
|
||||
::
|
||||
%seen-index (seen-index +.in)
|
||||
%remove-graph (remove-graph +.in)
|
||||
%set-dnd (set-dnd +.in)
|
||||
%seen seen
|
||||
==
|
||||
@ -488,6 +489,62 @@
|
||||
(~(put by last-seen) stats-index new-time)
|
||||
(give %seen-index new-time stats-index)
|
||||
::
|
||||
++ remove-graph
|
||||
|= rid=resource
|
||||
|^
|
||||
=/ indices get-stats-indices
|
||||
=. poke-core
|
||||
(give %remove-graph rid)
|
||||
=. poke-core
|
||||
(remove-notifications indices)
|
||||
=. unreads-count
|
||||
((dif-map-by-key ,@ud) unreads-count indices)
|
||||
=. unreads-each
|
||||
%+ (dif-map-by-key ,(set index:graph-store))
|
||||
unreads-each indices
|
||||
=. last-seen
|
||||
((dif-map-by-key ,@da) last-seen indices)
|
||||
=. by-index
|
||||
((dif-map-by-key ,(set @da)) by-index indices)
|
||||
poke-core
|
||||
::
|
||||
++ get-stats-indices
|
||||
%- ~(gas ^in *(set stats-index:store))
|
||||
%+ skim
|
||||
;: weld
|
||||
~(tap ^in ~(key by unreads-count))
|
||||
~(tap ^in ~(key by last-seen))
|
||||
~(tap ^in ~(key by unreads-each))
|
||||
~(tap ^in ~(key by by-index))
|
||||
==
|
||||
|= =stats-index:store
|
||||
?. ?=(%graph -.stats-index) %.n
|
||||
=(graph.stats-index rid)
|
||||
::
|
||||
++ dif-map-by-key
|
||||
|* value=mold
|
||||
|= [=(map stats-index:store value) =(set stats-index:store)]
|
||||
=/ to-remove ~(tap ^in set)
|
||||
|-
|
||||
?~ to-remove map
|
||||
=. map
|
||||
(~(del by map) i.to-remove)
|
||||
$(to-remove t.to-remove)
|
||||
::
|
||||
++ remove-notifications
|
||||
|= =(set stats-index:store)
|
||||
^+ poke-core
|
||||
=/ indices
|
||||
~(tap ^in set)
|
||||
|-
|
||||
?~ indices poke-core
|
||||
=/ times=(list @da)
|
||||
~(tap ^in (~(get ju by-index) i.indices))
|
||||
=. poke-core
|
||||
(read-index i.indices times)
|
||||
$(indices t.indices)
|
||||
--
|
||||
::
|
||||
++ seen
|
||||
=> (emit cancel-autoseen)
|
||||
=> (emit autoseen-timer)
|
||||
|
@ -22,7 +22,7 @@
|
||||
^- graph:store
|
||||
=/ =update:store
|
||||
(get-graph res)
|
||||
?> ?=(%0 -.res)
|
||||
?> ?=(%0 -.update)
|
||||
?> ?=(%add-graph -.q.update)
|
||||
graph.q.update
|
||||
::
|
||||
|
@ -97,6 +97,7 @@
|
||||
%read-count (stats-index +.upd)
|
||||
%unread-each (unread-each +.upd)
|
||||
%unread-count (unread-count +.upd)
|
||||
%remove-graph s+(enjs-path:resource +.upd)
|
||||
%seen-index (seen-index +.upd)
|
||||
%unreads (unreads +.upd)
|
||||
::
|
||||
|
@ -95,6 +95,7 @@
|
||||
[%unread-note time=@da index]
|
||||
::
|
||||
[%seen-index time=@da =stats-index]
|
||||
[%remove-graph =resource]
|
||||
::
|
||||
[%read-all ~]
|
||||
[%set-dnd dnd=?]
|
||||
@ -123,6 +124,7 @@
|
||||
[%added time=@da =index =notification]
|
||||
[%timebox time=@da archived=? =(list [index notification])]
|
||||
[%count count=@ud]
|
||||
[%clear =stats-index]
|
||||
[%unreads unreads=(list [stats-index stats])]
|
||||
==
|
||||
--
|
||||
|
@ -142,6 +142,14 @@ function reduce(data: any, state: HarkState) {
|
||||
unreadSince(data, state);
|
||||
unreadEach(data, state);
|
||||
seenIndex(data, state);
|
||||
removeGraph(data, state);
|
||||
}
|
||||
|
||||
function removeGraph(json: any, state: HarkState) {
|
||||
const data = _.get(json, 'remove-graph');
|
||||
if(data) {
|
||||
delete state.unreads.graph[data];
|
||||
}
|
||||
}
|
||||
|
||||
function seenIndex(json: any, state: HarkState) {
|
||||
|
Loading…
Reference in New Issue
Block a user