mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 11:33:41 +03:00
chat, links, publish: join upon api instantiation
This commit is contained in:
parent
ef00dc71e4
commit
34dcc9f971
@ -17,9 +17,15 @@ export class JoinScreen extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { props } = this;
|
||||
if (props.autoJoin !== '/undefined/undefined' &&
|
||||
props.autoJoin !== '/~/undefined/undefined') {
|
||||
this.componentDidUpdate();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const { props, state } = this;
|
||||
|
||||
if ((props.autoJoin !== '/undefined/undefined' &&
|
||||
props.autoJoin !== '/~/undefined/undefined') &&
|
||||
(props.api && (prevProps?.api !== props.api))) {
|
||||
let station = props.autoJoin.split('/');
|
||||
const sig = props.autoJoin.includes('/~/');
|
||||
|
||||
@ -41,12 +47,9 @@ export class JoinScreen extends Component {
|
||||
awaiting: true
|
||||
}, () => props.api.chatView.join(ship, station, true));
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const { props, state } = this;
|
||||
if (state.station in props.inbox ||
|
||||
(props.chatSynced !== prevProps.chatSynced && state.station !== '/')) {
|
||||
(props?.chatSynced !== prevProps?.chatSynced && state.station !== '/')) {
|
||||
this.setState({ awaiting: false });
|
||||
props.history.push(`/~chat/room${state.station}`);
|
||||
}
|
||||
|
@ -131,8 +131,16 @@ export class LinksApp extends Component {
|
||||
<Route exact path="/~link/join/:resource"
|
||||
render={ (props) => {
|
||||
const resourcePath = '/' + props.match.params.resource;
|
||||
this.api.joinCollection(resourcePath);
|
||||
props.history.push(makeRoutePath(resourcePath));
|
||||
|
||||
const autoJoin = () => {
|
||||
try {
|
||||
this.api.joinCollection(resourcePath);
|
||||
props.history.push(makeRoutePath(resourcePath));
|
||||
} catch(err) {
|
||||
setTimeout(autoJoin, 2000);
|
||||
}
|
||||
};
|
||||
autoJoin();
|
||||
}}
|
||||
/>
|
||||
<Route exact path="/~link/(popout)?/:resource/members"
|
||||
|
@ -18,16 +18,18 @@ export class JoinScreen extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// direct join from incoming URL
|
||||
if ((this.props.ship) && (this.props.notebook)) {
|
||||
const incomingBook = `${this.props.ship}/${this.props.notebook}`;
|
||||
this.setState({ book: incomingBook }, () => {
|
||||
this.onClickJoin();
|
||||
});
|
||||
}
|
||||
this.componentDidUpdate();
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
componentDidUpdate(prevProps) {
|
||||
if ((this.props.ship) && (this.props.notebook)) {
|
||||
const incomingBook = `${this.props.ship}/${this.props.notebook}`;
|
||||
if (this.props.api && (prevProps?.api !== this.props.api)) {
|
||||
this.setState({ book: incomingBook }, () => {
|
||||
this.onClickJoin();
|
||||
});
|
||||
}
|
||||
}
|
||||
// redirect to notebook when we have it
|
||||
if (this.props.notebooks) {
|
||||
if (this.state.awaiting) {
|
||||
|
Loading…
Reference in New Issue
Block a user