Skip to content

Commit 502f7d7

Browse files
reply navigation improvement
1 parent a4d48b2 commit 502f7d7

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

src/components/ConversationList.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ import { DoubleDownArrow } from '../common/Icons';
66
import Pressable from '../common/Pressable';
77
import ApplicationColors from '../config/appColors';
88
import config from '../config/config';
9-
import { calculateOffset, getUserIdFromJid, handleConversationScollToBottom } from '../helpers/chatHelpers';
9+
import {
10+
calculateOffset,
11+
getReplyScrollmsgId,
12+
getUserIdFromJid,
13+
handleConversationScollToBottom,
14+
setReplyScrollmsgId,
15+
} from '../helpers/chatHelpers';
1016
import { CHAT_TYPE_GROUP, NOTIFICATION } from '../helpers/constants';
1117
import { useChatMessages, useThemeColorPalatte } from '../redux/reduxHook';
1218
import { getCurrentUserJid } from '../uikitMethods';
1319
import ChatMessage from './ChatMessage';
20+
import store from '../redux/store';
21+
import { highlightMessage } from '../redux/chatMessageDataSlice';
1422

1523
export const conversationFlatListRef = createRef();
1624
conversationFlatListRef.current = {};
@@ -147,6 +155,12 @@ const ConversationList = ({ chatUser }) => {
147155
disableVirtualization={true}
148156
scrollEventThrottle={16}
149157
windowSize={5}
158+
onMomentumScrollEnd={() => {
159+
setTimeout(() => {
160+
store.dispatch(highlightMessage({ userId, msgId: getReplyScrollmsgId(), shouldHighlight: 0 }));
161+
setReplyScrollmsgId(null);
162+
}, 1000);
163+
}}
150164
onEndReached={handleLoadMore}
151165
onEndReachedThreshold={0.5}
152166
onScroll={handleScroll}

src/helpers/chatHelpers.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ const memoizedUsernameGraphemes = {};
120120
const splitter = new Graphemer();
121121
let currentChatUser = '';
122122
const stringSet = getStringSet();
123-
let isConversationScreenActive = false;
123+
let isConversationScreenActive = false,
124+
replyScrollmsgId = '';
124125

125126
const documentAttachmentTypes = [
126127
DocumentPicker.types.allFiles,
@@ -138,6 +139,12 @@ const documentAttachmentTypes = [
138139
// '.rar'
139140
];
140141

142+
export const getReplyScrollmsgId = () => replyScrollmsgId;
143+
144+
export const setReplyScrollmsgId = val => {
145+
replyScrollmsgId = val;
146+
};
147+
141148
export const setIsConversationScreenActive = val => {
142149
isConversationScreenActive = val;
143150
};
@@ -1315,10 +1322,7 @@ export const handleReplyPress = (userId, msgId, message) => {
13151322
offset: adjustedOffset,
13161323
animated: true,
13171324
});
1318-
1319-
setTimeout(() => {
1320-
store.dispatch(highlightMessage({ userId, msgId, shouldHighlight: 0 }));
1321-
}, 1000);
1325+
replyScrollmsgId = msgId;
13221326
};
13231327

13241328
export const findConversationMessageIndex = (msgId, message) => {

0 commit comments

Comments
 (0)