Skip to content

Commit

Permalink
Fix frames caching display because group is refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalzieu committed Jun 27, 2024
1 parent d14254c commit f886c88
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
2 changes: 1 addition & 1 deletion components/PinnedConversations/PinnedConversations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function PinnedConversations({ convos }: Props) {
const pinnedConvos = !convos
? []
: convos?.map((convo) => {
return <PinnedConversation conversation={convo} />;
return <PinnedConversation conversation={convo} key={convo.topic} />;
});
return <View style={styles.container}>{pinnedConvos}</View>;
}
Expand Down
26 changes: 1 addition & 25 deletions screens/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ import { isDesktop } from "../utils/device";
import { converseEventEmitter } from "../utils/events";
import { setTopicToNavigateTo, topicToNavigateTo } from "../utils/navigation";
import { getTitleFontScale, TextInputWithValue } from "../utils/str";
import { ConverseXmtpClientType } from "../utils/xmtpRN/client";
import {
loadOlderMessages,
syncGroupsMessages,
} from "../utils/xmtpRN/messages";
import { getXmtpClient } from "../utils/xmtpRN/sync";
import { loadOlderMessages } from "../utils/xmtpRN/messages";
import { NavigationParamList } from "./Navigation/Navigation";

const Conversation = ({
Expand Down Expand Up @@ -245,24 +240,6 @@ const Conversation = ({
};
}, [navigation, onLeaveScreen, onOpeningConversation]);

const refreshGroup = useCallback(async () => {
if (!conversation?.isGroup || !conversation?.topic) return;
const client = (await getXmtpClient(
currentAccount()
)) as ConverseXmtpClientType;
if (!client) return;
const groups = await client.conversations.listGroups();
const group = groups.find((g) => g.topic === conversation.topic);
if (!group) return;
syncGroupsMessages(currentAccount(), [group], {
[conversation?.topic]: 0,
});
}, [conversation?.isGroup, conversation?.topic]);

useEffect(() => {
refreshGroup();
}, [refreshGroup]);

return (
<View style={styles.container} key={`conversation-${colorScheme}`}>
{route.params?.topic || route.params?.mainConversationWithPeer ? (
Expand All @@ -277,7 +254,6 @@ const Conversation = ({
setTransactionMode,
frameTextInputFocused,
setFrameTextInputFocused,
onPullToRefresh: conversation?.isGroup ? refreshGroup : undefined,
}}
>
<ConverseChat />
Expand Down
5 changes: 4 additions & 1 deletion screens/ConversationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ function ConversationList({ navigation, route, searchBarRef }: Props) {
}, [clearSearch, isSplit, openedConversationTopic]);

const ListHeaderComponents: React.ReactElement[] = [
<PinnedConversations convos={pinnedConversations} />,
<PinnedConversations
convos={pinnedConversations}
key="pinnedConversations"
/>,
];
const showSearchTitleHeader =
((Platform.OS === "ios" && searchBarFocused && !showNoResult) ||
Expand Down

0 comments on commit f886c88

Please sign in to comment.