mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 13:04:17 +03:00
Merge pull request #2609 from urbit/m/group-kick-fix
group-hook: fix resubscribe bug
This commit is contained in:
commit
31794ebacf
@ -273,13 +273,38 @@
|
||||
%contacts
|
||||
=/ owner (~(got by synced) path.fact)
|
||||
?> =(owner src.bol)
|
||||
%+ weld
|
||||
:~ (contact-poke [%delete path.fact])
|
||||
(contact-poke [%create path.fact])
|
||||
=/ have-contacts=(unit contacts)
|
||||
(contacts-scry path.fact)
|
||||
?~ have-contacts
|
||||
:: if we don't have any contacts yet,
|
||||
:: create the entry, and %add every contact
|
||||
::
|
||||
:- (contact-poke [%create path.fact])
|
||||
%+ turn ~(tap by contacts.fact)
|
||||
|= [=ship =contact]
|
||||
(contact-poke [%add path.fact ship contact])
|
||||
:: if we already have some, decide between %add, %remove and recreate
|
||||
:: on a per-contact basis
|
||||
::
|
||||
%- zing
|
||||
%+ turn
|
||||
%~ tap in
|
||||
%- ~(uni in ~(key by contacts.fact))
|
||||
~(key by u.have-contacts)
|
||||
|= =ship
|
||||
^- (list card)
|
||||
=/ have=(unit contact) (~(get by u.have-contacts) ship)
|
||||
=/ want=(unit contact) (~(get by contacts.fact) ship)
|
||||
?~ have
|
||||
[(contact-poke %add path.fact ship (need want))]~
|
||||
?~ want
|
||||
[(contact-poke %remove path.fact ship)]~
|
||||
?: =(u.want u.have) ~
|
||||
::TODO probably want an %all edit-field that resolves to more granular
|
||||
:: updates within the contact-store?
|
||||
:~ (contact-poke %remove path.fact ship)
|
||||
(contact-poke %add path.fact ship u.want)
|
||||
==
|
||||
%+ turn ~(tap by contacts.fact)
|
||||
|= [=ship =contact]
|
||||
(contact-poke [%add path.fact ship contact])
|
||||
::
|
||||
%add
|
||||
=/ owner (~(got by synced) path.fact)
|
||||
|
@ -33,8 +33,24 @@
|
||||
++ on-init on-init:def
|
||||
++ on-save !>(state)
|
||||
++ on-load
|
||||
|= old=vase
|
||||
`this(state !<(state-zero old))
|
||||
|= =vase
|
||||
^- (quip card _this)
|
||||
=/ old !<(state-zero vase)
|
||||
:_ this(state old)
|
||||
%+ murn
|
||||
~(tap by synced.old)
|
||||
|= [=path =ship]
|
||||
^- (unit card)
|
||||
=/ =wire
|
||||
[(scot %p ship) %group path]
|
||||
=/ =term
|
||||
?: =(our.bowl ship)
|
||||
%group-store
|
||||
%group-hook
|
||||
?: (~(has by wex.bowl) [wire ship term])
|
||||
~
|
||||
`[%pass wire %agent [ship term] %watch [%group path]]
|
||||
::
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek on-peek:def
|
||||
++ on-arvo on-arvo:def
|
||||
@ -74,20 +90,26 @@
|
||||
?~ p.sign
|
||||
[~ this]
|
||||
%- (slog u.p.sign)
|
||||
?> ?=([@ @ *] wire)
|
||||
=/ =ship (slav %p i.wire)
|
||||
=. synced.state (~(del by synced.state) t.t.wire)
|
||||
?> ?=([@ %group ^] wire)
|
||||
=/ =ship (slav %p i.wire)
|
||||
=* group t.t.wire
|
||||
:: only remove from synced if this watch-nack came from the ship we
|
||||
:: thought we were actively syncing from
|
||||
::
|
||||
=? synced.state
|
||||
=(ship (~(gut by synced.state) group ship))
|
||||
(~(del by synced.state) group)
|
||||
[~ this]
|
||||
::
|
||||
%kick
|
||||
?> ?=([@ @ *] wire)
|
||||
?> ?=([@ %group ^] wire)
|
||||
=/ =ship (slav %p i.wire)
|
||||
?. (~(has by synced.state) wire)
|
||||
=* group t.t.wire
|
||||
?. (~(has by synced.state) group)
|
||||
[~ this]
|
||||
=/ group-path [%group wire]
|
||||
=/ group-wire [i.wire group-path]
|
||||
=* group-path t.wire
|
||||
:_ this
|
||||
[%pass group-wire %agent [ship %group-hook] %watch group-path]~
|
||||
[%pass wire %agent [ship %group-hook] %watch group-path]~
|
||||
::
|
||||
%fact
|
||||
?. ?=(%group-update p.cage.sign)
|
||||
@ -169,10 +191,23 @@
|
||||
=/ ship (~(get by synced.state) pax.diff)
|
||||
?~ ship ~
|
||||
?. =(src.bol u.ship) ~
|
||||
:~ (group-poke pax.diff [%unbundle pax.diff])
|
||||
(group-poke pax.diff [%bundle pax.diff])
|
||||
(group-poke pax.diff [%add members.diff pax.diff])
|
||||
==
|
||||
=/ have-group=(unit group)
|
||||
(group-scry pax.diff)
|
||||
?~ have-group
|
||||
:: if we don't have the group yet, create it
|
||||
::
|
||||
:~ (group-poke pax.diff [%bundle pax.diff])
|
||||
(group-poke pax.diff [%add members.diff pax.diff])
|
||||
==
|
||||
:: if we already have the group, calculate and apply the diff
|
||||
::
|
||||
=/ added=group (~(dif in members.diff) u.have-group)
|
||||
=/ removed=group (~(dif in u.have-group) members.diff)
|
||||
%+ weld
|
||||
?~ added ~
|
||||
[(group-poke pax.diff [%add added pax.diff])]~
|
||||
?~ removed ~
|
||||
[(group-poke pax.diff [%remove removed pax.diff])]~
|
||||
::
|
||||
%add
|
||||
:_ state
|
||||
|
Loading…
Reference in New Issue
Block a user