Skip to content

Commit 207614f

Browse files
humanagentrygine
andauthored
Dm deeplink (#800)
* dm deeplink * deeplink * Re-org dev tool app * Re-org error modal * Re-org redirects * Refactor navbar state * Fix redirects * Add LoadingMessage component * Adjust no convos message styling * Add messages to load DM route * Remove build artifact * Fix type * deeplink --------- Co-authored-by: Ry Racherbaumer <ry@xmtp.com>
1 parent 1302099 commit 207614f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+480
-263
lines changed

apps/xmtp.chat/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"postcss-simple-vars": "^7.0.1",
4949
"tsconfig": "workspace:*",
5050
"typescript": "^5.7.3",
51-
"vite": "^6.0.7"
51+
"vite": "^6.0.7",
52+
"vite-tsconfig-paths": "npm:^5.1.4"
5253
}
5354
}

apps/xmtp.chat/src/components/AddressBadge.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Badge, Flex, Text, Tooltip } from "@mantine/core";
22
import { useClipboard } from "@mantine/hooks";
3-
import { shortAddress } from "../helpers/address";
3+
import { shortAddress } from "@/helpers/address";
44

55
export type AddressTooltipLabelProps = {
66
address: string;

apps/xmtp.chat/src/components/App.tsx

-140
This file was deleted.

apps/xmtp.chat/src/components/Actions.tsx apps/xmtp.chat/src/components/App/Actions.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Button, Flex, useMatches } from "@mantine/core";
22
import { useEffect, useRef } from "react";
33
import { useNavigate } from "react-router";
4-
import { useClient } from "../hooks/useClient";
5-
import { IconMessagePlus } from "../icons/IconMessagePlus";
6-
import { useRefManager } from "./RefManager";
4+
import { useRefManager } from "@/contexts/RefManager";
5+
import { useClient } from "@/hooks/useClient";
6+
import { IconMessagePlus } from "@/icons/IconMessagePlus";
77

88
export const Actions: React.FC = () => {
99
const { client } = useClient();
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { AppShell } from "@mantine/core";
2+
import { useDisclosure } from "@mantine/hooks";
3+
import { AppFooter } from "@/components/App/AppFooter";
4+
import { AppHeader } from "@/components/App/AppHeader";
5+
import { ErrorModal } from "@/components/App/ErrorModal";
6+
import { useAppState } from "@/contexts/AppState";
7+
import { useAnalytics } from "@/hooks/useAnalytics";
8+
import { useRedirects } from "@/hooks/useRedirects";
9+
import { Main } from "@/routes/Main";
10+
import { Navbar } from "@/routes/Navbar";
11+
import classes from "./App.module.css";
12+
13+
export const App: React.FC = () => {
14+
useRedirects();
15+
useAnalytics();
16+
const [opened, { toggle }] = useDisclosure();
17+
const { navbar } = useAppState();
18+
19+
return (
20+
<>
21+
<ErrorModal />
22+
<AppShell
23+
header={{ height: 68 }}
24+
footer={{
25+
height: 64,
26+
}}
27+
navbar={{
28+
width: { base: 300, lg: 420 },
29+
breakpoint: "sm",
30+
collapsed: { desktop: !navbar, mobile: !opened },
31+
}}
32+
padding="md">
33+
<AppShell.Header>
34+
<AppHeader opened={opened} toggle={toggle} collapsed={!navbar} />
35+
</AppShell.Header>
36+
<AppShell.Navbar className={classes.navbar}>
37+
<Navbar />
38+
</AppShell.Navbar>
39+
<AppShell.Main className={classes.main}>
40+
<Main />
41+
</AppShell.Main>
42+
<AppShell.Footer display="flex" className={classes.footer}>
43+
<AppFooter />
44+
</AppShell.Footer>
45+
</AppShell>
46+
</>
47+
);
48+
};

apps/xmtp.chat/src/components/AppFooter.tsx apps/xmtp.chat/src/components/App/AppFooter.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Anchor, Box, Flex, Group, Image, Text } from "@mantine/core";
2-
import logo from "../assets/xmtp-icon.png";
2+
import logo from "@/assets/xmtp-icon.png";
33

