mirror of
https://github.com/urbit/shrub.git
synced 2025-01-02 01:25:55 +03:00
groups: contact-card view is passed api prop
This commit is contained in:
parent
db1bbebab3
commit
f30b66055f
@ -231,6 +231,7 @@ export default class GroupsApp extends Component {
|
||||
{...props}
|
||||
/>
|
||||
<ContactCard
|
||||
api={this.api}
|
||||
history={props.history}
|
||||
contact={contact}
|
||||
path={groupPath}
|
||||
@ -283,6 +284,7 @@ export default class GroupsApp extends Component {
|
||||
{...props}
|
||||
/>
|
||||
<ContactCard
|
||||
api={this.api}
|
||||
history={props.history}
|
||||
contact={contact}
|
||||
path={groupPath}
|
||||
@ -311,6 +313,7 @@ export default class GroupsApp extends Component {
|
||||
associations={associations}
|
||||
>
|
||||
<ContactCard
|
||||
api={this.api}
|
||||
history={props.history}
|
||||
path="/~/default"
|
||||
contact={me}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Sigil } from '../../../../lib/sigil';
|
||||
|
||||
import api from '../../api';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { EditElement } from './edit-element';
|
||||
import { Spinner } from '../../../../components/Spinner';
|
||||
@ -143,7 +142,7 @@ export class ContactCard extends Component {
|
||||
},
|
||||
() => {
|
||||
console.log(state.avatarToSet);
|
||||
api
|
||||
props.api
|
||||
.contactEdit(props.path, ship, {
|
||||
avatar: {
|
||||
url: state.avatarToSet
|
||||
@ -165,7 +164,7 @@ export class ContactCard extends Component {
|
||||
|
||||
if (hexTest && hexTest[1] !== currentColor && !props.share) {
|
||||
this.setState({ awaiting: true, type: 'Saving to group' }, () => {
|
||||
api
|
||||
props.api
|
||||
.contactEdit(props.path, `~${props.ship}`, { color: hexTest[1] })
|
||||
.then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
@ -184,7 +183,7 @@ export class ContactCard extends Component {
|
||||
const emailTestResult = emailTest.exec(state.emailToSet);
|
||||
if (emailTestResult) {
|
||||
this.setState({ awaiting: true, type: 'Saving to group' }, () => {
|
||||
api
|
||||
props.api
|
||||
.contactEdit(props.path, ship, { email: state.emailToSet })
|
||||
.then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
@ -201,7 +200,7 @@ export class ContactCard extends Component {
|
||||
return false;
|
||||
}
|
||||
this.setState({ awaiting: true, type: 'Saving to group' }, () => {
|
||||
api
|
||||
props.api
|
||||
.contactEdit(props.path, ship, { nickname: state.nickNameToSet })
|
||||
.then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
@ -218,7 +217,7 @@ export class ContactCard extends Component {
|
||||
return false;
|
||||
}
|
||||
this.setState({ awaiting: true, type: 'Saving to group' }, () => {
|
||||
api
|
||||
props.api
|
||||
.contactEdit(props.path, ship, { notes: state.notesToSet })
|
||||
.then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
@ -236,7 +235,7 @@ export class ContactCard extends Component {
|
||||
const phoneTestResult = phoneTest.exec(state.phoneToSet);
|
||||
if (phoneTestResult) {
|
||||
this.setState({ awaiting: true, type: 'Saving to group' }, () => {
|
||||
api
|
||||
props.api
|
||||
.contactEdit(props.path, ship, { phone: state.phoneToSet })
|
||||
.then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
@ -255,7 +254,7 @@ export class ContactCard extends Component {
|
||||
const websiteTestResult = websiteTest.exec(state.websiteToSet);
|
||||
if (websiteTestResult) {
|
||||
this.setState({ awaiting: true, type: 'Saving to group' }, () => {
|
||||
api
|
||||
props.api
|
||||
.contactEdit(props.path, ship, { website: state.websiteToSet })
|
||||
.then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
@ -268,7 +267,7 @@ export class ContactCard extends Component {
|
||||
this.setState(
|
||||
{ emailToSet: '', awaiting: true, type: 'Removing from group' },
|
||||
() => {
|
||||
api.contactEdit(props.path, ship, { email: '' }).then(() => {
|
||||
props.api.contactEdit(props.path, ship, { email: '' }).then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
});
|
||||
}
|
||||
@ -279,7 +278,7 @@ export class ContactCard extends Component {
|
||||
this.setState(
|
||||
{ nicknameToSet: '', awaiting: true, type: 'Removing from group' },
|
||||
() => {
|
||||
api.contactEdit(props.path, ship, { nickname: '' }).then(() => {
|
||||
props.api.contactEdit(props.path, ship, { nickname: '' }).then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
});
|
||||
}
|
||||
@ -290,7 +289,7 @@ export class ContactCard extends Component {
|
||||
this.setState(
|
||||
{ phoneToSet: '', awaiting: true, type: 'Removing from group' },
|
||||
() => {
|
||||
api.contactEdit(props.path, ship, { phone: '' }).then(() => {
|
||||
props.api.contactEdit(props.path, ship, { phone: '' }).then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
});
|
||||
}
|
||||
@ -301,7 +300,7 @@ export class ContactCard extends Component {
|
||||
this.setState(
|
||||
{ websiteToSet: '', awaiting: true, type: 'Removing from group' },
|
||||
() => {
|
||||
api.contactEdit(props.path, ship, { website: '' }).then(() => {
|
||||
props.api.contactEdit(props.path, ship, { website: '' }).then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
});
|
||||
}
|
||||
@ -316,7 +315,7 @@ export class ContactCard extends Component {
|
||||
type: 'Removing from group'
|
||||
},
|
||||
() => {
|
||||
api.contactEdit(props.path, ship, { avatar: null }).then(() => {
|
||||
props.api.contactEdit(props.path, ship, { avatar: null }).then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
});
|
||||
}
|
||||
@ -327,7 +326,7 @@ export class ContactCard extends Component {
|
||||
this.setState(
|
||||
{ notesToSet: '', awaiting: true, type: 'Removing from group' },
|
||||
() => {
|
||||
api.contactEdit(props.path, ship, { notes: '' }).then(() => {
|
||||
props.api.contactEdit(props.path, ship, { notes: '' }).then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
});
|
||||
}
|
||||
@ -382,7 +381,7 @@ export class ContactCard extends Component {
|
||||
};
|
||||
|
||||
this.setState({ awaiting: true, type: 'Sharing with group' }, () => {
|
||||
api.contactView
|
||||
props.api.contactView
|
||||
.share(`~${props.ship}`, props.path, `~${window.ship}`, contact)
|
||||
.then(() => {
|
||||
props.history.push(`/~groups/view${props.path}/${window.ship}`);
|
||||
@ -404,7 +403,7 @@ export class ContactCard extends Component {
|
||||
avatar: null
|
||||
};
|
||||
|
||||
api.contactView.share(
|
||||
props.api.contactView.share(
|
||||
`~${props.ship}`,
|
||||
props.path,
|
||||
`~${window.ship}`,
|
||||
@ -412,9 +411,9 @@ export class ContactCard extends Component {
|
||||
);
|
||||
|
||||
this.setState({ awaiting: true, type: 'Removing from group' }, () => {
|
||||
api.contactView.delete(props.path).then(() => {
|
||||
props.api.contactView.delete(props.path).then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
props.history.push(`/~groups`);
|
||||
props.history.push('/~groups');
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -423,7 +422,7 @@ export class ContactCard extends Component {
|
||||
const { props } = this;
|
||||
|
||||
this.setState({ awaiting: true, type: 'Removing from group' }, () => {
|
||||
api.contactView.remove(props.path, `~${props.ship}`).then(() => {
|
||||
props.api.contactView.remove(props.path, `~${props.ship}`).then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
props.history.push(`/~groups${props.path}`);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user