Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dm deeplink #800

Merged
merged 13 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/xmtp.chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"postcss-simple-vars": "^7.0.1",
"tsconfig": "workspace:*",
"typescript": "^5.7.3",
"vite": "^6.0.7"
"vite": "^6.0.7",
"vite-tsconfig-paths": "npm:^5.1.4"
}
}
2 changes: 1 addition & 1 deletion apps/xmtp.chat/src/components/AddressBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Badge, Flex, Text, Tooltip } from "@mantine/core";
import { useClipboard } from "@mantine/hooks";
import { shortAddress } from "../helpers/address";
import { shortAddress } from "@/helpers/address";

export type AddressTooltipLabelProps = {
address: string;
Expand Down
140 changes: 0 additions & 140 deletions apps/xmtp.chat/src/components/App.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Button, Flex, useMatches } from "@mantine/core";
import { useEffect, useRef } from "react";
import { useNavigate } from "react-router";
import { useClient } from "../hooks/useClient";
import { IconMessagePlus } from "../icons/IconMessagePlus";
import { useRefManager } from "./RefManager";
import { useRefManager } from "@/contexts/RefManager";
import { useClient } from "@/hooks/useClient";
import { IconMessagePlus } from "@/icons/IconMessagePlus";

export const Actions: React.FC = () => {
const { client } = useClient();
Expand Down
48 changes: 48 additions & 0 deletions apps/xmtp.chat/src/components/App/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { AppShell } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { AppFooter } from "@/components/App/AppFooter";
import { AppHeader } from "@/components/App/AppHeader";
import { ErrorModal } from "@/components/App/ErrorModal";
import { useAppState } from "@/contexts/AppState";
import { useAnalytics } from "@/hooks/useAnalytics";
import { useRedirects } from "@/hooks/useRedirects";
import { Main } from "@/routes/Main";
import { Navbar } from "@/routes/Navbar";
import classes from "./App.module.css";

export const App: React.FC = () => {
useRedirects();
useAnalytics();
const [opened, { toggle }] = useDisclosure();
const { navbar } = useAppState();

return (
<>
<ErrorModal />
<AppShell
header={{ height: 68 }}
footer={{
height: 64,
}}
navbar={{
width: { base: 300, lg: 420 },
breakpoint: "sm",
collapsed: { desktop: !navbar, mobile: !opened },
}}
padding="md">
<AppShell.Header>
<AppHeader opened={opened} toggle={toggle} collapsed={!navbar} />
</AppShell.Header>
<AppShell.Navbar className={classes.navbar}>
<Navbar />
</AppShell.Navbar>
<AppShell.Main className={classes.main}>
<Main />
</AppShell.Main>
<AppShell.Footer display="flex" className={classes.footer}>
<AppFooter />
</AppShell.Footer>
</AppShell>
</>
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Anchor, Box, Flex, Group, Image, Text } from "@mantine/core";
import logo from "../assets/xmtp-icon.png";
import logo from "@/assets/xmtp-icon.png";

export const AppFooter: React.FC = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Burger, Button, Flex } from "@mantine/core";
import { useNavigate } from "react-router";
import { shortAddress } from "../helpers/address";
import { useClient } from "../hooks/useClient";
import { shortAddress } from "@/helpers/address";
import { useClient } from "@/hooks/useClient";
import { Actions } from "./Actions";
import classes from "./AppHeader.module.css";
import { Connection } from "./Connection";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { type Hex } from "viem";
import { generatePrivateKey } from "viem/accounts";
import { useConnect, useDisconnect, useWalletClient } from "wagmi";
import { injected } from "wagmi/connectors";
import { createEphemeralSigner, createSigner } from "../helpers/createSigner";
import { useClient } from "../hooks/useClient";
import { IconLogout } from "../icons/IconLogout";
import { IconUser } from "../icons/IconUser";
import { useRefManager } from "./RefManager";
import { Settings } from "./Settings";
import { Settings } from "@/components/Settings/Settings";
import { useRefManager } from "@/contexts/RefManager";
import { createEphemeralSigner, createSigner } from "@/helpers/createSigner";
import { useClient } from "@/hooks/useClient";
import { IconLogout } from "@/icons/IconLogout";
import { IconUser } from "@/icons/IconUser";

export const Disconnect: React.FC = () => {
const { disconnect } = useDisconnect();
Expand Down
58 changes: 58 additions & 0 deletions apps/xmtp.chat/src/components/App/ErrorModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Button, Group, Modal, ScrollArea, Stack, Title } from "@mantine/core";
import { useEffect, useState } from "react";
import { CodeWithCopy } from "@/components/CodeWithCopy";

export const ErrorModal: React.FC = () => {
const [unhandledRejectionError, setUnhandledRejectionError] = useState<
string | null
>(null);

useEffect(() => {
const handleUnhandledRejection = (event: PromiseRejectionEvent) => {
setUnhandledRejectionError(
(event.reason as Error).message || "Unknown error",
);
};
window.addEventListener("unhandledrejection", handleUnhandledRejection);
return () => {
window.removeEventListener(
"unhandledrejection",
handleUnhandledRejection,
);
};
}, []);

return unhandledRejectionError ? (
<Modal
opened={!!unhandledRejectionError}
onClose={() => {
setUnhandledRejectionError(null);
}}
withCloseButton={false}
centered>
<Stack gap="md">
<Title order={4}>Application error</Title>
<ScrollArea>
<CodeWithCopy
code={JSON.stringify(unhandledRejectionError, null, 2)}
/>
</ScrollArea>
<Group justify="space-between">
<Button
variant="default"
component="a"
href="https://github.com/xmtp/xmtp-js/issues/new/choose"
target="_blank">
Report issue
</Button>
<Button
onClick={() => {
setUnhandledRejectionError(null);
}}>
OK
</Button>
</Group>
</Stack>
</Modal>
) : null;
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Stack, Text, Title, useMatches } from "@mantine/core";
import { useRefManager } from "./RefManager";
import { useRefManager } from "@/contexts/RefManager";

export const SelectConversation = () => {
const { getRef } = useRefManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ import {
} from "@mantine/core";
import { useLocalStorage } from "@mantine/hooks";
import type { XmtpEnv } from "@xmtp/browser-sdk";
import { useRefManager } from "./RefManager";
import { useEffect } from "react";
import { useAppState } from "@/contexts/AppState";
import { useRefManager } from "@/contexts/RefManager";

export const Welcome = () => {
const { setNavbar } = useAppState();
useEffect(() => {
setNavbar(false);
}, []);

const { getRef } = useRefManager();
const [network] = useLocalStorage<XmtpEnv>({
key: "XMTP_NETWORK",
Expand Down
2 changes: 1 addition & 1 deletion apps/xmtp.chat/src/components/BadgeWithCopy.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Badge, Button, Text, Tooltip } from "@mantine/core";
import { useClipboard } from "@mantine/hooks";
import { IconCopy } from "../icons/IconCopy";
import { IconCopy } from "@/icons/IconCopy";
import classes from "./BadgeWithCopy.module.css";

type CopyIconProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Flex, TextInput } from "@mantine/core";
import type { Conversation } from "@xmtp/browser-sdk";
import { useState } from "react";
import { useConversation } from "../hooks/useConversation";
import { useConversation } from "@/hooks/useConversation";

export type ComposerProps = {
conversation: Conversation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import {
import type { Conversation as XmtpConversation } from "@xmtp/browser-sdk";
import { useEffect } from "react";
import { Link, Outlet } from "react-router";
import { useBodyClass } from "../hooks/useBodyClass";
import { useConversation } from "../hooks/useConversation";
import { Messages } from "@/components/Messages/Messages";
import { useBodyClass } from "@/hooks/useBodyClass";
import { useConversation } from "@/hooks/useConversation";
import { Composer } from "./Composer";
import { Messages } from "./Messages";
import classes from "./ScrollFade.module.css";

export type ConversationProps = {
conversation?: XmtpConversation;
Expand Down Expand Up @@ -88,7 +87,7 @@ export const Conversation: React.FC<ConversationProps> = ({
{messages.length === 0 && <Text>No messages</Text>}
</Stack>
) : (
<ScrollArea type="scroll" className={classes.root}>
<ScrollArea type="scroll" className="scrollfade">
<Messages messages={messages} />
</ScrollArea>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Conversation as XmtpConversation } from "@xmtp/browser-sdk";
import { useEffect, useState } from "react";
import { useParams } from "react-router";
import { useBodyClass } from "../hooks/useBodyClass";
import { useConversations } from "../hooks/useConversations";
import { useBodyClass } from "@/hooks/useBodyClass";
import { useConversations } from "@/hooks/useConversations";
import { Conversation } from "./Conversation";

export const LoadConversation: React.FC = () => {
Expand Down
Loading
Loading