-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix: Leave thread chat when has no comment #27849
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
08337c3
leave room when has no comment
dukenv0307 844752d
fix: merge main
dukenv0307 1555286
merge main
dukenv0307 3a8f8f0
fix: resolve conflict
dukenv0307 475a7e0
add comment
dukenv0307 6269ba7
add dependencies to useEffect
dukenv0307 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import React, {useRef, useState, useEffect, useMemo, useCallback} from 'react'; | ||
| import {withOnyx} from 'react-native-onyx'; | ||
| import {useFocusEffect} from '@react-navigation/native'; | ||
| import {useFocusEffect, useIsFocused} from '@react-navigation/native'; | ||
| import PropTypes from 'prop-types'; | ||
| import {View} from 'react-native'; | ||
| import lodashGet from 'lodash/get'; | ||
|
|
@@ -153,6 +153,7 @@ function ReportScreen({ | |
| const reactionListRef = useRef(); | ||
| const prevReport = usePrevious(report); | ||
| const prevUserLeavingStatus = usePrevious(userLeavingStatus); | ||
| const isFocused = useIsFocused(); | ||
|
|
||
| const [skeletonViewContainerHeight, setSkeletonViewContainerHeight] = useState(0); | ||
| const [isBannerVisible, setIsBannerVisible] = useState(true); | ||
|
|
@@ -180,6 +181,8 @@ function ReportScreen({ | |
| const didSubscribeToReportLeavingEvents = useRef(false); | ||
|
|
||
| const isDefaultReport = checkDefaultReport(report); | ||
| const isThread = ReportUtils.isThread(report); | ||
| const isNotificationPreferenceHidden = report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; | ||
|
|
||
| let headerView = ( | ||
| <HeaderView | ||
|
|
@@ -350,6 +353,14 @@ function ReportScreen({ | |
| [report, isLoading, shouldHideReport, isDefaultReport, isOptimisticDelete, userLeavingStatus], | ||
| ); | ||
|
|
||
| // When the report screen is unmounted or no longer in focus, and the user has no comments on that thread, call LeaveRoom | ||
| useEffect(() => { | ||
|
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. Will this hook runs when component unmounts ?
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. Yes, it will |
||
| if (isFocused || !isThread || !isNotificationPreferenceHidden) { | ||
| return; | ||
| } | ||
| Report.leaveRoom(reportID, false); | ||
| }, [isFocused, isThread, isNotificationPreferenceHidden, reportID]); | ||
|
|
||
| return ( | ||
| <ReportScreenContext.Provider | ||
| value={{ | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this line above the modal dismissal .
Bug: User is navigated to concierge after leaving the thread
CleanShot.2023-09-26.at.16.07.37.mp4
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fedirjh I see the problem, this PR changed the logic
so I don't think just moving that IF condition will work since when we call LeaveRoom, we set the optimistic data of that report statusNum to CLOSED
App/src/libs/actions/Report.js
Line 1868 in fff2dd4
In ReportScreen, we have a logic to navigate to Concierge once statusNum is CLOSED
App/src/pages/home/ReportScreen.js
Lines 312 to 321 in fff2dd4
Working on this to find a solution
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one simple solution for this bug is that we add an optimistic prop let's say
shouldNavigateand use it to prevent redirection insideReportScreen.