diff --git a/src/CONST.ts b/src/CONST.ts
index dd192f1b257c..08c6a2509207 100755
--- a/src/CONST.ts
+++ b/src/CONST.ts
@@ -2650,6 +2650,12 @@ const CONST = {
EVENTS: {
SCROLLING: 'scrolling',
},
+ HORIZONTAL_SPACER: {
+ DEFAULT_BORDER_BOTTOM_WIDTH: 1,
+ DEFAULT_MARGIN_VERTICAL: 8,
+ HIDDEN_MARGIN_VERTICAL: 0,
+ HIDDEN_BORDER_BOTTOM_WIDTH: 0,
+ },
} as const;
export default CONST;
diff --git a/src/components/ReportActionItem/MoneyReportView.js b/src/components/ReportActionItem/MoneyReportView.js
index 68eecf11d5bf..f593d947f96c 100644
--- a/src/components/ReportActionItem/MoneyReportView.js
+++ b/src/components/ReportActionItem/MoneyReportView.js
@@ -15,6 +15,7 @@ import variables from '../../styles/variables';
import * as CurrencyUtils from '../../libs/CurrencyUtils';
import EmptyStateBackgroundImage from '../../../assets/images/empty-state_background-fade.png';
import useLocalize from '../../hooks/useLocalize';
+import SpacerView from '../SpacerView';
const propTypes = {
/** The report currently being looked at */
@@ -66,7 +67,10 @@ function MoneyReportView(props) {
- {props.shouldShowHorizontalRule && }
+
);
}
diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js
index 712c7ded6ab0..de01f0cfde8f 100644
--- a/src/components/ReportActionItem/MoneyRequestView.js
+++ b/src/components/ReportActionItem/MoneyRequestView.js
@@ -27,6 +27,7 @@ import Image from '../Image';
import ReportActionItemImage from './ReportActionItemImage';
import * as TransactionUtils from '../../libs/TransactionUtils';
import OfflineWithFeedback from '../OfflineWithFeedback';
+import SpacerView from '../SpacerView';
const propTypes = {
/** The report currently being looked at */
@@ -169,7 +170,10 @@ function MoneyRequestView({report, parentReport, shouldShowHorizontalRule, trans
subtitleTextStyle={styles.textLabelError}
/>
- {shouldShowHorizontalRule && }
+
);
}
diff --git a/src/components/ReportActionItem/TaskView.js b/src/components/ReportActionItem/TaskView.js
index 8c6432a79878..f2a1758a050b 100644
--- a/src/components/ReportActionItem/TaskView.js
+++ b/src/components/ReportActionItem/TaskView.js
@@ -27,6 +27,7 @@ import getButtonState from '../../libs/getButtonState';
import PressableWithSecondaryInteraction from '../PressableWithSecondaryInteraction';
import * as Session from '../../libs/actions/Session';
import * as Expensicons from '../Icon/Expensicons';
+import SpacerView from '../SpacerView';
const propTypes = {
/** The report currently being looked at */
@@ -158,7 +159,10 @@ function TaskView(props) {
/>
)}
- {props.shouldShowHorizontalRule && }
+
);
}
diff --git a/src/components/SpacerView.js b/src/components/SpacerView.js
new file mode 100644
index 000000000000..3b81bbfa0dc5
--- /dev/null
+++ b/src/components/SpacerView.js
@@ -0,0 +1,49 @@
+import React from 'react';
+import Animated, {useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
+import PropTypes from 'prop-types';
+import * as StyleUtils from '../styles/StyleUtils';
+import stylePropTypes from '../styles/stylePropTypes';
+import CONST from '../CONST';
+
+const propTypes = {
+ /**
+ * Should we show the spacer
+ */
+ shouldShow: PropTypes.bool.isRequired,
+
+ /**
+ * Array of style objects
+ * @default []
+ */
+ style: stylePropTypes,
+};
+
+const defaultProps = {
+ style: [],
+};
+
+function SpacerView({shouldShow = true, style = []}) {
+ const marginVertical = useSharedValue(CONST.HORIZONTAL_SPACER.DEFAULT_MARGIN_VERTICAL);
+ const borderBottomWidth = useSharedValue(CONST.HORIZONTAL_SPACER.DEFAULT_BORDER_BOTTOM_WIDTH);
+ const animatedStyles = useAnimatedStyle(() => ({
+ marginVertical: marginVertical.value,
+ borderBottomWidth: borderBottomWidth.value,
+ }));
+
+ React.useEffect(() => {
+ const duration = CONST.ANIMATED_TRANSITION;
+ const values = {
+ marginVertical: shouldShow ? CONST.HORIZONTAL_SPACER.DEFAULT_MARGIN_VERTICAL : CONST.HORIZONTAL_SPACER.HIDDEN_MARGIN_VERTICAL,
+ borderBottomWidth: shouldShow ? CONST.HORIZONTAL_SPACER.DEFAULT_BORDER_BOTTOM_WIDTH : CONST.HORIZONTAL_SPACER.HIDDEN_BORDER_BOTTOM_WIDTH,
+ };
+ marginVertical.value = withTiming(values.marginVertical, {duration});
+ borderBottomWidth.value = withTiming(values.borderBottomWidth, {duration});
+ }, [shouldShow, borderBottomWidth, marginVertical]);
+
+ return ;
+}
+
+SpacerView.displayName = 'SpacerView';
+SpacerView.propTypes = propTypes;
+SpacerView.defaultProps = defaultProps;
+export default SpacerView;
diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js
index 5ba91cccf924..19270ff13f45 100644
--- a/src/pages/home/report/ReportActionsList.js
+++ b/src/pages/home/report/ReportActionsList.js
@@ -115,7 +115,7 @@ function ReportActionsList({
const {isOffline} = useNetwork();
const opacity = useSharedValue(0);
const userActiveSince = useRef(null);
- const currentUnreadMarker = useRef(null);
+ const [currentUnreadMarker, setCurrentUnreadMarker] = useState(null);
const scrollingVerticalOffset = useRef(0);
const readActionSkipped = useRef(false);
const reportActionSize = useRef(sortedReportActions.length);
@@ -158,12 +158,12 @@ function ReportActionsList({
}
}
- if (currentUnreadMarker.current || reportActionSize.current === sortedReportActions.length) {
+ if (currentUnreadMarker || reportActionSize.current === sortedReportActions.length) {
return;
}
reportActionSize.current = sortedReportActions.length;
- currentUnreadMarker.current = null;
+ setCurrentUnreadMarker(null);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sortedReportActions.length, report.reportID]);
@@ -175,7 +175,7 @@ function ReportActionsList({
}
// Clearing the current unread marker so that it can be recalculated
- currentUnreadMarker.current = null;
+ setCurrentUnreadMarker(null);
setMessageManuallyMarked({read: true});
// We only care when a new lastReadTime is set in the report
@@ -224,7 +224,7 @@ function ReportActionsList({
* Show/hide the new floating message counter when user is scrolling back/forth in the history of messages.
*/
const handleUnreadFloatingButton = () => {
- if (scrollingVerticalOffset.current > VERTICAL_OFFSET_THRESHOLD && !isFloatingMessageCounterVisible && !!currentUnreadMarker.current) {
+ if (scrollingVerticalOffset.current > VERTICAL_OFFSET_THRESHOLD && !isFloatingMessageCounterVisible && !!currentUnreadMarker) {
setIsFloatingMessageCounterVisible(true);
}
@@ -260,6 +260,15 @@ function ReportActionsList({
return Math.ceil(availableHeight / minimumReportActionHeight);
}, [windowHeight]);
+ /**
+ * Thread's divider line should hide when the first chat in the thread is marked as unread.
+ * This is so that it will not be conflicting with header's separator line.
+ */
+ const shouldHideThreadDividerLine = useMemo(
+ () => sortedReportActions.length > 1 && sortedReportActions[sortedReportActions.length - 2].reportActionID === currentUnreadMarker,
+ [sortedReportActions, currentUnreadMarker],
+ );
+
/**
* @param {Object} args
* @param {Number} args.index
@@ -269,7 +278,7 @@ function ReportActionsList({
({item: reportAction, index}) => {
let shouldDisplayNewMarker = false;
- if (!currentUnreadMarker.current) {
+ if (!currentUnreadMarker) {
const nextMessage = sortedReportActions[index + 1];
const isCurrentMessageUnread = isMessageUnread(reportAction, report.lastReadTime);
shouldDisplayNewMarker = isCurrentMessageUnread && !isMessageUnread(nextMessage, report.lastReadTime);
@@ -279,18 +288,17 @@ function ReportActionsList({
}
const canDisplayMarker = scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD ? reportAction.created < userActiveSince.current : true;
- if (!currentUnreadMarker.current && shouldDisplayNewMarker && canDisplayMarker) {
- currentUnreadMarker.current = reportAction.reportActionID;
+ if (!currentUnreadMarker && shouldDisplayNewMarker && canDisplayMarker) {
+ setCurrentUnreadMarker(reportAction.reportActionID);
}
} else {
- shouldDisplayNewMarker = reportAction.reportActionID === currentUnreadMarker.current;
+ shouldDisplayNewMarker = reportAction.reportActionID === currentUnreadMarker;
}
const shouldDisplayParentAction =
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED &&
ReportUtils.isChatThread(report) &&
!ReportActionsUtils.isTransactionThread(ReportActionsUtils.getParentReportAction(report));
- const shouldHideThreadDividerLine = sortedReportActions.length > 1 && sortedReportActions[sortedReportActions.length - 2].reportActionID === currentUnreadMarker.current;
return shouldDisplayParentAction ? (
);
},
- [report, hasOutstandingIOU, sortedReportActions, mostRecentIOUReportActionID, messageManuallyMarked],
+ [report, hasOutstandingIOU, sortedReportActions, mostRecentIOUReportActionID, messageManuallyMarked, shouldHideThreadDividerLine, currentUnreadMarker],
);
// Native mobile does not render updates flatlist the changes even though component did update called.
// To notify there something changes we can use extraData prop to flatlist
- const extraData = [isSmallScreenWidth ? currentUnreadMarker.current : undefined, ReportUtils.isArchivedRoom(report)];
+ const extraData = [isSmallScreenWidth ? currentUnreadMarker : undefined, ReportUtils.isArchivedRoom(report)];
const hideComposer = ReportUtils.shouldDisableWriteActions(report);
const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(personalDetailsList, report, currentUserPersonalDetails.accountID) && !isComposerFullSize;
return (
<>
diff --git a/src/styles/styles.js b/src/styles/styles.js
index a748a0fb353b..18e000e9faba 100644
--- a/src/styles/styles.js
+++ b/src/styles/styles.js
@@ -3614,10 +3614,8 @@ const styles = (theme) => ({
},
reportHorizontalRule: {
- borderBottomWidth: 1,
borderColor: theme.border,
...spacing.mh5,
- ...spacing.mv2,
},
assigneeTextStyle: {