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

refactor and fix modal #1094

Merged
merged 9 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
152 changes: 79 additions & 73 deletions components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { getProfile, getProfileData } from "../../utils/profile";
import { UUID_REGEX } from "../../utils/regex";
import { isContentType } from "../../utils/xmtpRN/contentTypes";
import { Recommendation } from "../Recommendations/Recommendation";
import { MessageReactionsDrawer } from "./Message/MessageReactions/MessageReactionsDrawer/MessageReactionsDrawer";

const usePeerSocials = () => {
const conversation = useConversationContext("conversation");
Expand Down Expand Up @@ -430,81 +431,86 @@ export function Chat() {
}, [onReadyToFocus]);

return (
<View
style={styles.chatContainer}
key={`chat-${
conversation?.isGroup ? conversation?.topic : conversation?.peerAddress
}-${conversation?.context?.conversationId || ""}-${isBlockedPeer}`}
>
<Animated.View style={chatContentStyle}>
{conversation && listArray.length > 0 && !isBlockedPeer && (
<AnimatedListView
contentContainerStyle={styles.chat}
data={listArray}
refreshing={conversation?.pending}
extraData={[peerSocials]}
renderItem={renderItem}
onLayout={handleOnLayout}
ref={(r) => {
if (r) {
messageListRef.current = r;
<>
<View
style={styles.chatContainer}
key={`chat-${
conversation?.isGroup
? conversation?.topic
: conversation?.peerAddress
}-${conversation?.context?.conversationId || ""}-${isBlockedPeer}`}
>
<Animated.View style={chatContentStyle}>
{conversation && listArray.length > 0 && !isBlockedPeer && (
<AnimatedListView
contentContainerStyle={styles.chat}
data={listArray}
refreshing={conversation?.pending}
extraData={[peerSocials]}
renderItem={renderItem}
onLayout={handleOnLayout}
ref={(r) => {
if (r) {
messageListRef.current = r;
}
}}
keyboardDismissMode="interactive"
automaticallyAdjustContentInsets={false}
contentInsetAdjustmentBehavior="never"
// Causes a glitch on Android, no sure we need it for now
// maintainVisibleContentPosition={{
// minIndexForVisible: 0,
// autoscrollToTopThreshold: 100,
// }}
estimatedListSize={
isSplitScreen ? undefined : Dimensions.get("screen")
}
}}
keyboardDismissMode="interactive"
automaticallyAdjustContentInsets={false}
contentInsetAdjustmentBehavior="never"
// Causes a glitch on Android, no sure we need it for now
// maintainVisibleContentPosition={{
// minIndexForVisible: 0,
// autoscrollToTopThreshold: 100,
// }}
estimatedListSize={
isSplitScreen ? undefined : Dimensions.get("screen")
}
inverted
keyExtractor={keyExtractor}
getItemType={getItemType(framesStore)}
keyboardShouldPersistTaps="handled"
estimatedItemSize={80}
// Size glitch on Android
showsVerticalScrollIndicator={Platform.OS === "ios"}
pointerEvents="auto"
ListFooterComponent={ListFooterComponent}
/>
inverted
keyExtractor={keyExtractor}
getItemType={getItemType(framesStore)}
keyboardShouldPersistTaps="handled"
estimatedItemSize={80}
// Size glitch on Android
showsVerticalScrollIndicator={Platform.OS === "ios"}
pointerEvents="auto"
ListFooterComponent={ListFooterComponent}
/>
)}
{showPlaceholder && !conversation?.isGroup && (
<ChatPlaceholder messagesCount={listArray.length} />
)}
{showPlaceholder && conversation?.isGroup && (
<GroupChatPlaceholder messagesCount={listArray.length} />
)}
{conversation?.isGroup ? <GroupConsentPopup /> : <ConsentPopup />}
</Animated.View>
{showChatInput && (
<>
<ReanimatedView
style={[
textInputStyle,
{
display:
frameTextInputFocused && hideInputIfFrameFocused
? "none"
: "flex",
},
]}
>
{!transactionMode && <ChatInput inputHeight={chatInputHeight} />}
{transactionMode && <TransactionInput />}
</ReanimatedView>
<View
style={[
styles.inputBottomFiller,
{ height: insets.bottom + DEFAULT_INPUT_HEIGHT },
]}
/>
</>
lourou marked this conversation as resolved.
Show resolved Hide resolved
)}
{showPlaceholder && !conversation?.isGroup && (
<ChatPlaceholder messagesCount={listArray.length} />
)}
{showPlaceholder && conversation?.isGroup && (
<GroupChatPlaceholder messagesCount={listArray.length} />
)}
{conversation?.isGroup ? <GroupConsentPopup /> : <ConsentPopup />}
</Animated.View>
{showChatInput && (
<>
<ReanimatedView
style={[
textInputStyle,
{
display:
frameTextInputFocused && hideInputIfFrameFocused
? "none"
: "flex",
},
]}
>
{!transactionMode && <ChatInput inputHeight={chatInputHeight} />}
{transactionMode && <TransactionInput />}
</ReanimatedView>
<View
style={[
styles.inputBottomFiller,
{ height: insets.bottom + DEFAULT_INPUT_HEIGHT },
]}
/>
</>
)}
</View>
</View>
<MessageReactionsDrawer />
lourou marked this conversation as resolved.
Show resolved Hide resolved
</>
lourou marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down
2 changes: 1 addition & 1 deletion components/Chat/Message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Animated, {
} from "react-native-reanimated";

import ChatMessageActions from "./MessageActions";
import { ChatMessageReactions } from "./MessageReactions";
import { ChatMessageReactions } from "./MessageReactions/MessageReactions";
import MessageStatus from "./MessageStatus";
import {
currentAccount,
Expand Down
Loading