JoinGroup: redirect if we have the group

Joining a group we have fails. We now redirect to the workspace.

Fixes urbit/landscape#683
This commit is contained in:
Matilde Park 2021-04-13 14:12:10 -04:00
parent 1ae61a0715
commit 3245465281

View File

@ -81,6 +81,9 @@ export function JoinGroup(props: JoinGroupProps): ReactElement {
if(group === TUTORIAL_GROUP_RESOURCE) { if(group === TUTORIAL_GROUP_RESOURCE) {
await api.settings.putEntry('tutorial', 'joined', Date.now()); await api.settings.putEntry('tutorial', 'joined', Date.now());
} }
if (group in groups) {
return history.push(`/~landscape${group}`);
}
await api.groups.join(ship, name); await api.groups.join(ship, name);
try { try {
await waiter((p) => { await waiter((p) => {
@ -111,6 +114,9 @@ export function JoinGroup(props: JoinGroupProps): ReactElement {
async (values: FormSchema, actions: FormikHelpers<FormSchema>) => { async (values: FormSchema, actions: FormikHelpers<FormSchema>) => {
const [ship, name] = values.group.split('/'); const [ship, name] = values.group.split('/');
const path = `/ship/${ship}/${name}`; const path = `/ship/${ship}/${name}`;
if (path in groups) {
return history.push(`/~landscape${path}`);
}
// skip if it's unmanaged // skip if it's unmanaged
try { try {
const prev = await api.metadata.preview(path); const prev = await api.metadata.preview(path);