interface: do not redirect to joined group automatically

This commit is contained in:
Liam Fitzgerald 2021-12-07 11:04:36 -05:00
parent 119805fd04
commit ba9cfd8e92
3 changed files with 30 additions and 13 deletions

View File

@ -83,7 +83,7 @@ export const LaunchApp = (props: LaunchAppProps): ReactElement | null => {
<Tiles />
<ModalButton
icon="Plus"
bg="washedGray"
bg="white"
color="black"
text="New Group"
style={{ gridColumnStart: 1 }}
@ -91,14 +91,12 @@ export const LaunchApp = (props: LaunchAppProps): ReactElement | null => {
<NewGroup />
</ModalButton>
<Button
backgroundColor="washedGray"
color="black"
border={0}
p={0}
borderRadius={2}
onClick={() => history.push({ search: "?join-kind=group" })}
>
<Row gapX="2" p={2} height="100%" width="100%" alignItems="center">
<Row backgroundColor="white" gapX="2" p={2} height="100%" width="100%" alignItems="center">
<Icon icon="BootNode" />
<Text fontWeight="medium" whiteSpace="nowrap">Join Group</Text>
</Row>

View File

@ -48,10 +48,10 @@ function JoinForm(props: {
);
};
const onDecline = () => {
const onDecline = () => {
airlock.poke(decline(desc.kind, invite.uid));
dismiss();
}
};
const isGroups = desc.kind === "groups";
return (
@ -117,7 +117,7 @@ function JoinLoading(props: {
const { desc, request, dismiss, modal, finished } = props;
const history = useHistory();
useEffect(() => {
if (request.progress === "done") {
if (desc.kind === "graph" && request.progress === "done") {
history.push(finished);
}
}, [request]);
@ -205,13 +205,18 @@ export function Join(props: JoinProps) {
joinRequest && joinLoad.includes(joinRequest.progress as any);
useEffect(() => {
if (isDone) {
if (isDone && desc.kind == "graph") {
history.push(finishedPath);
}
}, [isDone, desc]);
return isDone ? (
<JoinDone modal={modal} desc={desc} />
<JoinDone
dismiss={dismiss}
modal={modal}
desc={desc}
finished={finishedPath}
/>
) : isLoading ? (
<JoinLoading
modal={modal}
@ -312,21 +317,30 @@ function JoinProgressIndicator(props: { progress: JoinProgress }) {
export interface JoinDoneProps {
desc: JoinDesc;
modal: boolean;
finished: string;
dismiss: () => void;
}
export function JoinDone(props: JoinDoneProps) {
const { desc, modal } = props;
const { desc, modal, finished, dismiss } = props;
const { preview, error } = usePreview(desc.group);
const name = desc.kind === "groups" ? "Group" : "Group Chat";
const title = `Joined ${name} successfully`;
const history = useHistory();
const onView = () => {
history.push(finished);
};
return (
<JoinSkeleton title={title} modal={modal} desc={desc}>
<Col p="4" gapY="4">
<JoinProgressIndicator progress="done" />
<Row gapX="2">
<Button>Dismiss</Button>
<Button primary>View Group</Button>
<Button onClick={dismiss}>Dismiss</Button>
<Button onClick={onView} primary>
View Group
</Button>
</Row>
</Col>
</JoinSkeleton>

View File

@ -17,6 +17,7 @@ import { resourceFromPath } from "~/logic/lib/group";
import useMetadataState, { usePreview } from "~/logic/state/metadata";
import useInviteState, { useInviteForResource } from "~/logic/state/invite";
import {useHistory} from "react-router-dom";
const SUMMARY_HEIGHT = "96px";
@ -38,6 +39,10 @@ interface JoinSkeletonProps {
export function JoinSkeleton(props: JoinSkeletonProps) {
const { title, body, children, onJoin, desc, modal } = props;
const history = useHistory();
const dismiss = () => {
history.push({ search: '' });
};
const inner = (
<Col
@ -64,7 +69,7 @@ export function JoinSkeleton(props: JoinSkeletonProps) {
</Col>
);
return modal ? (
<ModalOverlay dismiss={() => {}}>{inner}</ModalOverlay>
<ModalOverlay dismiss={dismiss}>{inner}</ModalOverlay>
) : (
inner
);