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

feat: Remove XMTP DB drop and clean XMTP stuff #1550

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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: 0 additions & 3 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { QueryClientProvider } from "@tanstack/react-query";
import { useReactQueryDevTools } from "@dev-plugins/react-query";

import { useAppTheme, useThemeProvider } from "@theme/useAppTheme";

Check warning on line 18 in App.tsx

View workflow job for this annotation

GitHub Actions / lint

'useAppTheme' is defined but never used
import { useCoinbaseWalletListener } from "@utils/coinbaseWallet";
import { converseEventEmitter } from "@utils/events";
import logger from "@utils/logger";
Expand All @@ -33,7 +33,6 @@
import { ThirdwebProvider } from "thirdweb/react";

import { Snackbars } from "@components/Snackbar/Snackbars";
import { xmtpEngine } from "./components/XmtpEngine";
import config from "./config";
import {
TEMPORARY_ACCOUNT_NAME,
Expand Down Expand Up @@ -81,8 +80,6 @@

const coinbaseUrl = new URL(`https://${config.websiteDomain}/coinbase`);

xmtpEngine.start();

const App = () => {
const styles = useStyles();
const debugRef = useRef();
Expand All @@ -98,10 +95,10 @@
}, []);

const showDebugMenu = useCallback(() => {
if (!debugRef.current || !(debugRef.current as any).showDebugMenu) {

Check warning on line 98 in App.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return;
}
(debugRef.current as any).showDebugMenu();

Check warning on line 101 in App.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
}, []);

