mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-13 08:38:43 +03:00
Merge pull request #2841 from urbit/lf/groups-kick-fix
groups: fix self destruct on kick
This commit is contained in:
commit
ebbb3c8349
@ -215,7 +215,9 @@
|
||||
=/ ship (~(get by synced.state) pax.diff)
|
||||
?~ ship [~ state]
|
||||
?. =(src.bol u.ship) [~ state]
|
||||
?. (~(has in members.diff) our.bol) [~ state]
|
||||
?. (~(has in members.diff) our.bol)
|
||||
:_ state
|
||||
[(group-poke pax.diff diff)]~
|
||||
=/ changes (poke-group-hook-action [%remove pax.diff])
|
||||
:_ +.changes
|
||||
%+ welp -.changes
|
||||
|
@ -17,6 +17,7 @@ class UrbitApi {
|
||||
this.contactView = {
|
||||
create: this.contactCreate.bind(this),
|
||||
delete: this.contactDelete.bind(this),
|
||||
remove: this.contactRemove.bind(this),
|
||||
share: this.contactShare.bind(this)
|
||||
};
|
||||
|
||||
@ -103,6 +104,10 @@ class UrbitApi {
|
||||
return this.contactViewAction({ delete: { path }});
|
||||
}
|
||||
|
||||
contactRemove(path, ship) {
|
||||
return this.contactViewAction({ remove: { path, ship } });
|
||||
}
|
||||
|
||||
contactHookAction(data) {
|
||||
return this.action("contact-hook", "contact-action", data);
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ export class ContactCard extends Component {
|
||||
this.notesToSet = this.notesToSet.bind(this);
|
||||
this.setField = this.setField.bind(this);
|
||||
this.shareWithGroup = this.shareWithGroup.bind(this);
|
||||
this.removeFromGroup = this.removeFromGroup.bind(this);
|
||||
this.removeSelfFromGroup = this.removeSelfFromGroup.bind(this);
|
||||
this.removeOtherFromGroup = this.removeOtherFromGroup.bind(this);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
@ -340,7 +341,7 @@ export class ContactCard extends Component {
|
||||
}));
|
||||
}
|
||||
|
||||
removeFromGroup() {
|
||||
removeSelfFromGroup() {
|
||||
const { props } = this;
|
||||
// share empty contact so that we can remove ourselves from group
|
||||
// if we haven't shared yet
|
||||
@ -360,10 +361,19 @@ export class ContactCard extends Component {
|
||||
|
||||
this.setState({ awaiting: true, type: 'Removing from group' }, (() => {
|
||||
api.contactView.delete(props.path).then(() => {
|
||||
const destination = (props.ship === window.ship)
|
||||
? '' : props.path;
|
||||
this.setState({ awaiting: false });
|
||||
props.history.push(`/~groups${destination}`);
|
||||
props.history.push(`/~groups`);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
removeOtherFromGroup() {
|
||||
const { props } = this;
|
||||
|
||||
this.setState({ awaiting: true, type: 'Removing from group' }, (() => {
|
||||
api.contactView.remove(props.path, `~${props.ship}`).then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
props.history.push(`/~groups${props.path}`);
|
||||
});
|
||||
}));
|
||||
}
|
||||
@ -659,7 +669,7 @@ export class ContactCard extends Component {
|
||||
className={
|
||||
'bg-gray0-d mv4 mh3 pa1 f9 red2 pointer flex-shrink-0 ' + adminOpt
|
||||
}
|
||||
onClick={this.removeFromGroup}
|
||||
onClick={props.ship === window.ship ? this.removeSelfFromGroup : this.removeOtherFromGroup}
|
||||
>
|
||||
{props.ship === window.ship
|
||||
? 'Leave Group'
|
||||
|
Loading…
Reference in New Issue
Block a user