Repository navigation
fix: Allow multiple loads in useLoadReportActions hook
#76104
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
Changes from all commits
752818e
78b9e08
82871aa
d52a3db
f52664a
ddbe111
9281641
813340d
e94134c
8e53c67
67ee491
ffd9815
550ed29
46f49fa
742e02e
9cc3ef0
67ac0fa
dd36c52
f3ae0a7
41c2d90
6e82b8d
e79c8e8
84a4a02
89a6999
9ab146d
1d563e7
f5c6ad8
8953594
b30e256
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -311,13 +311,11 @@ function paginate<TRequestType extends ApiRequestType, TCommand extends CommandO | |
|
|
||
| switch (type) { | ||
| case CONST.API_REQUEST_TYPE.WRITE: | ||
| processRequest(request, type); | ||
| return; | ||
| return processRequest(request, type); | ||
| case CONST.API_REQUEST_TYPE.MAKE_REQUEST_WITH_SIDE_EFFECTS: | ||
| return processRequest(request, type); | ||
| case CONST.API_REQUEST_TYPE.READ: | ||
| waitForWrites(command as ReadCommand).then(() => processRequest(request, type)); | ||
| return; | ||
| return waitForWrites(command as ReadCommand).then(() => processRequest(request, type)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is correct. @rlinoz not sure what is "allowed" to be a request with side effect, but if we actually want to wait until the API has sent it's response for these requests, i suppose we can treat that as a side effect? I don't think there's another way of actually awaiting the response. Wdyt?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I don't think there is another way of waiting on response. Can you start a thread about this in #expert-contributors so we can get some feedback, please? |
||
| default: | ||
| throw new Error('Unknown API request type'); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ import InvertedFlatList from '@components/InvertedFlatList'; | |
| import {usePersonalDetails} from '@components/OnyxListItemProvider'; | ||
| import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView'; | ||
| import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; | ||
| import {AUTOSCROLL_TO_TOP_THRESHOLD} from '@hooks/useFlatListScrollKey'; | ||
| import useIsAnonymousUser from '@hooks/useIsAnonymousUser'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useNetworkWithOfflineStatus from '@hooks/useNetworkWithOfflineStatus'; | ||
|
|
@@ -346,13 +345,10 @@ function ReportActionsList({ | |
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [lastAction?.created]); | ||
|
|
||
| const lastActionIndex = lastAction?.reportActionID; | ||
| const reportActionSize = useRef(sortedVisibleReportActions.length); | ||
| const lastVisibleActionCreated = getReportLastVisibleActionCreated(report, transactionThreadReport); | ||
| const hasNewestReportAction = lastAction?.created === lastVisibleActionCreated || isReportPreviewAction(lastAction); | ||
| const hasNewestReportActionRef = useRef(hasNewestReportAction); | ||
| hasNewestReportActionRef.current = hasNewestReportAction; | ||
| const previousLastIndex = useRef(lastActionIndex); | ||
| const sortedVisibleReportActionsRef = useRef(sortedVisibleReportActions); | ||
|
|
||
| const {isFloatingMessageCounterVisible, setIsFloatingMessageCounterVisible, trackVerticalScrolling, onViewableItemsChanged} = useReportUnreadMessageScrollTracking({ | ||
|
|
@@ -370,20 +366,6 @@ function ReportActionsList({ | |
| }, | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| if ( | ||
| scrollOffsetRef.current < AUTOSCROLL_TO_TOP_THRESHOLD && | ||
| previousLastIndex.current !== lastActionIndex && | ||
| reportActionSize.current !== sortedVisibleReportActions.length && | ||
| hasNewestReportAction | ||
| ) { | ||
| setIsFloatingMessageCounterVisible(false); | ||
| reportScrollManager.scrollToBottom(); | ||
| } | ||
| previousLastIndex.current = lastActionIndex; | ||
| reportActionSize.current = sortedVisibleReportActions.length; | ||
| }, [lastActionIndex, sortedVisibleReportActions.length, reportScrollManager, hasNewestReportAction, linkedReportActionID, setIsFloatingMessageCounterVisible, scrollOffsetRef]); | ||
|
|
||
| useEffect(() => { | ||
| const shouldTriggerScroll = shouldFocusToTopOnMount && prevHasCreatedActionAdded && !hasCreatedActionAdded; | ||
| if (!shouldTriggerScroll) { | ||
|
|
@@ -549,9 +531,13 @@ function ReportActionsList({ | |
| if (action?.reportActionID) { | ||
| setActionIdToHighlight(action.reportActionID); | ||
| } | ||
| } else { | ||
| } else if (Navigation.getReportRHPActiveRoute()) { | ||
| setIsFloatingMessageCounterVisible(false); | ||
| reportScrollManager.scrollToBottom(); | ||
| } else { | ||
| Navigation.setNavigationActionToMicrotaskQueue(() => { | ||
| Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID)); | ||
| }); | ||
|
Comment on lines
+538
to
+540
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For non- Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Addressing this!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only navigating if the |
||
| } | ||
|
|
||
| setIsScrollToBottomEnabled(true); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import type ChatContentScrollViewPlatformStyles from './types'; | ||
|
|
||
| const chatContentScrollViewPlatformStyles: ChatContentScrollViewPlatformStyles = { | ||
| overflow: 'hidden', | ||
| overflow: 'clip', | ||
| }; | ||
|
|
||
| export default chatContentScrollViewPlatformStyles; |
Uh oh!
There was an error while loading. Please reload this page.