mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 11:33:41 +03:00
t groups + contacts: make removes completely clean up state
This commit is contained in:
parent
0145981542
commit
6d4a694aeb
@ -19,7 +19,7 @@
|
|||||||
+$ state-zero [%0 state-base]
|
+$ state-zero [%0 state-base]
|
||||||
+$ state-one [%1 state-base]
|
+$ state-one [%1 state-base]
|
||||||
+$ state-base
|
+$ state-base
|
||||||
$: synced=(map path ship)
|
$: =synced
|
||||||
invite-created=_|
|
invite-created=_|
|
||||||
==
|
==
|
||||||
--
|
--
|
||||||
@ -125,31 +125,29 @@
|
|||||||
++ poke-contact-action
|
++ poke-contact-action
|
||||||
|= act=contact-action
|
|= act=contact-action
|
||||||
^- (quip card _state)
|
^- (quip card _state)
|
||||||
|^
|
|
||||||
:_ state
|
:_ state
|
||||||
?+ -.act !!
|
?+ -.act !!
|
||||||
%edit (handle-contact-action path.act ship.act act)
|
%edit (handle-contact-action path.act ship.act act)
|
||||||
%add (handle-contact-action path.act ship.act act)
|
%add (handle-contact-action path.act ship.act act)
|
||||||
%remove (handle-contact-action path.act ship.act act)
|
%remove (handle-contact-action path.act ship.act act)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ handle-contact-action
|
++ handle-contact-action
|
||||||
|= [=path =ship act=contact-action]
|
|= [=path =ship act=contact-action]
|
||||||
^- (list card)
|
^- (list card)
|
||||||
:: local
|
:: local
|
||||||
?: (team:title our.bol src.bol)
|
?: (team:title our.bol src.bol)
|
||||||
?. (~(has by synced) path) ~
|
?. (~(has by synced) path) ~
|
||||||
=/ shp ?:(=(path /~/default) our.bol (~(got by synced) path))
|
=/ shp ?:(=(path /~/default) our.bol (~(got by synced) path))
|
||||||
=/ appl ?:(=(shp our.bol) %contact-store %contact-hook)
|
=/ appl ?:(=(shp our.bol) %contact-store %contact-hook)
|
||||||
[%pass / %agent [shp appl] %poke %contact-action !>(act)]~
|
[%pass / %agent [shp appl] %poke %contact-action !>(act)]~
|
||||||
:: foreign
|
:: foreign
|
||||||
=/ shp (~(got by synced) path)
|
=/ shp (~(got by synced) path)
|
||||||
?. |(=(shp our.bol) =(src.bol ship)) ~
|
?. |(=(shp our.bol) =(src.bol ship)) ~
|
||||||
:: scry group to check if ship is a member
|
:: scry group to check if ship is a member
|
||||||
=/ =group (need (group-scry path))
|
=/ =group (need (group-scry path))
|
||||||
?. (~(has in group) shp) ~
|
?. (~(has in group) shp) ~
|
||||||
[%pass / %agent [our.bol %contact-store] %poke %contact-action !>(act)]~
|
[%pass / %agent [our.bol %contact-store] %poke %contact-action !>(act)]~
|
||||||
--
|
|
||||||
::
|
::
|
||||||
++ poke-hook-action
|
++ poke-hook-action
|
||||||
|= act=contact-hook-action
|
|= act=contact-hook-action
|
||||||
@ -163,7 +161,7 @@
|
|||||||
=. synced (~(put by synced) path.act our.bol)
|
=. synced (~(put by synced) path.act our.bol)
|
||||||
:_ state
|
:_ state
|
||||||
:~ [%pass contact-path %agent [our.bol %contact-store] %watch contact-path]
|
:~ [%pass contact-path %agent [our.bol %contact-store] %watch contact-path]
|
||||||
[%give %fact ~ %contact-hook-update !>([%initial synced])]
|
[%give %fact [/synced]~ %contact-hook-update !>([%initial synced])]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
%add-synced
|
%add-synced
|
||||||
@ -173,7 +171,7 @@
|
|||||||
=/ contact-path [%contacts path.act]
|
=/ contact-path [%contacts path.act]
|
||||||
:_ state
|
:_ state
|
||||||
:~ [%pass contact-path %agent [ship.act %contact-hook] %watch contact-path]
|
:~ [%pass contact-path %agent [ship.act %contact-hook] %watch contact-path]
|
||||||
[%give %fact ~ %contact-hook-update !>([%initial synced])]
|
[%give %fact [/synced]~ %contact-hook-update !>([%initial synced])]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
%remove
|
%remove
|
||||||
@ -185,16 +183,19 @@
|
|||||||
%- zing
|
%- zing
|
||||||
:~ (pull-wire [%contacts path.act])
|
:~ (pull-wire [%contacts path.act])
|
||||||
[%give %kick ~[[%contacts path.act]] ~]~
|
[%give %kick ~[[%contacts path.act]] ~]~
|
||||||
[%give %fact ~ %contact-hook-update !>([%initial synced])]~
|
[%give %fact [/synced]~ %contact-hook-update !>([%initial synced])]~
|
||||||
==
|
==
|
||||||
?. |(=(u.ship src.bol) (team:title our.bol src.bol))
|
?. |(=(u.ship src.bol) (team:title our.bol src.bol))
|
||||||
:: if neither ship = source or source = us, do nothing
|
:: if neither ship = source or source = us, do nothing
|
||||||
[~ state]
|
[~ state]
|
||||||
:: delete a foreign ship's path
|
:: delete a foreign ship's path
|
||||||
|
=/ cards
|
||||||
|
(handle-contact-action path.act our.bol [%remove path.act our.bol])
|
||||||
:_ state(synced (~(del by synced) path.act))
|
:_ state(synced (~(del by synced) path.act))
|
||||||
%- zing
|
%- zing
|
||||||
:~ (pull-wire [%contacts path.act])
|
:~ (pull-wire [%contacts path.act])
|
||||||
[%give %fact ~ %contact-hook-update !>([%initial synced])]~
|
[%give %fact [/synced]~ %contact-hook-update !>([%initial synced])]~
|
||||||
|
cards
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -207,10 +208,7 @@
|
|||||||
=/ =group (need (group-scry pax))
|
=/ =group (need (group-scry pax))
|
||||||
?> (~(has in group) src.bol)
|
?> (~(has in group) src.bol)
|
||||||
=/ contacts (need (contacts-scry pax))
|
=/ contacts (need (contacts-scry pax))
|
||||||
:~ :*
|
[%give %fact ~ %contact-update !>([%contacts pax contacts])]~
|
||||||
%give %fact ~ %contact-update
|
|
||||||
!>([%contacts pax contacts])
|
|
||||||
== ==
|
|
||||||
::
|
::
|
||||||
++ watch-synced
|
++ watch-synced
|
||||||
|= pax=path
|
|= pax=path
|
||||||
@ -324,13 +322,15 @@
|
|||||||
==
|
==
|
||||||
::
|
::
|
||||||
%add
|
%add
|
||||||
=/ owner (~(got by synced) path.fact)
|
=/ owner (~(get by synced) path.fact)
|
||||||
?> |(=(owner src.bol) =(src.bol ship.fact))
|
?~ owner ~
|
||||||
|
?> |(=(u.owner src.bol) =(src.bol ship.fact))
|
||||||
~[(contact-poke [%add path.fact ship.fact contact.fact])]
|
~[(contact-poke [%add path.fact ship.fact contact.fact])]
|
||||||
::
|
::
|
||||||
%remove
|
%remove
|
||||||
=/ owner (~(got by synced) path.fact)
|
=/ owner (~(get by synced) path.fact)
|
||||||
?> |(=(owner src.bol) =(src.bol ship.fact))
|
?~ owner ~
|
||||||
|
?> |(=(u.owner src.bol) =(src.bol ship.fact))
|
||||||
%+ welp
|
%+ welp
|
||||||
:~ (group-poke [%remove [ship.fact ~ ~] path.fact])
|
:~ (group-poke [%remove [ship.fact ~ ~] path.fact])
|
||||||
(contact-poke [%remove path.fact ship.fact])
|
(contact-poke [%remove path.fact ship.fact])
|
||||||
|
@ -142,7 +142,7 @@
|
|||||||
|= [=path =ship]
|
|= [=path =ship]
|
||||||
^- (quip card _state)
|
^- (quip card _state)
|
||||||
=/ contacts (~(got by rolodex) path)
|
=/ contacts (~(got by rolodex) path)
|
||||||
?> (~(has by contacts) ship)
|
?. (~(has by contacts) ship) [~ state]
|
||||||
=. contacts (~(del by contacts) ship)
|
=. contacts (~(del by contacts) ship)
|
||||||
:- (send-diff path [%remove path ship])
|
:- (send-diff path [%remove path ship])
|
||||||
state(rolodex (~(put by rolodex) path contacts))
|
state(rolodex (~(put by rolodex) path contacts))
|
||||||
|
@ -147,9 +147,9 @@
|
|||||||
::
|
::
|
||||||
%delete
|
%delete
|
||||||
%+ weld
|
%+ weld
|
||||||
:~ (group-poke [%unbundle path.act])
|
:~ (contact-hook-poke [%remove path.act])
|
||||||
|
(group-poke [%unbundle path.act])
|
||||||
(contact-poke [%delete path.act])
|
(contact-poke [%delete path.act])
|
||||||
(contact-hook-poke [%remove path.act])
|
|
||||||
==
|
==
|
||||||
(delete-metadata path.act)
|
(delete-metadata path.act)
|
||||||
::
|
::
|
||||||
|
@ -38,18 +38,12 @@
|
|||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
=/ old !<(state-zero vase)
|
=/ old !<(state-zero vase)
|
||||||
:_ this(state old)
|
:_ this(state old)
|
||||||
%+ murn
|
%+ murn ~(tap by synced.old)
|
||||||
~(tap by synced.old)
|
|
||||||
|= [=path =ship]
|
|= [=path =ship]
|
||||||
^- (unit card)
|
^- (unit card)
|
||||||
=/ =wire
|
=/ =wire [(scot %p ship) %group path]
|
||||||
[(scot %p ship) %group path]
|
=/ =term ?:(=(our.bowl ship) %group-store %group-hook)
|
||||||
=/ =term
|
?: (~(has by wex.bowl) [wire ship term]) ~
|
||||||
?: =(our.bowl ship)
|
|
||||||
%group-store
|
|
||||||
%group-hook
|
|
||||||
?: (~(has by wex.bowl) [wire ship term])
|
|
||||||
~
|
|
||||||
`[%pass wire %agent [ship term] %watch [%group path]]
|
`[%pass wire %agent [ship term] %watch [%group path]]
|
||||||
::
|
::
|
||||||
++ on-leave on-leave:def
|
++ on-leave on-leave:def
|
||||||
@ -173,10 +167,9 @@
|
|||||||
%remove [(update-subscribers [%group pax.diff] diff) state]
|
%remove [(update-subscribers [%group pax.diff] diff) state]
|
||||||
::
|
::
|
||||||
%unbundle
|
%unbundle
|
||||||
:_ state(synced (~(del by synced.state) pax.diff))
|
=/ ship (~(get by synced.state) pax.diff)
|
||||||
%+ snoc
|
?~ ship [~ state]
|
||||||
(update-subscribers [%group pax.diff] diff)
|
(poke-group-hook-action [%remove pax.diff])
|
||||||
[%give %kick [%group pax.diff]~ ~]
|
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ handle-foreign
|
++ handle-foreign
|
||||||
@ -185,7 +178,6 @@
|
|||||||
?- -.diff
|
?- -.diff
|
||||||
%keys [~ state]
|
%keys [~ state]
|
||||||
%bundle [~ state]
|
%bundle [~ state]
|
||||||
::
|
|
||||||
%path
|
%path
|
||||||
:_ state
|
:_ state
|
||||||
?~ pax.diff ~
|
?~ pax.diff ~
|
||||||
@ -219,23 +211,24 @@
|
|||||||
[(group-poke pax.diff diff)]~
|
[(group-poke pax.diff diff)]~
|
||||||
::
|
::
|
||||||
%remove
|
%remove
|
||||||
:_ state
|
?~ pax.diff [~ state]
|
||||||
?~ pax.diff ~
|
|
||||||
=/ ship (~(get by synced.state) pax.diff)
|
=/ ship (~(get by synced.state) pax.diff)
|
||||||
?~ ship ~
|
?~ ship [~ state]
|
||||||
?. =(src.bol u.ship) ~
|
?. =(src.bol u.ship) [~ state]
|
||||||
[(group-poke pax.diff diff)]~
|
?. (~(has in members.diff) our.bol) [~ state]
|
||||||
|
=/ changes (poke-group-hook-action [%remove pax.diff])
|
||||||
|
:_ +.changes
|
||||||
|
%+ welp -.changes
|
||||||
|
:~ (group-poke pax.diff diff)
|
||||||
|
(group-poke pax.diff [%unbundle pax.diff])
|
||||||
|
==
|
||||||
::
|
::
|
||||||
%unbundle
|
%unbundle
|
||||||
?~ pax.diff
|
?~ pax.diff [~ state]
|
||||||
[~ state]
|
|
||||||
=/ ship (~(get by synced.state) pax.diff)
|
=/ ship (~(get by synced.state) pax.diff)
|
||||||
?~ ship
|
?~ ship [~ state]
|
||||||
[~ state]
|
?. =(src.bol u.ship) [~ state]
|
||||||
?. =(src.bol u.ship)
|
(poke-group-hook-action [%remove pax.diff])
|
||||||
[~ state]
|
|
||||||
:_ state(synced (~(del by synced.state) pax.diff))
|
|
||||||
[(group-poke pax.diff diff)]~
|
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ group-poke
|
++ group-poke
|
||||||
@ -262,5 +255,4 @@
|
|||||||
?: =(u.shp our.bol)
|
?: =(u.shp our.bol)
|
||||||
[%pass wir %agent [our.bol %group-store] %leave ~]~
|
[%pass wir %agent [our.bol %group-store] %leave ~]~
|
||||||
[%pass wir %agent [u.shp %group-hook] %leave ~]~
|
[%pass wir %agent [u.shp %group-hook] %leave ~]~
|
||||||
::
|
|
||||||
--
|
--
|
||||||
|
@ -11,8 +11,7 @@ class UrbitApi {
|
|||||||
this.bindPaths = [];
|
this.bindPaths = [];
|
||||||
|
|
||||||
this.contactHook = {
|
this.contactHook = {
|
||||||
edit: this.contactEdit.bind(this),
|
edit: this.contactEdit.bind(this)
|
||||||
remove: this.contactRemove.bind(this)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.contactView = {
|
this.contactView = {
|
||||||
@ -108,14 +107,6 @@ class UrbitApi {
|
|||||||
return this.action("contact-hook", "contact-action", data);
|
return this.action("contact-hook", "contact-action", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
contactRemove(path, ship) {
|
|
||||||
return this.contactHookAction({
|
|
||||||
remove: {
|
|
||||||
path, ship
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
contactEdit(path, ship, editField) {
|
contactEdit(path, ship, editField) {
|
||||||
/* editField can be...
|
/* editField can be...
|
||||||
{nickname: ''}
|
{nickname: ''}
|
||||||
|
@ -317,13 +317,12 @@ export class ContactCard extends Component {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.setState({awaiting: true, type: "Removing from group"}, (() => {
|
this.setState({awaiting: true, type: "Removing from group"}, (() => {
|
||||||
api.contactHook.remove(props.path, `~${props.ship}`).then(() => {
|
api.contactView.delete(props.path).then(() => {
|
||||||
let destination = (props.ship === window.ship)
|
let destination = (props.ship === window.ship)
|
||||||
? "" : props.path;
|
? "" : props.path;
|
||||||
this.setState({awaiting: false});
|
this.setState({awaiting: false});
|
||||||
props.history.push(`/~groups${destination}`);
|
props.history.push(`/~groups${destination}`);
|
||||||
});
|
});
|
||||||
api.contactView.delete(props.path);
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user