-
Notifications
You must be signed in to change notification settings - Fork 3k
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
HIGH: Kill ReconnectToReport #34902
HIGH: Kill ReconnectToReport #34902
Changes from 1 commit
404732f
0b4b666
bcfe3ab
7cb1ab1
10360a3
148f19d
c369feb
6e2648d
ea3f7b6
278c3f1
325111d
5c587e0
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 |
---|---|---|
|
@@ -88,10 +88,7 @@ function ReportActionsView(props) { | |
const isFirstRender = useRef(true); | ||
const hasCachedActions = useInitialValue(() => _.size(props.reportActions) > 0); | ||
const mostRecentIOUReportActionID = useInitialValue(() => ReportActionsUtils.getMostRecentIOURequestActionID(props.reportActions)); | ||
|
||
const prevNetworkRef = useRef(props.network); | ||
const prevAuthTokenType = usePrevious(props.session.authTokenType); | ||
|
||
const prevIsSmallScreenWidthRef = useRef(props.isSmallScreenWidth); | ||
|
||
const isFocused = useIsFocused(); | ||
|
@@ -118,36 +115,14 @@ function ReportActionsView(props) { | |
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
useEffect(() => { | ||
const prevNetwork = prevNetworkRef.current; | ||
// When returning from offline to online state we want to trigger a request to OpenReport which | ||
// will fetch the reportActions data and mark the report as read. If the report is not fully visible | ||
// then we call ReconnectToReport which only loads the reportActions data without marking the report as read. | ||
const wasNetworkChangeDetected = lodashGet(prevNetwork, 'isOffline') && !lodashGet(props.network, 'isOffline'); | ||
if (wasNetworkChangeDetected) { | ||
if (isReportFullyVisible) { | ||
openReportIfNecessary(); | ||
} else { | ||
Report.reconnect(reportID); | ||
} | ||
} | ||
// update ref with current network state | ||
prevNetworkRef.current = props.network; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [props.network, props.report, isReportFullyVisible]); | ||
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. Not needed anymore because 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. Sounds right to me. |
||
|
||
useEffect(() => { | ||
const wasLoginChangedDetected = prevAuthTokenType === 'anonymousAccount' && !props.session.authTokenType; | ||
if (wasLoginChangedDetected && didUserLogInDuringSession() && isUserCreatedPolicyRoom(props.report)) { | ||
if (isReportFullyVisible) { | ||
openReportIfNecessary(); | ||
} else { | ||
Report.reconnect(reportID); | ||
} | ||
openReportIfNecessary(); | ||
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. This is the only case we still need to fetch report with In the past, we were call |
||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [props.session, props.report, isReportFullyVisible]); | ||
|
||
}, [props.session, props.report]); | ||
useEffect(() => { | ||
const prevIsSmallScreenWidth = prevIsSmallScreenWidthRef.current; | ||
// If the view is expanded from mobile to desktop layout | ||
|
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.
TODO: Need to make sure this isn't needed. If reliable updates works properly, I don't think we should miss a report, but 🤷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.
This code is very very very very Old (~2020), and it is very likely that things were much more unreliable back then. I think this came from this PR:
https://github.com/Expensify/App/pull/339/files
And have been modified a few times after, for example here: https://github.com/Expensify/App/pull/1075/files#r548053786
I think this can be tested by:
accountA
is offline and has never chatted withaccountB
beforeaccountB
creates a DM withaccountA
and sends a message.accountA
misses the push eventaccountA
goes onlineaccountB
sends another messageThat way, when we push the last message sent by
accountB
in step 4,accountA
could have been missing the report, but that is not the case anymore becauseaccountA
got the report in step 3 because of "reliable updates".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.
Agree with you @aldo-expensify that the app is more reliable. I think this code is basically here for the case you have laid out i.e. it was possible to get a pusher update for a report that you didn't have locally yet. And in that case, we would fetch it.
cc @tgolen to get more eyes on this one just in case he can think of something we are not seeing.
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.
Huh... Good to see this code is no longer necessary! I agree with both of you and the assumptions.