-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Implement a debug setting that simulates a poor connection by going online/offline a bunch #53698
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
86c486b
43330f8
5e52653
2b9fb2d
714a2ec
2be5a97
3e6f419
4f0f128
e2ed846
b1b14a2
10ee0d8
8c8adc6
53b39c5
da8a017
ba65360
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ import Onyx from 'react-native-onyx'; | |||||
| import Log from '@libs/Log'; | ||||||
| import type {NetworkStatus} from '@libs/NetworkConnection'; | ||||||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||||||
| import type {ConnectionChanges} from '@src/types/onyx/Network'; | ||||||
|
|
||||||
| function setIsOffline(isOffline: boolean, reason = '') { | ||||||
| if (reason) { | ||||||
|
|
@@ -32,4 +33,21 @@ function setShouldFailAllRequests(shouldFailAllRequests: boolean) { | |||||
| Onyx.merge(ONYXKEYS.NETWORK, {shouldFailAllRequests}); | ||||||
| } | ||||||
|
|
||||||
| export {setIsOffline, setShouldForceOffline, setShouldFailAllRequests, setTimeSkew, setNetWorkStatus}; | ||||||
| function setPoorConnectionTimeoutID(poorConnectionTimeoutID: NodeJS.Timeout | undefined) { | ||||||
| Onyx.merge(ONYXKEYS.NETWORK, {poorConnectionTimeoutID}); | ||||||
| } | ||||||
|
|
||||||
| function setShouldSimulatePoorConnection(shouldSimulatePoorConnection: boolean, poorConnectionTimeoutID: NodeJS.Timeout | undefined) { | ||||||
| if (!shouldSimulatePoorConnection) { | ||||||
| clearTimeout(poorConnectionTimeoutID); | ||||||
| Onyx.merge(ONYXKEYS.NETWORK, {shouldSimulatePoorConnection, poorConnectionTimeoutID: undefined}); | ||||||
|
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.
Suggested change
It seems we set shouldSimulatePoorConnection 2 times if shouldSimulatePoorConnection=false. I think we either use
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. Nice catch! I forgot to add an earlier return, updated! |
||||||
| return; | ||||||
| } | ||||||
| Onyx.merge(ONYXKEYS.NETWORK, {shouldSimulatePoorConnection}); | ||||||
| } | ||||||
|
|
||||||
| function setConnectionChanges(connectionChanges: ConnectionChanges) { | ||||||
| Onyx.merge(ONYXKEYS.NETWORK, {connectionChanges}); | ||||||
| } | ||||||
|
|
||||||
| export {setIsOffline, setShouldForceOffline, setConnectionChanges, setShouldSimulatePoorConnection, setPoorConnectionTimeoutID, setShouldFailAllRequests, setTimeSkew, setNetWorkStatus}; | ||||||
Uh oh!
There was an error while loading. Please reload this page.