44
export const AppFooter: React.FC = () => {
55
return (

apps/xmtp.chat/src/components/AppHeader.tsx apps/xmtp.chat/src/components/App/AppHeader.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Burger, Button, Flex } from "@mantine/core";
22
import { useNavigate } from "react-router";
3-
import { shortAddress } from "../helpers/address";
4-
import { useClient } from "../hooks/useClient";
3+
import { shortAddress } from "@/helpers/address";
4+
import { useClient } from "@/hooks/useClient";
55
import { Actions } from "./Actions";
66
import classes from "./AppHeader.module.css";
77
import { Connection } from "./Connection";

apps/xmtp.chat/src/components/Connection.tsx apps/xmtp.chat/src/components/App/Connection.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import { type Hex } from "viem";
77
import { generatePrivateKey } from "viem/accounts";
88
import { useConnect, useDisconnect, useWalletClient } from "wagmi";
99
import { injected } from "wagmi/connectors";
10-
import { createEphemeralSigner, createSigner } from "../helpers/createSigner";
11-
import { useClient } from "../hooks/useClient";
12-
import { IconLogout } from "../icons/IconLogout";
13-
import { IconUser } from "../icons/IconUser";
14-
import { useRefManager } from "./RefManager";
15-
import { Settings } from "./Settings";
10+
import { Settings } from "@/components/Settings/Settings";
11+
import { useRefManager } from "@/contexts/RefManager";
12+
import { createEphemeralSigner, createSigner } from "@/helpers/createSigner";
13+
import { useClient } from "@/hooks/useClient";
14+
import { IconLogout } from "@/icons/IconLogout";
15+
import { IconUser } from "@/icons/IconUser";
1616

1717
export const Disconnect: React.FC = () => {
1818
const { disconnect } = useDisconnect();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { Button, Group, Modal, ScrollArea, Stack, Title } from "@mantine/core";
2+
import { useEffect, useState } from "react";
3+
import { CodeWithCopy } from "@/components/CodeWithCopy";
4+
5+
export const ErrorModal: React.FC = () => {
6+
const [unhandledRejectionError, setUnhandledRejectionError] = useState<
7+
string | null
8+
>(null);
9+
10+
useEffect(() => {
11+
const handleUnhandledRejection = (event: PromiseRejectionEvent) => {
12+
setUnhandledRejectionError(
13+
(event.reason as Error).message || "Unknown error",
14+
);
15+
};
16+
window.addEventListener("unhandledrejection", handleUnhandledRejection);
17+
return () => {
18+
window.removeEventListener(
19+
"unhandledrejection",
20+
handleUnhandledRejection,
21+
);
22+
};
23+
}, []);
24+
25+
return unhandledRejectionError ? (
26+
<Modal
27+
opened={!!unhandledRejectionError}
28+
onClose={() => {
29+
setUnhandledRejectionError(null);
30+
}}
31+
withCloseButton={false}
32+
centered>
33+
<Stack gap="md">
34+
<Title order={4}>Application error</Title>
35+
<ScrollArea>
36+
<CodeWithCopy
37+
code={JSON.stringify(unhandledRejectionError, null, 2)}
38+
/>
39+
</ScrollArea>
40+
<Group justify="space-between">
41+
<Button
42+
variant="default"
43+
component="a"
44+
href="https://github.com/xmtp/xmtp-js/issues/new/choose"
45+
target="_blank">
46+
Report issue
47+
</Button>
48+
<Button
49+
onClick={() => {
50+
setUnhandledRejectionError(null);
51+
}}>
52+
OK
53+
</Button>
54+
</Group>
55+
</Stack>
56+
</Modal>
57+
) : null;
58+
};

apps/xmtp.chat/src/components/SelectConversation.tsx apps/xmtp.chat/src/components/App/SelectConversation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Button, Stack, Text, Title, useMatches } from "@mantine/core";
2-
import { useRefManager } from "./RefManager";
2+
import { useRefManager } from "@/contexts/RefManager";
33

44
export const SelectConversation = () => {
55
const { getRef } = useRefManager();

apps/xmtp.chat/src/components/Welcome.tsx apps/xmtp.chat/src/components/App/Welcome.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ import {
1010
} from "@mantine/core";
1111
import { useLocalStorage } from "@mantine/hooks";
1212
import type { XmtpEnv } from "@xmtp/browser-sdk";
13-
import { useRefManager } from "./RefManager";
13+
import { useEffect } from "react";
14+
import { useAppState } from "@/contexts/AppState";
15+
import { useRefManager } from "@/contexts/RefManager";
1416

1517
export const Welcome = () => {
18+
const { setNavbar } = useAppState();
19+
useEffect(() => {
20+
setNavbar(false);
21+
}, []);
22+
1623
const { getRef } = useRefManager();
1724
const [network] = useLocalStorage<XmtpEnv>({
1825
key: "XMTP_NETWORK",

apps/xmtp.chat/src/components/BadgeWithCopy.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Badge, Button, Text, Tooltip } from "@mantine/core";
22
import { useClipboard } from "@mantine/hooks";
3-
import { IconCopy } from "../icons/IconCopy";
3+
import { IconCopy } from "@/icons/IconCopy";
44
import classes from "./BadgeWithCopy.module.css";
55

66
type CopyIconProps = {

apps/xmtp.chat/src/components/Composer.tsx apps/xmtp.chat/src/components/Conversation/Composer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Button, Flex, TextInput } from "@mantine/core";
22
import type { Conversation } from "@xmtp/browser-sdk";
33
import { useState } from "react";
4-
import { useConversation } from "../hooks/useConversation";
4+
import { useConversation } from "@/hooks/useConversation";
55

66
export type ComposerProps = {
77
conversation: Conversation;

apps/xmtp.chat/src/components/Conversation.tsx apps/xmtp.chat/src/components/Conversation/Conversation.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ import {
1111
import type { Conversation as XmtpConversation } from "@xmtp/browser-sdk";
1212
import { useEffect } from "react";
1313
import { Link, Outlet } from "react-router";
14-
import { useBodyClass } from "../hooks/useBodyClass";
15-
import { useConversation } from "../hooks/useConversation";
14+
import { Messages } from "@/components/Messages/Messages";
15+
import { useBodyClass } from "@/hooks/useBodyClass";
16+
import { useConversation } from "@/hooks/useConversation";
1617
import { Composer } from "./Composer";
17-
import { Messages } from "./Messages";
18-
import classes from "./ScrollFade.module.css";
1918

2019
export type ConversationProps = {
2120
conversation?: XmtpConversation;
@@ -88,7 +87,7 @@ export const Conversation: React.FC<ConversationProps> = ({
8887
{messages.length === 0 && <Text>No messages</Text>}
8988
</Stack>
9089
) : (
91-
<ScrollArea type="scroll" className={classes.root}>
90+
<ScrollArea type="scroll" className="scrollfade">
9291
<Messages messages={messages} />
9392
</ScrollArea>
9493
)}

apps/xmtp.chat/src/components/LoadConversation.tsx apps/xmtp.chat/src/components/Conversation/LoadConversation.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Conversation as XmtpConversation } from "@xmtp/browser-sdk";
22
import { useEffect, useState } from "react";
33
import { useParams } from "react-router";
4-
import { useBodyClass } from "../hooks/useBodyClass";
5-
import { useConversations } from "../hooks/useConversations";
4+
import { useBodyClass } from "@/hooks/useBodyClass";
5+
import { useConversations } from "@/hooks/useConversations";
66
import { Conversation } from "./Conversation";
77

88
export const LoadConversation: React.FC = () => {

0 commit comments

Comments
 (0)