useEffect(() => {
Expand Down Expand Up @@ -145,7 +142,7 @@
const AppKeyboardProvider =
Platform.OS === "ios" ? KeyboardProvider : React.Fragment;

export default function AppWithProviders() {

Check warning on line 145 in App.tsx

View workflow job for this annotation

GitHub Actions / lint

Prefer named exports
const colorScheme = useColorScheme();

const paperTheme = useMemo(() => {
Expand All @@ -165,7 +162,7 @@
<ActionSheetProvider>
<ThemeProvider value={{ themeScheme, setThemeContextOverride }}>
<PaperProvider theme={paperTheme}>
<GestureHandlerRootView style={{ flex: 1 }}>

Check warning on line 165 in App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { flex: 1 }
<BottomSheetModalProvider>
<App />
<Snackbars />
Expand Down
149 changes: 0 additions & 149 deletions components/XmtpEngine.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion containers/GroupScreenConsentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import TableView, {
TableViewItemType,
} from "../components/TableView/TableView";
import type { ConversationTopic } from "@xmtp/react-native-sdk";
import { GroupWithCodecsType } from "@/utils/xmtpRN/client.types";
import { GroupWithCodecsType } from "@/utils/xmtpRN/client/client.types";

type GroupScreenConsentTableProps = {
topic: ConversationTopic;
Expand Down
6 changes: 4 additions & 2 deletions containers/GroupScreenMembersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { IProfileSocials } from "@/features/profiles/profile-types";
import { useInboxProfilesSocials } from "@/hooks/useInboxProfilesSocials";
import { useGroupMembersConversationScreenQuery } from "@/queries/useGroupMembersQuery";
import { captureErrorWithFriendlyToast } from "@/utils/capture-error";
import { GroupWithCodecsType } from "@/utils/xmtpRN/client.types";
import { GroupWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { useGroupPermissionPolicyQuery } from "@queries/useGroupPermissionPolicyQuery";
import type { ConversationTopic, InboxId } from "@xmtp/react-native-sdk";
import TableView, {
Expand Down Expand Up @@ -98,7 +98,9 @@ export const GroupScreenMembersTable: FC<GroupScreenMembersTableProps> = memo(
const preferredName = getPreferredInboxName(mappedData[a.inboxId]);
items.push({
id: a.inboxId,
title: `${preferredName}${isCurrentUser ? translate("you_parentheses") : ""}`,
title: `${preferredName}${
isCurrentUser ? translate("you_parentheses") : ""
}`,
action: () => {
const {
options,
Expand Down
6 changes: 0 additions & 6 deletions data/store/chatStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import { create } from "zustand";
import { createJSONStorage, persist } from "zustand/middleware";

export type ChatStoreType = {
reconnecting: boolean;
setReconnecting: (reconnecting: boolean) => void;

groupInviteLinks: {
[topic: string]: string;
};
Expand All @@ -17,9 +14,6 @@ export const initChatStore = (account: string) => {
return create<ChatStoreType>()(
persist(
(set) => ({
reconnecting: false,
setReconnecting: (reconnecting) => set(() => ({ reconnecting })),

groupInviteLinks: {},
setGroupInviteLink(topic, inviteLink) {
set((state) => {
Expand Down
2 changes: 1 addition & 1 deletion features/GroupInvites/joinGroup/JoinGroup.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
GroupData,
GroupsDataEntity,
GroupWithCodecsType,
} from "@utils/xmtpRN/client.types";
} from "@/utils/xmtpRN/client/client.types";
import {
Conversation,
ConversationId,
Expand Down
2 changes: 1 addition & 1 deletion features/GroupInvites/joinGroup/joinGroup.machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GroupInvite } from "@/utils/api/api-groups/api-group.types";
import {
ConversationDataEntity,
ConversationWithCodecsType,
} from "@utils/xmtpRN/client.types";
} from "@/utils/xmtpRN/client/client.types";
import { assign, fromPromise, log, setup } from "xstate";

import { AllowGroupProps } from "./JoinGroup.client";
Expand Down
2 changes: 1 addition & 1 deletion features/consent/account-can-message-peer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logger from "@utils/logger";
import { ConverseXmtpClientType } from "@/utils/xmtpRN/client.types";
import { ConverseXmtpClientType } from "@/utils/xmtpRN/client/client.types";
import { getXmtpClient } from "@/utils/xmtpRN/sync";

type AccountCanMessagePeerArgs = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConverseXmtpClientType } from "@/utils/xmtpRN/client.types";
import { ConverseXmtpClientType } from "@/utils/xmtpRN/client/client.types";
import { getXmtpClient } from "@/utils/xmtpRN/sync";
import logger from "@utils/logger";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logger from "@utils/logger";
import { ConverseXmtpClientType } from "@/utils/xmtpRN/client.types";
import { ConverseXmtpClientType } from "@/utils/xmtpRN/client/client.types";
import { getXmtpClient } from "@/utils/xmtpRN/sync";

type UpdateConsentForGroupsForAccountArgs = {
Expand Down
2 changes: 1 addition & 1 deletion features/consent/update-inbox-ids-consent-for-account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConverseXmtpClientType } from "@/utils/xmtpRN/client.types";
import { ConverseXmtpClientType } from "@/utils/xmtpRN/client/client.types";
import { getXmtpClient } from "@/utils/xmtpRN/sync";
import logger from "@utils/logger";
import { InboxId } from "@xmtp/react-native-sdk";
Expand Down
2 changes: 1 addition & 1 deletion features/consent/use-allow-group.mutation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { updateConversationInConversationsQueryData } from "@/queries/conversations-query";
import { captureError } from "@/utils/capture-error";
import { GroupWithCodecsType } from "@/utils/xmtpRN/client.types";
import { GroupWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { queryClient } from "@queries/queryClient";
import {
MutationObserver,
Expand Down
2 changes: 1 addition & 1 deletion features/consent/use-dm-consent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { updateConversationInConversationsQueryData } from "@/queries/conversati
import { getConversationQueryData } from "@/queries/useConversationQuery";
import { getDmQueryData, setDmQueryData } from "@/queries/useDmQuery";
import { updateObjectAndMethods } from "@/utils/update-object-and-methods";
import { DmWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DmWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { useMutation } from "@tanstack/react-query";
import {
ConversationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useConversationQuery } from "@/queries/useConversationQuery";
import { useDmPeerInboxId } from "@/queries/useDmPeerInbox";
import { useAppTheme } from "@/theme/useAppTheme";
import { captureErrorWithToast } from "@/utils/capture-error";
import { DmWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DmWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { useCurrentAccount } from "@data/store/accountsStore";
import { usePreferredInboxAvatar } from "@hooks/usePreferredInboxAvatar";
import { usePreferredInboxName } from "@hooks/usePreferredInboxName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PinnedConversationAvatar } from "@/features/conversation-list/conversat
import { useConversationIsUnread } from "@/features/conversation-list/hooks/use-conversation-is-unread";
import { useConversationContextMenuViewDefaultProps } from "@/features/conversation-list/hooks/use-conversation-list-item-context-menu-default-props";
import { useDmPeerInboxId } from "@/queries/useDmPeerInbox";
import { DmWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DmWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { useCurrentAccount } from "@data/store/accountsStore";
import { usePreferredInboxAvatar } from "@hooks/usePreferredInboxAvatar";
import { usePreferredInboxName } from "@hooks/usePreferredInboxName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PinnedConversationAvatar } from "@/features/conversation-list/conversat
import { useConversationIsUnread } from "@/features/conversation-list/hooks/use-conversation-is-unread";
import { useConversationContextMenuViewDefaultProps } from "@/features/conversation-list/hooks/use-conversation-list-item-context-menu-default-props";
import { isTextMessage } from "@/features/conversation/conversation-message/conversation-message.utils";
import { GroupWithCodecsType } from "@/utils/xmtpRN/client.types";
import { GroupWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { navigate } from "@utils/navigation";
import { useCallback } from "react";
import { ConversationListPinnedConversation } from "./conversation-list-pinned-conversation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Text } from "@/design-system/Text";
import { useMessagePlainText } from "@/features/conversation-list/hooks/useMessagePlainText";
import { ThemedStyle, useAppTheme } from "@/theme/useAppTheme";
import { captureError } from "@/utils/capture-error";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { ViewStyle } from "react-native";

export type IPinnedConversationMessagePreviewProps = {
Expand Down
2 changes: 1 addition & 1 deletion features/conversation-list/conversation-list.screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { captureError } from "@/utils/capture-error";
import {
DmWithCodecsType,
GroupWithCodecsType,
} from "@/utils/xmtpRN/client.types";
} from "@/utils/xmtpRN/client/client.types";
import { useDisconnectActionSheet } from "@hooks/useDisconnectActionSheet";
import { NativeStackScreenProps } from "@react-navigation/native-stack";
import React, { memo, useCallback } from "react";
Expand Down
2 changes: 1 addition & 1 deletion features/conversation-list/conversation-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ConversationListItemDm } from "@/features/conversation-list/conversatio
import { ConversationListItemGroup } from "@/features/conversation-list/conversation-list-item/conversation-list-item-group";
import { isConversationGroup } from "@/features/conversation/utils/is-conversation-group";
import { useAppTheme } from "@/theme/useAppTheme";
import { ConversationWithCodecsType } from "@/utils/xmtpRN/client.types";
import { ConversationWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { useCallback, useRef } from "react";
import {
FlatListProps,
Expand Down
2 changes: 1 addition & 1 deletion features/conversation-list/hooks/use-delete-dm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { actionSheetColors } from "@/styles/colors";
import { useAppTheme } from "@/theme/useAppTheme";
import { deleteTopic } from "@/utils/api/topics";
import { captureErrorWithToast } from "@/utils/capture-error";
import { DmWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DmWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { useMutation } from "@tanstack/react-query";
import { useCallback } from "react";

Expand Down
2 changes: 1 addition & 1 deletion features/conversation-list/hooks/useMessagePlainText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "@/queries/useInboxProfileSocialsQuery";
import { captureError } from "@/utils/capture-error";
import { getPreferredInboxName } from "@/utils/profile";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import logger from "@utils/logger";
import {
DecodedMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useCurrentAccount } from "@/data/store/accountsStore";
import { getMessageStringContent } from "@/features/conversation/conversation-message/conversation-message.utils";
import { getUnknownConsentConversationsQueryOptions } from "@/queries/unknown-consent-conversations-query";
import { captureError, captureErrorWithToast } from "@/utils/capture-error";
import { ConversationWithCodecsType } from "@/utils/xmtpRN/client.types";
import { ConversationWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { getMessageContentType } from "@/utils/xmtpRN/content-types/content-types";
import { useQuery } from "@tanstack/react-query";
import { useEffect, useState } from "react";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { useConversationMessageById } from "../conversation-message/use-conversation-message";
import { messageIsFromCurrentAccountInboxId } from "@/features/conversation/utils/message-is-from-current-user";
import { usePreferredInboxName } from "@/hooks/usePreferredInboxName";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { HStack } from "@design-system/HStack";
import { Icon } from "@design-system/Icon/Icon";
import { IconButton } from "@design-system/IconButton/IconButton";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from "@/features/conversation/conversation.store-context";
import { usePreferredInboxName } from "@/hooks/usePreferredInboxName";
import { captureError } from "@/utils/capture-error";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client/client.types";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to think it might be a good idea if we have a very thin layer that wraps all of our messaging stuff before messaging stuff touches the application

The reason being we don't need all these complicated types littering our code base and we could just have a message that has content available on it with a content type that is a Concrete property that we can determine at that layer and so instead of these complicated decoded message with Kodex types, etc., we could simply have message conversation, etc.

import { HStack } from "@design-system/HStack";
import { Icon } from "@design-system/Icon/Icon";
import { Text } from "@design-system/Text";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { MessageDeliveryStatus } from "@xmtp/react-native-sdk";

export function messageIsSent(message: DecodedMessageWithCodecsType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { hasPreviousMessageInSeries } from "@/features/conversation/utils/has-pr
import { messageIsFromCurrentAccountInboxId } from "@/features/conversation/utils/message-is-from-current-user";
import { messageShouldShowDateChange } from "@/features/conversation/utils/message-should-show-date-change";
import { convertNanosecondsToMilliseconds } from "@/utils/date";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { InboxId, MessageId } from "@xmtp/react-native-sdk";
import { createContext, memo, useContext, useEffect, useRef } from "react";
import { createStore, useStore } from "zustand";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
isTextMessage,
isTransactionReferenceMessage,
} from "@/features/conversation/conversation-message/conversation-message.utils";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client.types";
import { DecodedMessageWithCodecsType } from "@/utils/xmtpRN/client/client.types";
import { memo } from "react";

export const ConversationMessage = memo(
Expand Down
Loading
Loading