mirror of https://github.com/vector-im/riot-web
Fix Space creation wizard go to my first room button behaviour
parent
18b5b18f7c
commit
43868c4539
|
@ -89,7 +89,7 @@ interface IProps {
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
phase: Phase;
|
phase: Phase;
|
||||||
createdRooms?: boolean; // internal state for the creation wizard
|
firstRoomId?: boolean; // internal state for the creation wizard
|
||||||
showRightPanel: boolean;
|
showRightPanel: boolean;
|
||||||
myMembership: string;
|
myMembership: string;
|
||||||
}
|
}
|
||||||
|
@ -508,7 +508,7 @@ const SpaceSetupFirstRooms = ({ space, title, description, onFinished }) => {
|
||||||
try {
|
try {
|
||||||
const isPublic = space.getJoinRule() === JoinRule.Public;
|
const isPublic = space.getJoinRule() === JoinRule.Public;
|
||||||
const filteredRoomNames = roomNames.map(name => name.trim()).filter(Boolean);
|
const filteredRoomNames = roomNames.map(name => name.trim()).filter(Boolean);
|
||||||
await Promise.all(filteredRoomNames.map(name => {
|
const roomIds = await Promise.all(filteredRoomNames.map(name => {
|
||||||
return createRoom({
|
return createRoom({
|
||||||
createOpts: {
|
createOpts: {
|
||||||
preset: isPublic ? Preset.PublicChat : Preset.PrivateChat,
|
preset: isPublic ? Preset.PublicChat : Preset.PrivateChat,
|
||||||
|
@ -523,7 +523,7 @@ const SpaceSetupFirstRooms = ({ space, title, description, onFinished }) => {
|
||||||
suggested: true,
|
suggested: true,
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
onFinished(filteredRoomNames.length > 0);
|
onFinished(roomIds[0]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to create initial space rooms", e);
|
console.error("Failed to create initial space rooms", e);
|
||||||
setError(_t("Failed to create initial space rooms"));
|
setError(_t("Failed to create initial space rooms"));
|
||||||
|
@ -533,7 +533,7 @@ const SpaceSetupFirstRooms = ({ space, title, description, onFinished }) => {
|
||||||
|
|
||||||
let onClick = (ev) => {
|
let onClick = (ev) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
onFinished(false);
|
onFinished();
|
||||||
};
|
};
|
||||||
let buttonLabel = _t("Skip for now");
|
let buttonLabel = _t("Skip for now");
|
||||||
if (roomNames.some(name => name.trim())) {
|
if (roomNames.some(name => name.trim())) {
|
||||||
|
@ -588,7 +588,7 @@ const SpaceAddExistingRooms = ({ space, onFinished }) => {
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SpaceSetupPublicShare = ({ justCreatedOpts, space, onFinished, createdRooms }) => {
|
const SpaceSetupPublicShare = ({ justCreatedOpts, space, onFinished, firstRoomId }) => {
|
||||||
return <div className="mx_SpaceRoomView_publicShare">
|
return <div className="mx_SpaceRoomView_publicShare">
|
||||||
<h1>{ _t("Share %(name)s", {
|
<h1>{ _t("Share %(name)s", {
|
||||||
name: justCreatedOpts?.createOpts?.name || space.name,
|
name: justCreatedOpts?.createOpts?.name || space.name,
|
||||||
|
@ -601,7 +601,7 @@ const SpaceSetupPublicShare = ({ justCreatedOpts, space, onFinished, createdRoom
|
||||||
|
|
||||||
<div className="mx_SpaceRoomView_buttons">
|
<div className="mx_SpaceRoomView_buttons">
|
||||||
<AccessibleButton kind="primary" onClick={onFinished}>
|
<AccessibleButton kind="primary" onClick={onFinished}>
|
||||||
{ createdRooms ? _t("Go to my first room") : _t("Go to my space") }
|
{ firstRoomId ? _t("Go to my first room") : _t("Go to my space") }
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
|
@ -844,35 +844,10 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private goToFirstRoom = async () => {
|
private goToFirstRoom = async () => {
|
||||||
// TODO actually go to the first room
|
if (this.state.firstRoomId) {
|
||||||
|
|
||||||
const childRooms = SpaceStore.instance.getChildRooms(this.props.space.roomId);
|
|
||||||
if (childRooms.length) {
|
|
||||||
const room = childRooms[0];
|
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: "view_room",
|
||||||
room_id: room.roomId,
|
room_id: this.state.firstRoomId,
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let suggestedRooms = SpaceStore.instance.suggestedRooms;
|
|
||||||
if (SpaceStore.instance.activeSpace !== this.props.space) {
|
|
||||||
// the space store has the suggested rooms loaded for a different space, fetch the right ones
|
|
||||||
suggestedRooms = (await SpaceStore.instance.fetchSuggestedRooms(this.props.space, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (suggestedRooms.length) {
|
|
||||||
const room = suggestedRooms[0];
|
|
||||||
defaultDispatcher.dispatch({
|
|
||||||
action: "view_room",
|
|
||||||
room_id: room.room_id,
|
|
||||||
room_alias: room.canonical_alias || room.aliases?.[0],
|
|
||||||
via_servers: room.viaServers,
|
|
||||||
oobData: {
|
|
||||||
avatarUrl: room.avatar_url,
|
|
||||||
name: room.name || room.canonical_alias || room.aliases?.[0] || _t("Empty room"),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -902,14 +877,14 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
|
||||||
_t("Let's create a room for each of them.") + "\n" +
|
_t("Let's create a room for each of them.") + "\n" +
|
||||||
_t("You can add more later too, including already existing ones.")
|
_t("You can add more later too, including already existing ones.")
|
||||||
}
|
}
|
||||||
onFinished={(createdRooms: boolean) => this.setState({ phase: Phase.PublicShare, createdRooms })}
|
onFinished={(firstRoomId: boolean) => this.setState({ phase: Phase.PublicShare, firstRoomId })}
|
||||||
/>;
|
/>;
|
||||||
case Phase.PublicShare:
|
case Phase.PublicShare:
|
||||||
return <SpaceSetupPublicShare
|
return <SpaceSetupPublicShare
|
||||||
justCreatedOpts={this.props.justCreatedOpts}
|
justCreatedOpts={this.props.justCreatedOpts}
|
||||||
space={this.props.space}
|
space={this.props.space}
|
||||||
onFinished={this.goToFirstRoom}
|
onFinished={this.goToFirstRoom}
|
||||||
createdRooms={this.state.createdRooms}
|
firstRoomId={this.state.firstRoomId}
|
||||||
/>;
|
/>;
|
||||||
|
|
||||||
case Phase.PrivateScope:
|
case Phase.PrivateScope:
|
||||||
|
@ -931,7 +906,7 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
|
||||||
title={_t("What projects are you working on?")}
|
title={_t("What projects are you working on?")}
|
||||||
description={_t("We'll create rooms for each of them. " +
|
description={_t("We'll create rooms for each of them. " +
|
||||||
"You can add more later too, including already existing ones.")}
|
"You can add more later too, including already existing ones.")}
|
||||||
onFinished={(createdRooms: boolean) => this.setState({ phase: Phase.Landing, createdRooms })}
|
onFinished={(firstRoomId: boolean) => this.setState({ phase: Phase.Landing, firstRoomId })}
|
||||||
/>;
|
/>;
|
||||||
case Phase.PrivateExistingRooms:
|
case Phase.PrivateExistingRooms:
|
||||||
return <SpaceAddExistingRooms
|
return <SpaceAddExistingRooms
|
||||||
|
|
Loading…
Reference in New Issue