-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Send mostRecentReportActionLastModified
with ReconnectApp
#18807
Changes from 26 commits
8ac9d8c
72dcafc
8299384
3b680b0
e176806
ce9e668
b0c0aae
32e19d0
c3bf45b
d875a91
bb88c62
0619651
ec5a796
79feeef
e1ddfc2
2ac3528
6adf6de
4df4678
112b97d
4eda351
a88a3cb
c0583f8
0942351
daf4e6f
827562e
87b1c91
c256bb4
0a83f50
eaca434
76f76ad
41487c2
2341952
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import _ from 'underscore'; | ||
import lodashGet from 'lodash/get'; | ||
import ONYXKEYS from '../ONYXKEYS'; | ||
|
||
/** | ||
* Determine if the transitioning user is logging in as a new user. | ||
|
@@ -28,7 +31,34 @@ function isLoggingInAsNewUser(transitionURL, sessionEmail) { | |
return linkedEmail !== sessionEmail; | ||
} | ||
|
||
export { | ||
// eslint-disable-next-line import/prefer-default-export | ||
isLoggingInAsNewUser, | ||
}; | ||
let loggedInDuringSession; | ||
|
||
// To tell if the user logged in during this session we will check the value of session.authToken once when the app's JS inits. When the user logs out | ||
// we can reset this flag so that it can be updated again. | ||
Onyx.connect({ | ||
key: ONYXKEYS.SESSION, | ||
callback: (session) => { | ||
if (!_.isUndefined(loggedInDuringSession)) { | ||
return; | ||
} | ||
|
||
if (session && session.authToken) { | ||
loggedInDuringSession = false; | ||
} else { | ||
loggedInDuringSession = true; | ||
} | ||
}, | ||
}); | ||
|
||
function resetDidUserLogInDuringSession() { | ||
loggedInDuringSession = undefined; | ||
} | ||
|
||
/** | ||
* @returns {boolean} | ||
*/ | ||
function didUserLogInDuringSession() { | ||
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. Looking at this again, would it make more sense / be better to have some other system, like "isOnyxDataEmpty"? Maybe not? 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. It's a good question since all sorts of data could be "empty" and any could be used to signify that we have not yet called Looking whether Onyx data is entirely empty or not would present a new challenge. This gets pretty complicated, but the gist of it is that Onyx can initialize with various default states and when cleared we will reapply those default states. So, there really is no way for Onyx data to ever truly be "empty" as far as the App code is concerned. 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. Thanks for the explanation, makes sense 👍 |
||
return Boolean(loggedInDuringSession); | ||
} | ||
|
||
export {isLoggingInAsNewUser, didUserLogInDuringSession, resetDidUserLogInDuringSession}; |
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.
Can you clarify why you removed this?
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.
More context here: #18807 (comment)
Lmk if you want to discuss further? I am going to cause a regression with this - but the original solution is a hack.