mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 22:33:06 +03:00
Merge branch 'lf/chat-new-dm-race' (#2823)
* origin/lf/chat-new-dm-race: chat-js: fix race condition in new-dm flow Signed-off-by: Matilde Park <matilde@tlon.io>
This commit is contained in:
commit
8c3e2cff92
@ -11,13 +11,10 @@ export class NewDmScreen extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
ship: null,
|
||||
idError: false,
|
||||
inviteError: false,
|
||||
allowHistory: true,
|
||||
station: null,
|
||||
awaiting: false
|
||||
};
|
||||
|
||||
this.setInvite = this.setInvite.bind(this);
|
||||
this.onClickCreate = this.onClickCreate.bind(this);
|
||||
}
|
||||
|
||||
@ -26,8 +23,6 @@ export class NewDmScreen extends Component {
|
||||
if (props.autoCreate && urbitOb.isValidPatp(props.autoCreate)) {
|
||||
this.setState(
|
||||
{
|
||||
error: false,
|
||||
success: true,
|
||||
ship: props.autoCreate.slice(1),
|
||||
awaiting: true
|
||||
},
|
||||
@ -40,20 +35,14 @@ export class NewDmScreen extends Component {
|
||||
const { props, state } = this;
|
||||
|
||||
if (prevProps !== props) {
|
||||
let station = `/~${window.ship}/${state.idName}`;
|
||||
if (station in props.inbox) {
|
||||
props.history.push("/~chat/room" + station);
|
||||
const { station } = this.state;
|
||||
if (station && station in props.inbox) {
|
||||
this.setState({ awaiting: false });
|
||||
props.history.push(`/~chat/room${station}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setInvite(value) {
|
||||
this.setState({
|
||||
groups: [],
|
||||
ship: value.ships[0]
|
||||
});
|
||||
}
|
||||
|
||||
onClickCreate() {
|
||||
const { props, state } = this;
|
||||
|
||||
@ -73,15 +62,11 @@ export class NewDmScreen extends Component {
|
||||
|
||||
this.setState(
|
||||
{
|
||||
error: false,
|
||||
success: true,
|
||||
group: [],
|
||||
ship: [],
|
||||
awaiting: true
|
||||
station
|
||||
},
|
||||
() => {
|
||||
let groupPath = station;
|
||||
let submit = props.api.chatView.create(
|
||||
props.api.chatView.create(
|
||||
`~${window.ship} <-> ~${state.ship}`,
|
||||
"",
|
||||
station,
|
||||
@ -90,10 +75,6 @@ export class NewDmScreen extends Component {
|
||||
state.ship !== window.ship ? [`~${state.ship}`] : [],
|
||||
true
|
||||
);
|
||||
submit.then(() => {
|
||||
this.setState({ awaiting: false });
|
||||
props.history.push(`/~chat/room${station}`);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user