mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 21:12:56 +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
|
%contacts
|
||||||
=/ owner (~(got by synced) path.fact)
|
=/ owner (~(got by synced) path.fact)
|
||||||
?> =(owner src.bol)
|
?> =(owner src.bol)
|
||||||
%+ weld
|
=/ have-contacts=(unit contacts)
|
||||||
:~ (contact-poke [%delete path.fact])
|
(contacts-scry path.fact)
|
||||||
(contact-poke [%create 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)
|
%+ turn ~(tap by contacts.fact)
|
||||||
|= [=ship =contact]
|
|= [=ship =contact]
|
||||||
(contact-poke [%add path.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)
|
||||||
|
==
|
||||||
::
|
::
|
||||||
%add
|
%add
|
||||||
=/ owner (~(got by synced) path.fact)
|
=/ owner (~(got by synced) path.fact)
|
||||||
|
@ -33,8 +33,24 @@
|
|||||||
++ on-init on-init:def
|
++ on-init on-init:def
|
||||||
++ on-save !>(state)
|
++ on-save !>(state)
|
||||||
++ on-load
|
++ on-load
|
||||||
|= old=vase
|
|= =vase
|
||||||
`this(state !<(state-zero old))
|
^- (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-leave on-leave:def
|
||||||
++ on-peek on-peek:def
|
++ on-peek on-peek:def
|
||||||
++ on-arvo on-arvo:def
|
++ on-arvo on-arvo:def
|
||||||
@ -74,20 +90,26 @@
|
|||||||
?~ p.sign
|
?~ p.sign
|
||||||
[~ this]
|
[~ this]
|
||||||
%- (slog u.p.sign)
|
%- (slog u.p.sign)
|
||||||
?> ?=([@ @ *] wire)
|
?> ?=([@ %group ^] wire)
|
||||||
=/ =ship (slav %p i.wire)
|
=/ =ship (slav %p i.wire)
|
||||||
=. synced.state (~(del by synced.state) t.t.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]
|
[~ this]
|
||||||
::
|
::
|
||||||
%kick
|
%kick
|
||||||
?> ?=([@ @ *] wire)
|
?> ?=([@ %group ^] wire)
|
||||||
=/ =ship (slav %p i.wire)
|
=/ =ship (slav %p i.wire)
|
||||||
?. (~(has by synced.state) wire)
|
=* group t.t.wire
|
||||||
|
?. (~(has by synced.state) group)
|
||||||
[~ this]
|
[~ this]
|
||||||
=/ group-path [%group wire]
|
=* group-path t.wire
|
||||||
=/ group-wire [i.wire group-path]
|
|
||||||
:_ this
|
:_ this
|
||||||
[%pass group-wire %agent [ship %group-hook] %watch group-path]~
|
[%pass wire %agent [ship %group-hook] %watch group-path]~
|
||||||
::
|
::
|
||||||
%fact
|
%fact
|
||||||
?. ?=(%group-update p.cage.sign)
|
?. ?=(%group-update p.cage.sign)
|
||||||
@ -169,10 +191,23 @@
|
|||||||
=/ ship (~(get by synced.state) pax.diff)
|
=/ ship (~(get by synced.state) pax.diff)
|
||||||
?~ ship ~
|
?~ ship ~
|
||||||
?. =(src.bol u.ship) ~
|
?. =(src.bol u.ship) ~
|
||||||
:~ (group-poke pax.diff [%unbundle pax.diff])
|
=/ have-group=(unit group)
|
||||||
(group-poke pax.diff [%bundle pax.diff])
|
(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])
|
(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
|
%add
|
||||||
:_ state
|
:_ state
|
||||||
|
Loading…
Reference in New Issue
Block a user