mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-03 14:37:05 +03:00
group-on-leave thread: clean up contacts as well as everything else
This commit is contained in:
parent
9e69cba237
commit
2760f79f66
@ -181,21 +181,7 @@
|
||||
~[(add-pending rid ship.act)]
|
||||
::
|
||||
%delete
|
||||
=/ rid=resource
|
||||
(de-path:resource path.act)
|
||||
=/ group-pokes=(list card)
|
||||
?: =(our.bol entity.rid)
|
||||
~[(group-push-poke %remove rid)]
|
||||
:~ (group-proxy-poke %remove-members rid (sy our.bol ~))
|
||||
(group-pull-poke %remove rid)
|
||||
==
|
||||
;: weld
|
||||
group-pokes
|
||||
:~ (contact-hook-poke [%remove path.act])
|
||||
(group-poke [%remove-group rid ~])
|
||||
(contact-poke [%delete path.act])
|
||||
==
|
||||
==
|
||||
~
|
||||
::
|
||||
%remove
|
||||
=/ rid=resource
|
||||
|
@ -417,6 +417,7 @@
|
||||
::
|
||||
++ remove-group
|
||||
|= =json
|
||||
^- [resource ~]
|
||||
?> ?=(%o -.json)
|
||||
=/ rid=resource
|
||||
(dejs:resource (~(got by p.json) 'resource'))
|
||||
|
@ -1,4 +1,4 @@
|
||||
/- spider, grp=group-store, gra=graph-store, met=metadata-store, hook=metadata-hook
|
||||
/- spider, grp=group-store, gra=graph-store, met=metadata-store, con=contact-store
|
||||
/+ strandio, res=resource
|
||||
::
|
||||
=* strand strand:spider
|
||||
@ -13,16 +13,50 @@
|
||||
?. ?=(%remove-group -.update)
|
||||
(pure:m !>(~))
|
||||
;< =bowl:spider bind:m get-bowl:strandio
|
||||
:: tell group host to remove us as member
|
||||
::
|
||||
;< ~ bind:m
|
||||
%+ raw-poke
|
||||
[entity.resource.update %group-push-hook]
|
||||
:- %group-update
|
||||
!> ^- update:grp
|
||||
[%remove-members resource.update (silt [our.bowl ~])]
|
||||
:: stop serving or syncing group updates
|
||||
::
|
||||
;< ~ bind:m
|
||||
%+ raw-poke
|
||||
[our.bowl %group-push-hook]
|
||||
:- %push-hook-action
|
||||
!>([%remove resource.update])
|
||||
;< ~ bind:m
|
||||
%+ raw-poke
|
||||
[our.bowl %group-pull-hook]
|
||||
:- %pull-hook-action
|
||||
!>([%remove resource.update])
|
||||
:: stop serving or syncing contacts associated with group
|
||||
::
|
||||
;< ~ bind:m
|
||||
%+ raw-poke
|
||||
[our.bowl %contact-hook]
|
||||
:- %contact-hook-action
|
||||
!>([%remove (en-path:res resource.update)])
|
||||
:: remove contact data associated with group
|
||||
::
|
||||
;< ~ bind:m
|
||||
%+ raw-poke
|
||||
[our.bowl %contact-store]
|
||||
:- %contact-action
|
||||
!> ^- contact-action:con
|
||||
[%delete (en-path:res resource.update)]
|
||||
:: stop serving or syncing metadata associated with group
|
||||
::
|
||||
;< ~ bind:m
|
||||
%+ raw-poke
|
||||
[our.bowl %metadata-hook]
|
||||
:- %metadata-hook-action
|
||||
!> ^- metadata-hook-action:hook
|
||||
[%remove (en-path:res resource.update)]
|
||||
::
|
||||
!>([%remove (en-path:res resource.update)])
|
||||
:: get metadata associated with group
|
||||
::
|
||||
;< =associations:met bind:m
|
||||
%+ scry associations:met
|
||||
;: weld
|
||||
|
@ -32,10 +32,6 @@ export default class ContactsApi extends BaseApi<StoreState> {
|
||||
});
|
||||
}
|
||||
|
||||
delete(path: Path) {
|
||||
return this.viewAction({ delete: { path } });
|
||||
}
|
||||
|
||||
remove(path: Path, ship: Patp) {
|
||||
return this.viewAction({ remove: { path, ship } });
|
||||
}
|
||||
|
@ -26,6 +26,10 @@ export default class GroupsApi extends BaseApi<StoreState> {
|
||||
return this.proxyAction({ addMembers: { resource, ships } });
|
||||
}
|
||||
|
||||
removeGroup(resource: Resource) {
|
||||
return this.storeAction({ removeGroup: { resource } });
|
||||
}
|
||||
|
||||
changePolicy(resource: Resource, diff: Enc<GroupPolicyDiff>) {
|
||||
return this.proxyAction({ changePolicy: { resource, diff } });
|
||||
}
|
||||
@ -35,6 +39,7 @@ export default class GroupsApi extends BaseApi<StoreState> {
|
||||
}
|
||||
|
||||
private storeAction(action: GroupAction) {
|
||||
return this.action('group-store', 'group-action', action);
|
||||
console.log(action);
|
||||
return this.action('group-store', 'group-update', action);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ function DeleteGroup(props: {
|
||||
const onDelete = async () => {
|
||||
const name = props.association['group-path'].split('/').pop();
|
||||
if (prompt(`To confirm deleting this group, type ${name}`) === name) {
|
||||
await props.api.contacts.delete(props.association["group-path"]);
|
||||
const resource = resourceFromPath(props.association["group-path"])
|
||||
await props.api.groups.removeGroup(resource);
|
||||
history.push("/");
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user