Skip to content

Commit

Permalink
cleaned up functions
Browse files Browse the repository at this point in the history
Removed old functions to use better typesafe
  • Loading branch information
alexrisch committed Jan 3, 2025
1 parent 0d83716 commit d4cbb2c
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 191 deletions.
18 changes: 4 additions & 14 deletions components/ConversationFlashList/ConversationFlashList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ import { useSelect } from "@data/store/storeHelpers";
import { NavigationParamList } from "@screens/Navigation/Navigation";
import { ConversationFlatListHiddenRequestItem } from "@utils/conversation";
import { FlatListItemType } from "@features/conversation-list/ConversationList.types";
import { unwrapConversationContainer } from "@utils/groupUtils/conversationContainerHelpers";
import { ConversationVersion } from "@xmtp/react-native-sdk";
import {
DmWithCodecsType,
GroupWithCodecsType,
} from "@/utils/xmtpRN/client.types";
import { V3DMListItem } from "../V3DMListItem";
import { CONVERSATION_FLASH_LIST_REFRESH_THRESHOLD } from "./ConversationFlashList.constants";
import { isConversationGroup } from "@/features/conversation/utils/is-conversation-group";

type Props = {
onScroll?: () => void;
Expand Down Expand Up @@ -73,15 +68,10 @@ export default function ConversationFlashList({

const renderItem = useCallback(({ item }: { item: FlatListItemType }) => {
if ("lastMessage" in item) {
const conversation = unwrapConversationContainer(item);
if (conversation.version === ConversationVersion.GROUP) {
return (
<V3GroupConversationListItem
group={conversation as GroupWithCodecsType}
/>
);
if (isConversationGroup(item)) {
return <V3GroupConversationListItem group={item} />;
} else {
return <V3DMListItem conversation={conversation as DmWithCodecsType} />;
return <V3DMListItem conversation={item} />;
}
}
if (item.topic === "hiddenRequestsButton") {
Expand Down
16 changes: 4 additions & 12 deletions components/PinnedConversations/PinnedV3Conversation.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { useConversationListGroupItem } from "@hooks/useConversationListGroupItem";
import { conversationIsGroup } from "@utils/groupUtils/conversationContainerHelpers";
import {
DmWithCodecsType,
GroupWithCodecsType,
} from "@/utils/xmtpRN/client.types";
import React from "react";
import { PinnedV3GroupConversation } from "./PinnedV3GroupConversation";
import { PinnedV3DMConversation } from "./PinnedV3DMConversation";
import type { ConversationTopic } from "@xmtp/react-native-sdk";
import { isConversationGroup } from "@/features/conversation/utils/is-conversation-group";

type PinnedV3ConversationProps = {
topic: string;
Expand All @@ -18,12 +14,8 @@ export const PinnedV3Conversation = ({ topic }: PinnedV3ConversationProps) => {
if (!conversation) {
return null;
}
if (conversationIsGroup(conversation)) {
return (
<PinnedV3GroupConversation group={conversation as GroupWithCodecsType} />
);
if (isConversationGroup(conversation)) {
return <PinnedV3GroupConversation group={conversation} />;
}
return (
<PinnedV3DMConversation conversation={conversation as DmWithCodecsType} />
);
return <PinnedV3DMConversation conversation={conversation} />;
};
Loading

0 comments on commit d4cbb2c

Please sign in to comment.