Skip to content

Commit

Permalink
Merge pull request #225 from tloncorp/m/re-re-growl
Browse files Browse the repository at this point in the history
growl: don't scry during +on-load
  • Loading branch information
jamesacklin authored Oct 6, 2023
2 parents 509f381 + a3f689f commit f04d039
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions desk/app/growl.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,22 @@
def ~(. (default-agent this %.n) bowl)
::
++ on-init
=; consent=?
=^ caz this (on-poke ?:(consent %enable %disable) !>(~))
:_ this
::NOTE sadly, we cannot subscribe to items that may not exist right now,
:: so we subscribe to the whole bucket instead
[[%pass /settings %agent [our.bowl %settings] %watch /desk/groups] caz]
=+ .^ =data:settings
%gx
(scot %p our.bowl)
%settings
(scot %da now.bowl)
/desk/groups/settings-data
==
?> ?=(%desk -.data)
=; =val:settings
?>(?=(%b -.val) p.val)
%+ %~ gut by
(~(gut by desk.data) %groups ~)
'logActivity'
[%b |]
=^ caz this (on-poke %initialize !>(~))
:_ this
::NOTE sadly, we cannot subscribe to items that may not exist right now,
:: so we subscribe to the whole bucket instead
[[%pass /settings %agent [our.bowl %settings] %watch /desk/groups] caz]
::
++ on-save !>(state)
++ on-load
|= old-state=vase
|^ ^- (quip card _this)
=+ !<(old=versioned-state old-state)
?- -.old
%0
=^ caz this on-init :: %0 dropped the ball, re-initialize
:_ this
:_ caz
[%pass /settings %agent [our.bowl %settings] %leave ~]
::
%1
[~ this(state old)]
:: %0 lost sync with the flag so must re-set, but not scry during load
::
%0 [[%pass /re-set %arvo %b %wait now.bowl]~ this]
%1 [~ this(state old)]
==
::
+$ versioned-state $%(state-0 state-1)
Expand All @@ -70,15 +51,29 @@
%set-host
?> =(src.bowl our.bowl)
`this(bark-host !<(ship vase))
::
::
%initialize
=; consent=?
$(mark ?:(consent %enable %disable), vase !>(~))
=/ bap=path /(scot %p our.bowl)/settings/(scot %da now.bowl)
?. .^(? %gu (snoc bap %$)) |
=+ .^(=data:settings %gx (weld bap /desk/groups/settings-data))
?> ?=(%desk -.data)
=; =val:settings
?:(?=(%b -.val) p.val |)
%+ %~ gut by
(~(gut by desk.data) %groups ~)
'logActivity'
[%b |]
::
%enable
:_ this(enabled %.y)
~[[%pass /add-recipient %agent [bark-host %bark] %poke %bark-add-recipient !>(our.bowl)]]
::
::
%disable
:_ this(enabled %.n)
~[[%pass /remove-recipient %agent [bark-host %bark] %poke %bark-remove-recipient !>(our.bowl)]]
::
::
%growl-summarize
?. enabled
:_ this
Expand Down Expand Up @@ -123,13 +118,19 @@
(on-poke ?:(u.new %enable %disable) !>(~))
==
::
++ on-arvo
|= [=wire sign=sign-arvo]
^- (quip card _this)
?> =(/re-set wire)
?> ?=(%wake +<.sign)
(on-poke %initialize !>(~))
::
++ on-watch on-watch:def
++ on-fail
|= [=term =tang]
(mean ':sub +on-fail' term tang)
++ on-leave
|= =path
`this
++ on-arvo on-arvo:def
++ on-peek on-peek:def
--

0 comments on commit f04d039

Please sign in to comment.