mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-09-21 15:38:59 +03:00
groups: autojoin checks for group first
This commit is contained in:
parent
a93117add4
commit
62405ce5d0
@ -18,21 +18,31 @@ export class JoinScreen extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
// direct join from incoming URL
|
this.componentDidUpdate();
|
||||||
if ((this.props.ship) && (this.props.name)) {
|
}
|
||||||
const incomingGroup = `${this.props.ship}/${this.props.name}`;
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
const { props, state } = this;
|
||||||
|
// autojoin by URL, waits for group information
|
||||||
|
if ((props.ship && props.name) &&
|
||||||
|
(prevProps && (prevProps.groups !== props.groups))) {
|
||||||
|
console.log('autojoining');
|
||||||
|
const incomingGroup = `${props.ship}/${props.name}`;
|
||||||
|
// push to group if already exists
|
||||||
|
if (`/ship/${incomingGroup}` in props.groups) {
|
||||||
|
this.props.history.push(`/~groups/ship/${incomingGroup}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.setState({ group: incomingGroup }, () => {
|
this.setState({ group: incomingGroup }, () => {
|
||||||
this.onClickJoin();
|
this.onClickJoin();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
// once we've joined, push to group page
|
||||||
|
if (props.groups) {
|
||||||
componentDidUpdate() {
|
if (state.awaiting) {
|
||||||
if (this.props.groups) {
|
const group = `/ship/${state.group}`;
|
||||||
if (this.state.awaiting) {
|
if (group in props.groups) {
|
||||||
const group = `/ship/${this.state.group}`;
|
props.history.push(`/~groups${group}`);
|
||||||
if (group in this.props.groups) {
|
|
||||||
this.props.history.push(`/~groups${group}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,6 +51,7 @@ export class JoinScreen extends Component {
|
|||||||
|
|
||||||
onClickJoin() {
|
onClickJoin() {
|
||||||
const { props, state } = this;
|
const { props, state } = this;
|
||||||
|
console.log('i am joining');
|
||||||
|
|
||||||
const { group } = state;
|
const { group } = state;
|
||||||
const [ship, name] = group.split('/');
|
const [ship, name] = group.split('/');
|
||||||
|
Loading…
Reference in New Issue
Block a user