Skip to content
Merged
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: 1 addition & 2 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,7 @@ const CONST = {
},
},
THREAD_DISABLED: ['CREATED'],
// Used when displaying reportActions list to handle unread messages icon/button
SCROLL_VERTICAL_OFFSET_THRESHOLD: 200,
LATEST_MESSAGES_PILL_SCROLL_OFFSET_THRESHOLD: 2000,
ACTION_VISIBLE_THRESHOLD: 250,
MAX_GROUPING_TIME: 300000,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function MoneyRequestReportActionsList({
/**
* The reportActionID the unread marker should display above
*/
const unreadMarkerReportActionID = useMemo(() => {
const [unreadMarkerReportActionID, unreadMarkerReportActionIndex] = useMemo(() => {
// If there are message that were received while offline,
// we can skip checking all messages later than the earliest received offline message.
const startIndex = visibleReportActions.length - 1;
Expand All @@ -384,20 +384,20 @@ function MoneyRequestReportActionsList({

// eslint-disable-next-line react-compiler/react-compiler
if (shouldDisplayNewMarker) {
return reportAction.reportActionID;
return [reportAction.reportActionID, index];
}
}

return null;
return [null, -1];
}, [currentUserAccountID, earliestReceivedOfflineMessageIndex, prevVisibleActionsMap, visibleReportActions, unreadMarkerTime]);
prevUnreadMarkerReportActionID.current = unreadMarkerReportActionID;

const {isFloatingMessageCounterVisible, setIsFloatingMessageCounterVisible, trackVerticalScrolling} = useReportUnreadMessageScrollTracking({
const {isFloatingMessageCounterVisible, setIsFloatingMessageCounterVisible, trackVerticalScrolling, onViewableItemsChanged} = useReportUnreadMessageScrollTracking({
reportID: report.reportID,
currentVerticalScrollingOffsetRef: scrollingVerticalBottomOffset,
floatingMessageVisibleInitialValue: false,
readActionSkippedRef: readActionSkipped,
hasUnreadMarkerReportAction: !!unreadMarkerReportActionID,
unreadMarkerReportActionIndex,
isInverted: false,
Comment thread
FitseTLT marked this conversation as resolved.
onTrackScrolling: (event: NativeSyntheticEvent<NativeScrollEvent>) => {
const {layoutMeasurement, contentSize, contentOffset} = event.nativeEvent;
const fullContentHeight = contentSize.height;
Expand Down Expand Up @@ -675,6 +675,7 @@ function MoneyRequestReportActionsList({
)}
<View style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]}>
<FloatingMessageCounter
hasNewMessages={!!unreadMarkerReportActionID}
isActive={isFloatingMessageCounterVisible}
onClick={scrollToBottomAndMarkReportAsRead}
/>
Expand All @@ -694,6 +695,7 @@ function MoneyRequestReportActionsList({
style={styles.overscrollBehaviorContain}
data={visibleReportActions}
renderItem={renderItem}
onViewableItemsChanged={onViewableItemsChanged}
keyExtractor={keyExtractor}
onLayout={recordTimeToMeasureItemLayout}
onEndReached={onEndReached}
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ const translations = {
hereAlternateText: 'Benachrichtige alle in diesem Gespräch',
},
newMessages: 'Neue Nachrichten',
latestMessages: 'Neueste Nachrichten',
youHaveBeenBanned: 'Hinweis: Du wurdest von der Teilnahme an diesem Kanal ausgeschlossen.',
reportTypingIndicator: {
isTyping: 'tippt...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ const translations = {
hereAlternateText: 'Notify everyone in this conversation',
},
newMessages: 'New messages',
latestMessages: 'Latest messages',
youHaveBeenBanned: "Note: You've been banned from chatting in this channel.",
reportTypingIndicator: {
isTyping: 'is typing...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ const translations = {
hereAlternateText: 'Notificar a todos en esta conversación',
},
newMessages: 'Mensajes nuevos',
latestMessages: 'Últimos mensajes',
youHaveBeenBanned: 'Nota: Se te ha prohibido comunicarte en este canal',
reportTypingIndicator: {
isTyping: 'está escribiendo...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ const translations = {
hereAlternateText: 'Notifier tout le monde dans cette conversation',
},
newMessages: 'Nouveaux messages',
latestMessages: 'Derniers messages',
youHaveBeenBanned: 'Remarque : Vous avez été banni de la discussion dans ce canal.',
reportTypingIndicator: {
isTyping: 'est en train de taper...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ const translations = {
hereAlternateText: 'Notifica tutti in questa conversazione',
},
newMessages: 'Nuovi messaggi',
latestMessages: 'Ultimi messaggi',
youHaveBeenBanned: 'Nota: Sei stato bannato dalla chat in questo canale.',
reportTypingIndicator: {
isTyping: 'sta scrivendo...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ const translations = {
hereAlternateText: 'この会話の全員に通知する',
},
newMessages: '新しいメッセージ',
latestMessages: '最新のメッセージ',
youHaveBeenBanned: '注意: このチャンネルでのチャットは禁止されています。',
reportTypingIndicator: {
isTyping: '入力中...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ const translations = {
hereAlternateText: 'Breng iedereen in dit gesprek op de hoogte',
},
newMessages: 'Nieuwe berichten',
latestMessages: 'Laatste berichten',
youHaveBeenBanned: 'Opmerking: Je bent verbannen van het chatten in dit kanaal.',
reportTypingIndicator: {
isTyping: 'is aan het typen...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ const translations = {
hereAlternateText: 'Powiadom wszystkich w tej rozmowie',
},
newMessages: 'Nowe wiadomości',
latestMessages: 'Ostatnie wiadomości',
youHaveBeenBanned: 'Uwaga: Zostałeś zbanowany z czatu na tym kanale.',
reportTypingIndicator: {
isTyping: 'pisze...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ const translations = {
hereAlternateText: 'Notificar todos nesta conversa',
},
newMessages: 'Novas mensagens',
latestMessages: 'Mensagens recentes',
youHaveBeenBanned: 'Nota: Você foi banido de conversar neste canal.',
reportTypingIndicator: {
isTyping: 'está digitando...',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ const translations = {
hereAlternateText: '通知此对话中的所有人',
},
newMessages: '新消息',
latestMessages: '最新消息',
youHaveBeenBanned: '注意:您已被禁止在此频道聊天。',
reportTypingIndicator: {
isTyping: '正在输入...',
Expand Down
13 changes: 8 additions & 5 deletions src/pages/home/report/FloatingMessageCounter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ type FloatingMessageCounterProps = {
/** Whether the New Messages indicator is active */
isActive?: boolean;

/** Whether there are new messages */
hasNewMessages: boolean;

/** Callback to be called when user clicks the New Messages indicator */
onClick?: () => void;
};

const MARKER_INACTIVE_TRANSLATE_Y = -40;
const MARKER_ACTIVE_TRANSLATE_Y = 10;

function FloatingMessageCounter({isActive = false, onClick = () => {}}: FloatingMessageCounterProps) {
function FloatingMessageCounter({isActive = false, onClick = () => {}, hasNewMessages}: FloatingMessageCounterProps) {
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -60,22 +63,22 @@ function FloatingMessageCounter({isActive = false, onClick = () => {}}: Floating
<View style={styles.floatingMessageCounter}>
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter]}>
<Button
success
success={hasNewMessages}
small
onPress={onClick}
>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<Icon
small
src={Expensicons.DownArrow}
fill={theme.textLight}
fill={hasNewMessages ? theme.textLight : theme.icon}
/>

<Text
style={[styles.ml2, styles.buttonSmallText, styles.textWhite, styles.userSelectNone]}
style={[styles.ml2, styles.buttonSmallText, hasNewMessages && styles.textWhite, styles.userSelectNone]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{translate('newMessages')}
{hasNewMessages ? translate('newMessages') : translate('latestMessages')}
</Text>
</View>
</Button>
Expand Down
25 changes: 8 additions & 17 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ type ReportActionsListProps = {
shouldEnableAutoScrollToTopThreshold?: boolean;
};

const IS_CLOSE_TO_NEWEST_THRESHOLD = 15;

// In the component we are subscribing to the arrival of new actions.
// As there is the possibility that there are multiple instances of a ReportScreen
// for the same report, we only ever want one subscription to be active, as
Expand Down Expand Up @@ -247,7 +245,7 @@ function ReportActionsList({
/**
* The reportActionID the unread marker should display above
*/
const unreadMarkerReportActionID = useMemo(() => {
const [unreadMarkerReportActionID, unreadMarkerReportActionIndex] = useMemo(() => {
// If there are message that were received while offline,
// we can skip checking all messages later than the earliest received offline message.
const startIndex = earliestReceivedOfflineMessageIndex ?? 0;
Expand All @@ -272,11 +270,11 @@ function ReportActionsList({
prevUnreadMarkerReportActionID: prevUnreadMarkerReportActionID.current,
});
if (shouldDisplayNewMarker) {
return reportAction.reportActionID;
return [reportAction.reportActionID, index];
}
}

return null;
return [null, -1];
}, [accountID, earliestReceivedOfflineMessageIndex, prevSortedVisibleReportActionsObjects, sortedVisibleReportActions, unreadMarkerTime]);
prevUnreadMarkerReportActionID.current = unreadMarkerReportActionID;

Expand Down Expand Up @@ -330,28 +328,19 @@ function ReportActionsList({

// Display the new message indicator when comment linking and not close to the newest message.
const reportActionID = route?.params?.reportActionID;
const indexOfLinkedAction = reportActionID ? sortedVisibleReportActions.findIndex((action) => action.reportActionID === reportActionID) : -1;
const isLinkedActionCloseToNewest = indexOfLinkedAction < IS_CLOSE_TO_NEWEST_THRESHOLD;

const {isFloatingMessageCounterVisible, setIsFloatingMessageCounterVisible, trackVerticalScrolling} = useReportUnreadMessageScrollTracking({
const {isFloatingMessageCounterVisible, setIsFloatingMessageCounterVisible, trackVerticalScrolling, onViewableItemsChanged} = useReportUnreadMessageScrollTracking({
reportID: report.reportID,
currentVerticalScrollingOffsetRef: scrollingVerticalOffset,
floatingMessageVisibleInitialValue: !isLinkedActionCloseToNewest,
readActionSkippedRef: readActionSkipped,
hasUnreadMarkerReportAction: !!unreadMarkerReportActionID,
unreadMarkerReportActionIndex,
isInverted: true,
onTrackScrolling: (event: NativeSyntheticEvent<NativeScrollEvent>) => {
scrollingVerticalOffset.current = event.nativeEvent.contentOffset.y;
onScroll?.(event);
},
});

useEffect(() => {
if (isLinkedActionCloseToNewest) {
return;
}
setIsFloatingMessageCounterVisible(true);
}, [isLinkedActionCloseToNewest, route, setIsFloatingMessageCounterVisible]);

useEffect(() => {
if (
scrollingVerticalOffset.current < AUTOSCROLL_TO_TOP_THRESHOLD &&
Expand Down Expand Up @@ -777,6 +766,7 @@ function ReportActionsList({
return (
<>
<FloatingMessageCounter
hasNewMessages={!!unreadMarkerReportActionID}
isActive={isFloatingMessageCounterVisible}
onClick={scrollToBottomAndMarkReportAsRead}
/>
Expand Down Expand Up @@ -806,6 +796,7 @@ function ReportActionsList({
keyboardShouldPersistTaps="handled"
onLayout={onLayoutInner}
onScroll={trackVerticalScrolling}
onViewableItemsChanged={onViewableItemsChanged}
onScrollToIndexFailed={onScrollToIndexFailed}
extraData={extraData}
key={listID}
Expand Down
Loading