chat, links, publish: join upon api instantiation

This commit is contained in:
Matilde Park 2020-06-15 15:19:00 -04:00
parent ef00dc71e4
commit 34dcc9f971
3 changed files with 30 additions and 17 deletions

View File

@ -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}`);
}

View File

@ -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"

View File

@ -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) {