2020-11-24 05:20:44 +03:00
|
|
|
:: hark-store: notifications and unread counts [landscape]
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
:: hark-store can store unread counts differently, depending on the
|
|
|
|
:: resource.
|
|
|
|
:: - last seen. This way, hark-store simply stores an index into
|
|
|
|
:: graph-store, which represents the last "seen" item, useful for
|
|
|
|
:: high-volume applications which are intrinsically time-ordered. i.e.
|
|
|
|
:: chats, comments
|
|
|
|
:: - each. Hark-store will store an index for each item that is unread.
|
|
|
|
:: Usefull for non-linear, low-volume applications, i.e. blogs,
|
|
|
|
:: collections
|
|
|
|
::
|
2020-12-16 10:37:10 +03:00
|
|
|
/- post, group-store, metadata-store, store=hark-store
|
2020-12-01 08:46:28 +03:00
|
|
|
/+ resource, metadata, default-agent, dbug, graph-store, graphl=graph, verb, store=hark-store
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
::
|
2020-12-05 07:32:17 +03:00
|
|
|
~% %hark-store-top ..part ~
|
2020-10-21 08:54:59 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
+$ versioned-state
|
2020-11-24 05:20:44 +03:00
|
|
|
$% state:state-zero:store
|
2020-12-16 07:22:23 +03:00
|
|
|
state:state-one:store
|
|
|
|
state-2
|
2021-01-11 02:51:53 +03:00
|
|
|
state-3
|
2021-02-04 04:39:59 +03:00
|
|
|
state-4
|
2020-10-21 08:54:59 +03:00
|
|
|
==
|
2020-11-24 05:20:44 +03:00
|
|
|
+$ unread-stats
|
|
|
|
[indices=(set index:graph-store) last=@da]
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2021-01-11 02:51:53 +03:00
|
|
|
+$ base-state
|
|
|
|
$: unreads-each=(jug stats-index:store index:graph-store)
|
2020-12-16 07:22:23 +03:00
|
|
|
unreads-count=(map stats-index:store @ud)
|
|
|
|
last-seen=(map stats-index:store @da)
|
2020-10-21 08:54:59 +03:00
|
|
|
=notifications:store
|
|
|
|
archive=notifications:store
|
2020-11-24 05:20:44 +03:00
|
|
|
current-timebox=@da
|
2020-11-12 03:34:51 +03:00
|
|
|
dnd=_|
|
2020-10-21 08:54:59 +03:00
|
|
|
==
|
2020-12-16 07:22:23 +03:00
|
|
|
::
|
2021-01-11 02:51:53 +03:00
|
|
|
+$ state-2
|
2021-02-04 04:39:59 +03:00
|
|
|
[%2 state-two:store]
|
2021-01-11 02:51:53 +03:00
|
|
|
::
|
|
|
|
+$ state-3
|
2021-02-04 04:39:59 +03:00
|
|
|
[%3 state-two:store]
|
|
|
|
::
|
|
|
|
+$ state-4
|
|
|
|
[%4 base-state]
|
2021-01-11 02:51:53 +03:00
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
+$ inflated-state
|
2021-02-04 04:39:59 +03:00
|
|
|
$: state-4
|
2020-10-27 08:07:13 +03:00
|
|
|
cache
|
|
|
|
==
|
|
|
|
:: $cache: useful to have precalculated, but can be derived from state
|
|
|
|
:: albeit expensively
|
|
|
|
+$ cache
|
2021-01-13 05:37:23 +03:00
|
|
|
$: by-index=(jug stats-index:store [time=@da =index:store])
|
2020-10-27 08:07:13 +03:00
|
|
|
~
|
|
|
|
==
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2020-11-16 06:52:45 +03:00
|
|
|
++ orm ((ordered-map @da timebox:store) gth)
|
2020-10-21 08:54:59 +03:00
|
|
|
--
|
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
=| inflated-state
|
2020-10-21 08:54:59 +03:00
|
|
|
=* state -
|
|
|
|
::
|
|
|
|
=<
|
2020-12-01 08:46:28 +03:00
|
|
|
%+ verb |
|
2020-10-21 08:54:59 +03:00
|
|
|
%- agent:dbug
|
|
|
|
^- agent:gall
|
|
|
|
~% %hark-store-agent ..card ~
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
ha ~(. +> bowl)
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
met ~(. metadata bowl)
|
2020-12-01 08:46:28 +03:00
|
|
|
gra ~(. graphl bowl)
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
:_ this
|
|
|
|
~[autoseen-timer]
|
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
++ on-save !>(-.state)
|
2020-10-21 08:54:59 +03:00
|
|
|
++ on-load
|
2020-10-27 08:07:13 +03:00
|
|
|
|= =old=vase
|
2020-10-21 08:54:59 +03:00
|
|
|
^- (quip card _this)
|
2020-10-27 08:07:13 +03:00
|
|
|
=/ old
|
2020-11-24 05:20:44 +03:00
|
|
|
!<(versioned-state old-vase)
|
|
|
|
=| cards=(list card)
|
2020-12-10 08:19:46 +03:00
|
|
|
|^
|
2020-11-24 05:20:44 +03:00
|
|
|
?- -.old
|
2021-02-04 04:39:59 +03:00
|
|
|
%4
|
2021-01-12 01:15:14 +03:00
|
|
|
:- (flop cards)
|
2020-12-16 10:37:10 +03:00
|
|
|
this(-.state old, +.state (inflate-cache:ha old))
|
2021-02-04 04:39:59 +03:00
|
|
|
::
|
|
|
|
%3
|
|
|
|
%_ $
|
|
|
|
-.old %4
|
|
|
|
notifications.old (convert-notifications-3 notifications.old)
|
|
|
|
archive.old (convert-notifications-3 archive.old)
|
|
|
|
==
|
2021-01-11 02:51:53 +03:00
|
|
|
::
|
|
|
|
%2
|
|
|
|
%_ $
|
|
|
|
-.old %3
|
2021-01-12 01:15:14 +03:00
|
|
|
::
|
|
|
|
cards
|
|
|
|
:_ cards
|
|
|
|
[%pass / %agent [our dap]:bowl %poke noun+!>(%fix-dangling)]
|
2021-01-11 02:51:53 +03:00
|
|
|
==
|
2020-12-16 07:22:23 +03:00
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
%1
|
2020-12-16 10:37:10 +03:00
|
|
|
%_ $
|
|
|
|
::
|
|
|
|
old
|
|
|
|
%* . *state-2
|
|
|
|
unreads-each ((convert-unread ,(set index:graph-store)) uni-by unreads-each.old)
|
|
|
|
unreads-count ((convert-unread ,@ud) add unreads-count.old)
|
|
|
|
last-seen ((convert-unread ,@da) max last-seen.old)
|
|
|
|
notifications notifications.old
|
|
|
|
archive archive.old
|
|
|
|
current-timebox current-timebox.old
|
|
|
|
dnd dnd.old
|
|
|
|
==
|
|
|
|
==
|
2020-11-24 05:20:44 +03:00
|
|
|
::
|
|
|
|
%0
|
|
|
|
%_ $
|
|
|
|
::
|
|
|
|
old
|
2020-12-16 10:37:10 +03:00
|
|
|
%* . *state:state-one:store
|
2020-12-10 08:19:46 +03:00
|
|
|
notifications (convert-notifications-1 notifications.old)
|
|
|
|
archive (convert-notifications-1 archive.old)
|
|
|
|
current-timebox current-timebox.old
|
|
|
|
dnd dnd.old
|
|
|
|
==
|
2020-11-24 05:20:44 +03:00
|
|
|
==
|
|
|
|
==
|
2021-02-04 04:39:59 +03:00
|
|
|
::
|
|
|
|
++ convert-notifications-3
|
|
|
|
|= old=notifications:state-two:store
|
|
|
|
%+ gas:orm *notifications:store
|
|
|
|
^- (list [@da timebox:store])
|
|
|
|
%+ murn
|
|
|
|
(tap:orm:state-two:store old)
|
|
|
|
|= [time=@da =timebox:state-two:store]
|
|
|
|
^- (unit [@da timebox:store])
|
|
|
|
=/ new-timebox=timebox:store
|
|
|
|
(convert-timebox-3 timebox)
|
|
|
|
?: =(0 ~(wyt by new-timebox))
|
|
|
|
~
|
|
|
|
`[time new-timebox]
|
|
|
|
::
|
|
|
|
++ convert-timebox-3
|
|
|
|
|= =timebox:state-two:store
|
|
|
|
^- timebox:store
|
|
|
|
%- ~(gas by *timebox:store)
|
|
|
|
^- (list [index:store notification:store])
|
|
|
|
%+ murn
|
|
|
|
~(tap by timebox)
|
|
|
|
|= [=index:store =notification:state-two:store]
|
|
|
|
^- (unit [index:store notification:store])
|
|
|
|
=/ new-notification=(unit notification:store)
|
|
|
|
(convert-notification-3 notification)
|
|
|
|
?~ new-notification ~
|
|
|
|
`[index u.new-notification]
|
|
|
|
::
|
|
|
|
++ convert-notification-3
|
|
|
|
|= =notification:state-two:store
|
|
|
|
^- (unit notification:store)
|
|
|
|
?: ?=(%graph -.contents.notification)
|
|
|
|
`notification
|
|
|
|
=/ con=(list group-contents:store)
|
|
|
|
(convert-group-contents-3 list.contents.notification)
|
|
|
|
?: =(~ con) ~
|
|
|
|
=, notification
|
|
|
|
`[date read %group con]
|
|
|
|
::
|
|
|
|
++ convert-group-contents-3
|
|
|
|
|= con=(list group-contents:state-two:store)
|
|
|
|
^- (list group-contents:store)
|
|
|
|
%+ murn con
|
|
|
|
|= =group-contents:state-two:store
|
|
|
|
^- (unit group-contents:store)
|
|
|
|
?. ?=(?(%add-members %remove-members) -.group-contents) ~
|
|
|
|
`group-contents
|
|
|
|
::
|
2020-12-16 10:37:10 +03:00
|
|
|
++ uni-by
|
|
|
|
|= [a=(set index:graph-store) b=(set index:graph-store)]
|
|
|
|
=/ merged
|
|
|
|
(~(uni in a) b)
|
|
|
|
%- ~(gas in *(set index:graph-store))
|
|
|
|
%+ skip ~(tap in merged)
|
|
|
|
|=(=index:graph-store &(=((lent index) 3) !=(-:(flop index) 1)))
|
|
|
|
::
|
|
|
|
++ convert-unread
|
|
|
|
|* value=mold
|
|
|
|
|= [combine=$-([value value] value) unreads=(map index:store value)]
|
|
|
|
^- (map stats-index:store value)
|
|
|
|
%+ roll
|
|
|
|
~(tap in unreads)
|
|
|
|
|= [[=index:store val=value] out=(map stats-index:store value)]
|
|
|
|
=/ old=value
|
|
|
|
(~(gut by unreads) index (combine))
|
|
|
|
=/ =stats-index:store
|
|
|
|
(to-stats-index:store index)
|
|
|
|
(~(put by out) stats-index (combine old val))
|
2020-12-16 07:22:23 +03:00
|
|
|
::
|
2020-12-10 08:19:46 +03:00
|
|
|
++ convert-notifications-1
|
|
|
|
|= old=notifications:state-zero:store
|
2021-02-04 04:39:59 +03:00
|
|
|
%+ gas:orm:state-two:store *notifications:state-two:store
|
|
|
|
^- (list [@da timebox:state-two:store])
|
2020-12-10 08:19:46 +03:00
|
|
|
%+ murn
|
|
|
|
(tap:orm:state-zero:store old)
|
|
|
|
|= [time=@da =timebox:state-zero:store]
|
2021-02-04 04:39:59 +03:00
|
|
|
^- (unit [@da timebox:state-two:store])
|
|
|
|
=/ new-timebox=timebox:state-two:store
|
2020-12-10 08:19:46 +03:00
|
|
|
(convert-timebox-1 timebox)
|
|
|
|
?: =(0 ~(wyt by new-timebox))
|
|
|
|
~
|
|
|
|
`[time new-timebox]
|
|
|
|
::
|
|
|
|
++ convert-timebox-1
|
|
|
|
|= =timebox:state-zero:store
|
2021-02-04 04:39:59 +03:00
|
|
|
^- timebox:state-two:store
|
|
|
|
%- ~(gas by *timebox:state-two:store)
|
|
|
|
^- (list [index:store notification:state-two:store])
|
2020-12-10 08:19:46 +03:00
|
|
|
%+ murn
|
|
|
|
~(tap by timebox)
|
|
|
|
|= [=index:state-zero:store =notification:state-zero:store]
|
2021-02-04 04:39:59 +03:00
|
|
|
^- (unit [index:store notification:state-two:store])
|
2020-12-10 08:19:46 +03:00
|
|
|
=/ new-index=(unit index:store)
|
|
|
|
(convert-index-1 index)
|
2021-02-04 04:39:59 +03:00
|
|
|
=/ new-notification=(unit notification:state-two:store)
|
2020-12-10 08:19:46 +03:00
|
|
|
(convert-notification-1 notification)
|
|
|
|
?~ new-index ~
|
|
|
|
?~ new-notification ~
|
|
|
|
`[u.new-index u.new-notification]
|
|
|
|
::
|
|
|
|
++ convert-index-1
|
|
|
|
|= =index:state-zero:store
|
|
|
|
^- (unit index:store)
|
|
|
|
?+ -.index `index
|
|
|
|
%chat ~
|
|
|
|
::
|
|
|
|
%graph
|
|
|
|
=, index
|
|
|
|
`[%graph group graph module description ~]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ convert-notification-1
|
|
|
|
|= =notification:state-zero:store
|
2021-02-04 04:39:59 +03:00
|
|
|
^- (unit notification:state-two:store)
|
2020-12-10 08:19:46 +03:00
|
|
|
?: ?=(%chat -.contents.notification)
|
|
|
|
~
|
|
|
|
`notification
|
|
|
|
--
|
2020-10-27 08:07:13 +03:00
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
2020-11-24 05:20:44 +03:00
|
|
|
?> (team:title [src our]:bowl)
|
2020-10-27 08:07:13 +03:00
|
|
|
|^
|
|
|
|
?+ path (on-watch:def path)
|
|
|
|
::
|
|
|
|
[%updates ~]
|
|
|
|
:_ this
|
|
|
|
[%give %fact ~ hark-update+!>(initial-updates)]~
|
|
|
|
==
|
2020-11-10 06:32:48 +03:00
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
++ initial-updates
|
|
|
|
^- update:store
|
|
|
|
:- %more
|
|
|
|
^- (list update:store)
|
2020-12-17 04:59:35 +03:00
|
|
|
:- give-unreads
|
|
|
|
[%set-dnd dnd]~
|
2020-10-27 08:07:13 +03:00
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
++ give-since-unreads
|
2020-12-16 10:37:10 +03:00
|
|
|
^- (list [stats-index:store stats:store])
|
2020-11-24 05:20:44 +03:00
|
|
|
%+ turn
|
2020-12-01 08:46:28 +03:00
|
|
|
~(tap by unreads-count)
|
2020-12-16 10:37:10 +03:00
|
|
|
|= [=stats-index:store count=@ud]
|
|
|
|
:* stats-index
|
|
|
|
~(wyt in (~(gut by by-index) stats-index ~))
|
2020-12-01 08:46:28 +03:00
|
|
|
[%count count]
|
2020-12-16 10:37:10 +03:00
|
|
|
(~(gut by last-seen) stats-index *time)
|
2020-11-24 05:20:44 +03:00
|
|
|
==
|
2021-01-13 05:37:23 +03:00
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
++ give-each-unreads
|
2020-12-16 10:37:10 +03:00
|
|
|
^- (list [stats-index:store stats:store])
|
2020-11-24 05:20:44 +03:00
|
|
|
%+ turn
|
|
|
|
~(tap by unreads-each)
|
2020-12-16 10:37:10 +03:00
|
|
|
|= [=stats-index:store indices=(set index:graph-store)]
|
|
|
|
:* stats-index
|
|
|
|
~(wyt in (~(gut by by-index) stats-index ~))
|
2020-11-24 05:20:44 +03:00
|
|
|
[%each indices]
|
2020-12-16 10:37:10 +03:00
|
|
|
(~(gut by last-seen) stats-index *time)
|
2020-11-24 05:20:44 +03:00
|
|
|
==
|
|
|
|
::
|
2021-02-22 03:47:38 +03:00
|
|
|
++ give-group-unreads
|
|
|
|
^- (list [stats-index:store stats:store])
|
|
|
|
%+ murn ~(tap by by-index)
|
|
|
|
|= [=stats-index:store nots=(set [time index:store])]
|
|
|
|
?. ?=(%group -.stats-index)
|
|
|
|
~
|
|
|
|
:- ~
|
|
|
|
:* stats-index
|
|
|
|
~(wyt in nots)
|
|
|
|
[%count 0]
|
|
|
|
*time
|
|
|
|
==
|
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
++ give-unreads
|
2020-11-16 05:22:42 +03:00
|
|
|
^- update:store
|
|
|
|
:- %unreads
|
2021-02-22 03:47:38 +03:00
|
|
|
;: weld
|
|
|
|
give-each-unreads
|
|
|
|
give-since-unreads
|
|
|
|
give-group-unreads
|
|
|
|
==
|
2020-10-27 08:07:13 +03:00
|
|
|
--
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
++ on-peek
|
|
|
|
|= =path
|
|
|
|
^- (unit (unit cage))
|
|
|
|
?+ path (on-peek:def path)
|
|
|
|
::
|
2020-11-16 06:53:18 +03:00
|
|
|
[%x %recent ?(%archive %inbox) @ @ ~]
|
|
|
|
=/ is-archive
|
|
|
|
=(%archive i.t.t.path)
|
2020-10-27 08:07:13 +03:00
|
|
|
=/ offset=@ud
|
|
|
|
(slav %ud i.t.t.t.path)
|
2020-11-16 06:53:18 +03:00
|
|
|
=/ length=@ud
|
|
|
|
(slav %ud i.t.t.t.t.path)
|
2020-11-12 03:26:24 +03:00
|
|
|
:^ ~ ~ %hark-update
|
2020-11-03 03:36:00 +03:00
|
|
|
!> ^- update:store
|
|
|
|
:- %more
|
|
|
|
%+ turn
|
2020-11-12 03:26:24 +03:00
|
|
|
%+ scag length
|
|
|
|
%+ slag offset
|
2020-11-16 06:53:18 +03:00
|
|
|
%- tap-nonempty:ha
|
|
|
|
?:(is-archive archive notifications)
|
2020-11-03 03:36:00 +03:00
|
|
|
|= [time=@da =timebox:store]
|
|
|
|
^- update:store
|
2020-11-16 06:53:18 +03:00
|
|
|
:^ %timebox time is-archive
|
2020-11-03 03:36:00 +03:00
|
|
|
~(tap by timebox)
|
2020-10-27 08:07:13 +03:00
|
|
|
==
|
2020-11-10 06:32:48 +03:00
|
|
|
::
|
2020-10-21 08:54:59 +03:00
|
|
|
++ on-poke
|
|
|
|
~/ %hark-store-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
=^ cards state
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%hark-action (hark-action !<(action:store vase))
|
2021-01-11 02:51:53 +03:00
|
|
|
%noun (poke-noun !<(* vase))
|
2020-10-21 08:54:59 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2021-01-11 02:51:53 +03:00
|
|
|
++ poke-noun
|
|
|
|
|= val=*
|
|
|
|
?+ val ~|(%bad-noun-poke !!)
|
|
|
|
%fix-dangling fix-dangling
|
|
|
|
%print ~&(+.state [~ state])
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ fix-dangling
|
2021-01-12 01:15:14 +03:00
|
|
|
=/ graphs get-keys:gra
|
2021-01-11 02:51:53 +03:00
|
|
|
:_ state
|
|
|
|
%+ roll
|
|
|
|
~(tap by unreads-each)
|
|
|
|
|= $: [=stats-index:store indices=(set index:graph-store)]
|
|
|
|
out=(list card)
|
|
|
|
==
|
|
|
|
?. ?=(%graph -.stats-index) out
|
|
|
|
?. (~(has in graphs) graph.stats-index)
|
|
|
|
:_(out (poke-us %remove-graph graph.stats-index))
|
2021-01-12 01:15:14 +03:00
|
|
|
%+ welp out
|
2021-01-11 02:51:53 +03:00
|
|
|
%+ turn
|
|
|
|
%+ skip
|
2021-01-12 01:15:14 +03:00
|
|
|
~(tap in indices)
|
|
|
|
|= =index:graph-store
|
|
|
|
(check-node-existence:gra graph.stats-index index)
|
2021-01-11 02:51:53 +03:00
|
|
|
|=(=index:graph-store (poke-us %read-each stats-index index))
|
|
|
|
::
|
|
|
|
++ poke-us
|
|
|
|
|= =action:store
|
|
|
|
^- card
|
|
|
|
[%pass / %agent [our dap]:bowl %poke hark-action+!>(action)]
|
|
|
|
::
|
2020-10-21 08:54:59 +03:00
|
|
|
++ hark-action
|
|
|
|
|= =action:store
|
|
|
|
^- (quip card _state)
|
2020-12-15 08:38:56 +03:00
|
|
|
abet:translate:(abed:poke-engine:ha action)
|
2020-10-21 08:54:59 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-agent on-agent:def
|
|
|
|
::
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-arvo
|
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
?. ?=([%autoseen ~] wire)
|
|
|
|
(on-arvo:def wire sign-arvo)
|
2020-12-08 03:22:26 +03:00
|
|
|
?> ?=([%behn %wake *] sign-arvo)
|
2020-11-24 05:20:44 +03:00
|
|
|
:_ this(current-timebox now.bowl)
|
2020-10-21 08:54:59 +03:00
|
|
|
~[autoseen-timer:ha]
|
|
|
|
::
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* met ~(. metadata bowl)
|
2020-12-15 08:38:56 +03:00
|
|
|
++ poke-engine
|
|
|
|
|_ [in=action:store out=(list update:store) cards=(list card)]
|
|
|
|
++ poke-core .
|
|
|
|
::
|
|
|
|
++ abed
|
|
|
|
|= =action:store poke-core(in action)
|
|
|
|
::
|
|
|
|
++ abet
|
|
|
|
^- (quip card _state)
|
|
|
|
:_ state
|
|
|
|
%+ snoc (flop cards)
|
|
|
|
[%give %fact ~[/updates] %hark-update !>([%more (flop out)])]
|
|
|
|
::
|
|
|
|
++ give
|
|
|
|
|= =update:store poke-core(out [update out])
|
|
|
|
::
|
|
|
|
++ emit
|
|
|
|
|= =card poke-core(cards [card cards])
|
|
|
|
::
|
|
|
|
++ translate
|
|
|
|
^+ poke-core
|
2021-01-23 00:00:20 +03:00
|
|
|
?- -.in
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
%add-note (add-note +.in)
|
|
|
|
%archive (do-archive +.in)
|
|
|
|
::
|
|
|
|
%unread-count (unread-count +.in)
|
|
|
|
%read-count (read-count +.in)
|
|
|
|
::
|
|
|
|
%read-each (read-each +.in)
|
|
|
|
%unread-each (unread-each +.in)
|
|
|
|
::
|
|
|
|
%read-note (read-note +.in)
|
|
|
|
%unread-note (unread-note +.in)
|
|
|
|
::
|
|
|
|
%seen-index (seen-index +.in)
|
2020-12-17 09:10:26 +03:00
|
|
|
%remove-graph (remove-graph +.in)
|
2020-12-15 08:38:56 +03:00
|
|
|
%set-dnd (set-dnd +.in)
|
|
|
|
%seen seen
|
2021-01-23 00:00:20 +03:00
|
|
|
%read-all read-all
|
|
|
|
::
|
2020-12-15 08:38:56 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
:: +| %note
|
|
|
|
::
|
|
|
|
:: notification tracking
|
|
|
|
++ upd-cache
|
|
|
|
|= [read=? time=@da =index:store]
|
|
|
|
poke-core(+.state (^upd-cache read time index))
|
|
|
|
::
|
2021-01-11 06:36:00 +03:00
|
|
|
++ rebuild-cache
|
|
|
|
poke-core(+.state (inflate-cache -.state))
|
|
|
|
::
|
2020-12-15 08:38:56 +03:00
|
|
|
++ put-notifs
|
|
|
|
|= [time=@da =timebox:store]
|
|
|
|
poke-core(notifications (put:orm notifications time timebox))
|
|
|
|
::
|
|
|
|
++ add-note
|
|
|
|
|= [=index:store =notification:store]
|
|
|
|
^+ poke-core
|
|
|
|
=/ =timebox:store
|
|
|
|
(gut-orm notifications current-timebox)
|
|
|
|
=/ existing-notif
|
|
|
|
(~(get by timebox) index)
|
|
|
|
=/ new=notification:store
|
|
|
|
(merge-notification existing-notif notification)
|
|
|
|
=/ new-read=?
|
|
|
|
?~ existing-notif %.y
|
|
|
|
read.u.existing-notif
|
|
|
|
=/ new-timebox=timebox:store
|
|
|
|
(~(put by timebox) index new)
|
|
|
|
=. poke-core (put-notifs current-timebox new-timebox)
|
|
|
|
=? poke-core new-read
|
|
|
|
(upd-cache %.n current-timebox index)
|
|
|
|
(give %added current-timebox index new)
|
|
|
|
::
|
|
|
|
++ do-archive
|
|
|
|
|= [time=@da =index:store]
|
|
|
|
^+ poke-core
|
|
|
|
=/ =timebox:store
|
|
|
|
(gut-orm notifications time)
|
|
|
|
=/ =notification:store
|
|
|
|
(~(got by timebox) index)
|
|
|
|
=/ new-timebox=timebox:store
|
|
|
|
(~(del by timebox) index)
|
|
|
|
=? poke-core !read.notification
|
|
|
|
(upd-cache %.y time index)
|
|
|
|
=. poke-core
|
|
|
|
(put-notifs time new-timebox)
|
|
|
|
=. archive
|
|
|
|
%^ jub-orm archive time
|
|
|
|
|= archive-box=timebox:store
|
|
|
|
(~(put by archive-box) index notification(read %.y))
|
|
|
|
(give %archive time index)
|
|
|
|
::
|
2021-01-11 06:36:00 +03:00
|
|
|
:: if we detect cache inconsistencies, wipe and rebuild
|
2020-12-15 08:38:56 +03:00
|
|
|
++ change-read-status
|
|
|
|
|= [time=@da =index:store read=?]
|
2021-01-11 06:36:00 +03:00
|
|
|
^+ poke-core
|
2020-12-15 08:38:56 +03:00
|
|
|
=. poke-core (upd-cache read time index)
|
2021-01-12 01:05:40 +03:00
|
|
|
=/ tib=(unit timebox:store)
|
2021-01-11 06:36:00 +03:00
|
|
|
(get:orm notifications time)
|
2021-01-12 01:05:40 +03:00
|
|
|
?~ tib poke-core
|
|
|
|
=/ not=(unit notification:store)
|
|
|
|
(~(get by u.tib) index)
|
|
|
|
?~ not poke-core
|
2021-01-11 06:36:00 +03:00
|
|
|
=? poke-core
|
|
|
|
:: cache is inconsistent iff we didn't directly
|
|
|
|
:: call this through %read-note or %unread-note
|
2021-01-12 01:05:40 +03:00
|
|
|
&(=(read read.u.not) !?=(?(%read-note %unread-note) -.in))
|
2021-01-12 01:31:10 +03:00
|
|
|
~& >> "Inconsistent hark cache, rebuilding"
|
2021-01-11 06:36:00 +03:00
|
|
|
rebuild-cache
|
2021-02-04 06:48:00 +03:00
|
|
|
?< &(=(read read.u.not) ?=(?(%read-note %unread-note) -.in))
|
2021-01-12 01:05:40 +03:00
|
|
|
=. u.tib
|
|
|
|
(~(put by u.tib) index u.not(read read))
|
2021-01-11 06:36:00 +03:00
|
|
|
=. notifications
|
2021-01-12 01:05:40 +03:00
|
|
|
(put:orm notifications time u.tib)
|
2021-01-11 06:36:00 +03:00
|
|
|
poke-core
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ read-note
|
|
|
|
|= [time=@da =index:store]
|
|
|
|
%. [%read-note time index]
|
|
|
|
give:(change-read-status time index %.y)
|
|
|
|
::
|
|
|
|
++ unread-note
|
|
|
|
|= [time=@da =index:store]
|
|
|
|
%. [%unread-note time index]
|
|
|
|
give:(change-read-status time index %.n)
|
|
|
|
::
|
|
|
|
:: +| %each
|
|
|
|
::
|
|
|
|
:: each unread tracking
|
|
|
|
::
|
|
|
|
++ unread-each
|
2020-12-16 10:37:10 +03:00
|
|
|
|= [=stats-index:store unread=index:graph-store time=@da]
|
|
|
|
=. poke-core (seen-index time stats-index)
|
|
|
|
%+ jub-unreads-each:(give %unread-each stats-index unread time)
|
|
|
|
stats-index
|
2020-12-15 08:38:56 +03:00
|
|
|
|= indices=(set index:graph-store)
|
|
|
|
(~(put ^in indices) unread)
|
|
|
|
::
|
|
|
|
++ read-index-each
|
2020-12-16 07:22:23 +03:00
|
|
|
|= [=stats-index:store ref=index:graph-store]
|
2021-01-13 05:37:23 +03:00
|
|
|
%- read-indices
|
2020-12-15 08:38:56 +03:00
|
|
|
%+ skim
|
2020-12-16 10:37:10 +03:00
|
|
|
~(tap ^in (~(get ju by-index) stats-index))
|
2021-01-13 05:37:23 +03:00
|
|
|
|= [time=@da =index:store]
|
2020-12-15 08:38:56 +03:00
|
|
|
=/ =timebox:store
|
|
|
|
(gut-orm notifications time)
|
2021-01-13 05:37:23 +03:00
|
|
|
=/ not=notification:store
|
|
|
|
(~(got by timebox) index)
|
|
|
|
?. ?=(%graph -.index) %.n
|
|
|
|
?. ?=(%graph -.contents.not) %.n
|
2020-12-15 08:38:56 +03:00
|
|
|
(lien list.contents.not |=(p=post:post =(index.p ref)))
|
|
|
|
::
|
|
|
|
++ read-each
|
2020-12-16 10:37:10 +03:00
|
|
|
|= [=stats-index:store ref=index:graph-store]
|
|
|
|
=. poke-core (read-index-each stats-index ref)
|
|
|
|
%+ jub-unreads-each:(give %read-each stats-index ref)
|
|
|
|
stats-index
|
2020-12-15 08:38:56 +03:00
|
|
|
|= indices=(set index:graph-store)
|
|
|
|
(~(del ^in indices) ref)
|
|
|
|
::
|
|
|
|
++ jub-unreads-each
|
2020-12-16 10:37:10 +03:00
|
|
|
|= $: =stats-index:store
|
2020-12-15 08:38:56 +03:00
|
|
|
f=$-((set index:graph-store) (set index:graph-store))
|
|
|
|
==
|
2020-12-16 10:37:10 +03:00
|
|
|
poke-core(unreads-each (jub stats-index f))
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ unread-count
|
2020-12-16 07:22:23 +03:00
|
|
|
|= [=stats-index:store time=@da]
|
2020-12-15 08:38:56 +03:00
|
|
|
=/ new-count
|
2020-12-16 07:22:23 +03:00
|
|
|
+((~(gut by unreads-count) stats-index 0))
|
2020-12-15 08:38:56 +03:00
|
|
|
=. unreads-count
|
2020-12-16 07:22:23 +03:00
|
|
|
(~(put by unreads-count) stats-index new-count)
|
2020-12-16 10:37:10 +03:00
|
|
|
(seen-index:(give %unread-count stats-index time) time stats-index)
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ read-count
|
2020-12-16 10:37:10 +03:00
|
|
|
|= =stats-index:store
|
|
|
|
=. unreads-count (~(put by unreads-count) stats-index 0)
|
2021-01-13 05:37:23 +03:00
|
|
|
=/ times=(list [@da index:store])
|
2020-12-16 10:37:10 +03:00
|
|
|
~(tap ^in (~(get ju by-index) stats-index))
|
2021-01-13 05:37:23 +03:00
|
|
|
(give:(read-indices times) %read-count stats-index)
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
2021-01-13 05:37:23 +03:00
|
|
|
++ read-indices
|
|
|
|
|= times=(list [time=@da =index:store])
|
2020-12-16 10:37:10 +03:00
|
|
|
|-
|
|
|
|
?~ times poke-core
|
|
|
|
=/ core
|
2021-01-13 05:37:23 +03:00
|
|
|
(read-note i.times)
|
2020-12-16 10:37:10 +03:00
|
|
|
$(poke-core core, times t.times)
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ seen-index
|
2020-12-16 10:37:10 +03:00
|
|
|
|= [time=@da =stats-index:store]
|
2020-12-15 08:38:56 +03:00
|
|
|
=/ new-time=@da
|
2020-12-16 10:37:10 +03:00
|
|
|
(max time (~(gut by last-seen) stats-index 0))
|
2020-12-15 08:38:56 +03:00
|
|
|
=. last-seen
|
2020-12-16 10:37:10 +03:00
|
|
|
(~(put by last-seen) stats-index new-time)
|
|
|
|
(give %seen-index new-time stats-index)
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
2020-12-17 09:10:26 +03:00
|
|
|
++ 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
|
2021-01-13 05:37:23 +03:00
|
|
|
((dif-map-by-key ,(set [@da =index:store])) by-index indices)
|
2020-12-17 09:10:26 +03:00
|
|
|
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
|
2021-01-13 05:37:23 +03:00
|
|
|
=/ times=(list [time=@da =index:store])
|
2020-12-17 09:10:26 +03:00
|
|
|
~(tap ^in (~(get ju by-index) i.indices))
|
|
|
|
=. poke-core
|
2021-01-13 05:37:23 +03:00
|
|
|
(read-indices times)
|
2020-12-17 09:10:26 +03:00
|
|
|
$(indices t.indices)
|
|
|
|
--
|
|
|
|
::
|
2020-12-15 08:38:56 +03:00
|
|
|
++ seen
|
|
|
|
=> (emit cancel-autoseen)
|
|
|
|
=> (emit autoseen-timer)
|
|
|
|
poke-core(current-timebox now.bowl)
|
|
|
|
::
|
2021-01-23 00:00:20 +03:00
|
|
|
++ read-all
|
|
|
|
=: unreads-count (~(run by unreads-count) _0)
|
|
|
|
unreads-each (~(run by unreads-each) _~)
|
|
|
|
notifications (~(run by notifications) _~)
|
|
|
|
==
|
2021-02-16 04:23:13 +03:00
|
|
|
(give:seen:rebuild-cache %read-all ~)
|
2021-01-23 00:00:20 +03:00
|
|
|
::
|
2020-12-15 08:38:56 +03:00
|
|
|
++ set-dnd
|
|
|
|
|= d=?
|
|
|
|
(give:poke-core(dnd d) %set-dnd d)
|
|
|
|
--
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
|
|
|
++ merge-notification
|
2020-12-15 08:38:56 +03:00
|
|
|
|= [existing=(unit notification:store) new=notification:store]
|
2020-10-21 08:54:59 +03:00
|
|
|
^- notification:store
|
2020-12-15 08:38:56 +03:00
|
|
|
?~ existing new
|
|
|
|
?- -.contents.u.existing
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
|
|
|
%graph
|
|
|
|
?> ?=(%graph -.contents.new)
|
2020-12-15 08:38:56 +03:00
|
|
|
u.existing(read %.n, list.contents (weld list.contents.u.existing list.contents.new))
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
|
|
|
%group
|
|
|
|
?> ?=(%group -.contents.new)
|
2020-12-15 08:38:56 +03:00
|
|
|
u.existing(read %.n, list.contents (weld list.contents.u.existing list.contents.new))
|
2020-10-21 08:54:59 +03:00
|
|
|
==
|
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
:: +key-orm: +key:by for ordered maps
|
|
|
|
++ key-orm
|
|
|
|
|= =notifications:store
|
|
|
|
^- (list @da)
|
2020-12-15 08:38:56 +03:00
|
|
|
(turn (tap:orm notifications) |=([@da *] +<-))
|
2020-10-21 08:54:59 +03:00
|
|
|
:: +jub-orm: combo +jab/+gut for ordered maps
|
2020-10-22 04:30:37 +03:00
|
|
|
:: TODO: move to zuse.hoon
|
2020-10-21 08:54:59 +03:00
|
|
|
++ jub-orm
|
|
|
|
|= [=notifications:store time=@da fun=$-(timebox:store timebox:store)]
|
|
|
|
^- notifications:store
|
|
|
|
=/ =timebox:store
|
|
|
|
(fun (gut-orm notifications time))
|
|
|
|
(put:orm notifications time timebox)
|
2020-12-15 08:38:56 +03:00
|
|
|
++ jub
|
2020-12-16 10:37:10 +03:00
|
|
|
|= [=stats-index:store f=$-((set index:graph-store) (set index:graph-store))]
|
|
|
|
^- (jug stats-index:store index:graph-store)
|
2020-12-15 08:38:56 +03:00
|
|
|
=/ val=(set index:graph-store)
|
2020-12-16 10:37:10 +03:00
|
|
|
(~(gut by unreads-each) stats-index ~)
|
|
|
|
(~(put by unreads-each) stats-index (f val))
|
2020-10-22 04:30:37 +03:00
|
|
|
:: +gut-orm: +gut:by for ordered maps
|
|
|
|
:: TODO: move to zuse.hoon
|
2020-10-21 08:54:59 +03:00
|
|
|
++ gut-orm
|
|
|
|
|= [=notifications:store time=@da]
|
|
|
|
^- timebox:store
|
|
|
|
(fall (get:orm notifications time) ~)
|
|
|
|
::
|
|
|
|
++ autoseen-interval ~h3
|
|
|
|
++ cancel-autoseen
|
|
|
|
^- card
|
2020-11-24 05:20:44 +03:00
|
|
|
[%pass /autoseen %arvo %b %rest (add current-timebox autoseen-interval)]
|
2020-10-21 08:54:59 +03:00
|
|
|
::
|
|
|
|
++ autoseen-timer
|
|
|
|
^- card
|
|
|
|
[%pass /autoseen %arvo %b %wait (add now.bowl autoseen-interval)]
|
|
|
|
::
|
2020-11-24 05:20:44 +03:00
|
|
|
++ scry
|
|
|
|
|* [=mold p=path]
|
|
|
|
?> ?=(^ p)
|
|
|
|
?> ?=(^ t.p)
|
|
|
|
.^(mold i.p (scot %p our.bowl) i.t.p (scot %da now.bowl) t.t.p)
|
|
|
|
::
|
2020-10-21 08:54:59 +03:00
|
|
|
++ give
|
|
|
|
|= [paths=(list path) update=update:store]
|
|
|
|
^- (list card)
|
2020-10-27 08:07:13 +03:00
|
|
|
[%give %fact paths [%hark-update !>(update)]]~
|
|
|
|
::
|
2020-12-15 08:38:56 +03:00
|
|
|
++ tap-nonempty
|
|
|
|
|= =notifications:store
|
|
|
|
^- (list [@da timebox:store])
|
|
|
|
%+ skim (tap:orm notifications)
|
|
|
|
|=([@da =timebox:store] !=(~(wyt by timebox) 0))
|
2020-12-16 07:22:23 +03:00
|
|
|
|
2020-12-15 08:38:56 +03:00
|
|
|
::
|
|
|
|
++ upd-cache
|
|
|
|
|= [read=? time=@da =index:store]
|
2020-11-12 04:31:33 +03:00
|
|
|
^+ +.state
|
2020-11-16 05:22:42 +03:00
|
|
|
%_ +.state
|
|
|
|
::
|
|
|
|
by-index
|
2021-01-13 05:37:23 +03:00
|
|
|
%. [(to-stats-index:store index) time index]
|
2020-11-12 04:31:33 +03:00
|
|
|
?: read
|
2020-11-16 05:22:42 +03:00
|
|
|
~(del ju by-index)
|
|
|
|
~(put ju by-index)
|
|
|
|
==
|
2020-11-12 04:31:33 +03:00
|
|
|
::
|
2020-10-27 08:07:13 +03:00
|
|
|
++ inflate-cache
|
2021-02-04 04:39:59 +03:00
|
|
|
|= state-4
|
2020-11-12 04:31:33 +03:00
|
|
|
^+ +.state
|
2021-02-26 02:58:48 +03:00
|
|
|
=. +.state
|
|
|
|
*cache
|
2020-11-12 04:31:33 +03:00
|
|
|
=/ nots=(list [p=@da =timebox:store])
|
2020-10-27 08:07:13 +03:00
|
|
|
(tap:orm notifications)
|
2020-11-12 04:31:33 +03:00
|
|
|
|- =* outer $
|
2020-12-15 08:38:56 +03:00
|
|
|
?~ nots +.state
|
2020-11-12 04:31:33 +03:00
|
|
|
=/ unreads ~(tap by timebox.i.nots)
|
|
|
|
|- =* inner $
|
|
|
|
?~ unreads
|
|
|
|
outer(nots t.nots)
|
2020-10-27 08:07:13 +03:00
|
|
|
=* notification q.i.unreads
|
2020-11-12 04:31:33 +03:00
|
|
|
=* index p.i.unreads
|
2020-10-27 08:07:13 +03:00
|
|
|
?: read.notification
|
2020-11-12 04:31:33 +03:00
|
|
|
inner(unreads t.unreads)
|
|
|
|
=. +.state
|
2020-12-15 08:38:56 +03:00
|
|
|
(upd-cache %.n p.i.nots index)
|
2020-11-12 04:31:33 +03:00
|
|
|
inner(unreads t.unreads)
|
2020-10-21 08:54:59 +03:00
|
|
|
--
|